|
50 | 50 | import org.eclipse.aether.RepositorySystem; |
51 | 51 | import org.eclipse.aether.RepositorySystemSession; |
52 | 52 | import org.eclipse.aether.repository.RemoteRepository; |
| 53 | +import org.sonatype.plexus.build.incremental.BuildContext; |
53 | 54 |
|
54 | 55 | import com.diffplug.spotless.Formatter; |
55 | 56 | import com.diffplug.spotless.LineEnding; |
@@ -88,6 +89,9 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo { |
88 | 89 | @Component |
89 | 90 | private ResourceManager resourceManager; |
90 | 91 |
|
| 92 | + @Component |
| 93 | + protected BuildContext buildContext; |
| 94 | + |
91 | 95 | @Parameter(defaultValue = "${mojoExecution.goal}", required = true, readonly = true) |
92 | 96 | private String goal; |
93 | 97 |
|
@@ -344,10 +348,13 @@ private UpToDateChecker createUpToDateChecker(Iterable<Formatter> formatters) { |
344 | 348 | Path targetDir = project.getBasedir().toPath().resolve(project.getBuild().getDirectory()); |
345 | 349 | indexFile = targetDir.resolve(DEFAULT_INDEX_FILE_NAME); |
346 | 350 | } |
| 351 | + final UpToDateChecker checker; |
347 | 352 | if (upToDateChecking != null && upToDateChecking.isEnabled()) { |
348 | 353 | getLog().info("Up-to-date checking enabled"); |
349 | | - return UpToDateChecker.forProject(project, indexFile, formatters, getLog()); |
| 354 | + checker = UpToDateChecker.forProject(project, indexFile, formatters, getLog()); |
| 355 | + } else { |
| 356 | + checker = UpToDateChecker.noop(project, indexFile, getLog()); |
350 | 357 | } |
351 | | - return UpToDateChecker.noop(project, indexFile, getLog()); |
| 358 | + return UpToDateChecker.wrapWithBuildContext(checker, buildContext); |
352 | 359 | } |
353 | 360 | } |
0 commit comments