Ensure all sourceSets are compiled as part of Gradle precommit (#91897)

This commit is contained in:
Rene Groeschke 2022-11-24 21:30:41 +01:00 committed by GitHub
parent 6b7e8ffeaf
commit 1efb95b857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -31,10 +31,10 @@ public class PrecommitTaskPlugin implements Plugin<Project> {
"lifecycle-base", "lifecycle-base",
p -> project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(precommit)) p -> project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(precommit))
); );
project.getPluginManager().withPlugin("java", p -> { project.getPluginManager().withPlugin("java-base", p -> {
// run compilation as part of precommit // run compilation as part of precommit
project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().all(sourceSet -> project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().all(sourceSet ->
precommit.configure(t -> t.shouldRunAfter(sourceSet.getClassesTaskName())) precommit.configure(t -> t.dependsOn(sourceSet.getClassesTaskName()))
); );
// make sure tests run after all precommit tasks // make sure tests run after all precommit tasks
project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit)); project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit));

View file

@ -38,8 +38,8 @@ public class ElasticsearchJavaBasePlugin implements Plugin<Project> {
public void apply(Project project) { public void apply(Project project) {
// make sure the global build info plugin is applied to the root project // make sure the global build info plugin is applied to the root project
project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class);
// common repositories setup
project.getPluginManager().apply(JavaBasePlugin.class); project.getPluginManager().apply(JavaBasePlugin.class);
// common repositories setup
project.getPluginManager().apply(RepositoriesSetupPlugin.class); project.getPluginManager().apply(RepositoriesSetupPlugin.class);
project.getPluginManager().apply(ElasticsearchTestBasePlugin.class); project.getPluginManager().apply(ElasticsearchTestBasePlugin.class);
project.getPluginManager().apply(PrecommitTaskPlugin.class); project.getPluginManager().apply(PrecommitTaskPlugin.class);