how to make `mvn package` aware that it has already built the target

Viewed 72

In a makefile, I can easily do something like

${target}: ${sources}
    mvn package

Where I have ${target} the generated jar file, and ${sources} all the java files and the pom.xml. With this makefile, the target will not be be rebuilt unless one of the sources is changed since the last build of the target. The result is

$> make target/demo-0.8.0-SNAPSHOT-jar-with-dependencies.jar
make: 'target/demo-0.8.0-SNAPSHOT-jar-with-dependencies.jar' is up to date.

But just mvn package will always run the maven-assembly-plugin even though none of the source files has changed.

Question:

Is there a way to make mvn package be aware of the source files, similar to how make knows this so it'll just say "no need, it's already built."

1 Answers

Whether or not something makes sense is maybe up to the use case and the developer. In a system where integration is far more complicated than passing unit tests the only way to gain confidence is by deploying into a test Kubernetes environment.

Anyway thanks for answering my question that the maven packaging plugin is unable to handle this dependency tracking.

Related