2

Can a custom Maven plugin use incremental build support from core Maven or would it best have to implement that completely itself, with SHA1 hashes over the input and the like?

Noticed e.g. /target/maven-status/maven-compiler-plugin/compile/default-compile with createdFiles.lst and inputFiles.lst, so thinking that an existing custom e.g. code generator Maven plugin, which reads some files as input, generates some output, may be able to be changed to correctly use Maven Plugin APIs for incremental build? Unclear what specifically that plugin code would have to do differently than it does today for it to become incremental. Doesn't look like there is any doc about this?

Existing code does use e.g. org.sonatype.plexus.build.incremental.BuildContext.hasDelta(File), but with "return true" in org.sonatype.plexus.build.incremental.DefaultBuildContext.hasDelta(File) it's not surprising that this doesn't quite work... ;-) Is this not implemented in Maven, or can be configured differently? Would this require the takari-lifecycle-plugin? (That would be a problem in the case of the particular plugin I'm asking for, because the use of takari-jar instead of normal JAR would interfere with other plugins.)

Understood that the custom Maven plugin likely would have to interface with Maven core API to expose its notion of dependencies between the input files. In the case of this particular custom Maven plugin, some of the input is read from dependencies on the project's classpath. Would the incremental support be able to handle that as well?

Understood that existing Maven plugins, such as maven-compiler-plugin, are struggling with incremental builds (à la Gradle); see [1], [2] and [3], so this Q is specifically to learn about how a custom Maven plugin may be extended to support incremental build.

[1] http://takari.io/2014/10/16/incremental-compilation.html

[2] http://takari.io/book/40-lifecycle.html

[3] Does Maven support incremental builds?

Community
  • 1
  • 1
vorburger
  • 3,439
  • 32
  • 38

1 Answers1

0

can Maven custom plugins use incremental build support from core Maven?

yes. take a look on the sources of 'querydsl-maven-plugin'. also you can find more usages of BuildContext.hasDelta method with grepcode.com.

does it have to implement that itself?

may it? yes. have to? no.

usually such question means just an unnecessary preemptive optimization. you have to have a rational reason to look forward on incremental builds, before you start implement anything.

ursa
  • 4,404
  • 1
  • 24
  • 38
  • How well has this answer aged? Is this still the state of art for current or at least Mave 3.6+? – wilx Jul 28 '21 at 08:31