Repository navigation
Skip unnecessary Muzzle checking #12800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,14 +101,17 @@ class MuzzlePlugin : Plugin<Project> { | |
| } | ||
| project.publishMuzzleReport(report.flatMap { it.versionsFile }) | ||
|
|
||
| val hasRelevantTask = project.gradle.startParameter.taskNames.any { taskName -> | ||
| val relevantTasks = project.gradle.startParameter.taskNames.filter { taskName -> | ||
| val taskProjectPath = taskName.substringBeforeLast(":", "") | ||
| val taskNameOnly = taskName.substringAfterLast(":") | ||
| val isRelevantForProject = taskProjectPath.isEmpty() || taskProjectPath == project.path | ||
| val isAggregate = taskNameOnly.equals("runMuzzle", ignoreCase = true) | ||
| val isRelevantForProject = taskProjectPath.isEmpty() || taskProjectPath == project.path || | ||
| (isAggregate && project.path.startsWith("$taskProjectPath:")) | ||
|
|
||
| isRelevantForProject && taskNameOnly.endsWith("muzzle", ignoreCase = true) | ||
| isRelevantForProject && !taskNameOnly.equals("compileMuzzle", ignoreCase = true) && | ||
| taskNameOnly.endsWith("muzzle", ignoreCase = true) | ||
| } | ||
| if (!hasRelevantTask) { | ||
| if (relevantTasks.isEmpty()) { | ||
| // Adding muzzle dependencies has a large config overhead. Stop unless muzzle is explicitly run. | ||
| project.logger.info("No muzzle tasks invoked for ${project.path}, skipping muzzle task planification") | ||
| return | ||
|
|
@@ -117,10 +120,15 @@ class MuzzlePlugin : Plugin<Project> { | |
| // We only get here if we are running muzzle, so let's start timing things | ||
| val startTime = System.currentTimeMillis() | ||
|
|
||
| val system = MuzzleMavenRepoUtils.newRepositorySystem() | ||
| val session = MuzzleMavenRepoUtils.newRepositorySystemSession(system) | ||
| val taskPlanner = MuzzleTaskPlanner.from(system, session) | ||
| project.afterEvaluate { | ||
| if (relevantTasks.all { it.substringAfterLast(":").equals("runMuzzle", ignoreCase = true) } && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Hmm this still couples muzzle plugin to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I stumbled by chance to a feature of Gradle that allows to register and connect task very late, when Gradle assembled the task execution graph, which happens after project evaluation but before execution. This looks like the exact thing needed. And as a byproduct (that I actually wanted for a while) it removes |
||
| !extension.includeInAggregate.get()) { | ||
| project.logger.info("No muzzle tasks invoked for ${project.path}, skipping muzzle task planification") | ||
| return@afterEvaluate | ||
| } | ||
| val system = MuzzleMavenRepoUtils.newRepositorySystem() | ||
| val session = MuzzleMavenRepoUtils.newRepositorySystemSession(system) | ||
| val taskPlanner = MuzzleTaskPlanner.from(system, session) | ||
| // use runAfter to set up task finalizers in version order | ||
| var runAfter: TaskProvider<MuzzleTask> = muzzleTask | ||
| val muzzleReportTasks = mutableListOf<TaskProvider<MuzzleTask>>() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Cover both absolute and relative paths in the nested-aggregate test;
dd-java-agent:runMuzzlecurrently reports success without running the descendant checks.In
MuzzlePluginFunctionalTest, parameterize the existing test:Use
run(taskName)and retain the generated check'sSUCCESSassertion. Here, the relativetaskProjectPathcannot match the absoluteproject.path. This limitation predates the PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this block turns out to be useless and removed in #12831, so you can dismiss it.