Skip to content

Commit

Permalink
Ensure running precommit task compiles all project source sets (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira authored Mar 2, 2021
1 parent f06dc63 commit 7fea2ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskProvider;

/**
Expand All @@ -34,9 +33,8 @@ public final void apply(Project project) {
"java",
p -> {
// We want to get any compilation error before running the pre-commit checks.
for (SourceSet sourceSet : GradleUtils.getJavaSourceSets(project)) {
task.configure(t -> t.shouldRunAfter(sourceSet.getClassesTaskName()));
}
GradleUtils.getJavaSourceSets(project)
.all(sourceSet -> task.configure(t -> t.shouldRunAfter(sourceSet.getClassesTaskName())));
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.testing.Test;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
Expand All @@ -37,9 +36,8 @@ public void apply(Project project) {
"java",
p -> {
// run compilation as part of precommit
for (SourceSet sourceSet : GradleUtils.getJavaSourceSets(project)) {
precommit.configure(t -> t.dependsOn(sourceSet.getClassesTaskName()));
}
GradleUtils.getJavaSourceSets(project)
.all(sourceSet -> precommit.configure(t -> t.dependsOn(sourceSet.getClassesTaskName())));

// make sure tests run after all precommit tasks
project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit));
Expand Down

0 comments on commit 7fea2ee

Please sign in to comment.