Ensure precommit runs as part of check (#59476)

Precommit is setup to run as a dependency of the check task, but
unfortunately this wiring was only happening when the java plugin (but
not java-base plugin) was applied. This commit moves the wiring to occur
whenever the check task exists, which is with the lifecycle-base plugin.
This commit is contained in:
Ryan Ernst 2020-07-17 15:41:07 -07:00 committed by Ryan Ernst
parent 514b2f3414
commit e963918830
No known key found for this signature in database
GPG Key ID: 5F7EA39E15F54DCE
1 changed files with 7 additions and 4 deletions

View File

@ -66,10 +66,13 @@ public abstract class PrecommitPlugin implements Plugin<Project> {
t.setDescription("Runs all non-test checks");
});
project.getPluginManager().withPlugin("java", p -> {
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(precommit));
project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit));
});
project.getPluginManager()
.withPlugin(
"lifecycle-base",
p -> project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(precommit))
);
project.getPluginManager()
.withPlugin("java", p -> project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit)));
}
}
}