Skip to content

Commit

Permalink
Ensure format executes after compile (#688)
Browse files Browse the repository at this point in the history
Ensure that format tasks execute after compilation
  • Loading branch information
ferozco authored and bulldozer-bot[bot] committed Jul 12, 2019
1 parent 1395e78 commit d7ca0b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-688.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Ensure that format tasks execute after compilation
links:
- https://github.com/palantir/gradle-baseline/pull/688
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.gradle.api.Task;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.compile.JavaCompile;

class BaselineFormat extends AbstractBaselinePlugin {

Expand Down Expand Up @@ -54,7 +55,11 @@ public void apply(Project project) {

// necessary because SpotlessPlugin creates tasks in an afterEvaluate block
Task formatTask = project.task("format");
project.afterEvaluate(p -> formatTask.dependsOn(project.getTasks().getByName("spotlessApply")));
project.afterEvaluate(p -> {
Task spotlessApply = project.getTasks().getByName("spotlessApply");
formatTask.dependsOn(spotlessApply);
project.getTasks().withType(JavaCompile.class).configureEach(spotlessApply::mustRunAfter);
});
});
}
}

0 comments on commit d7ca0b6

Please sign in to comment.