Can I force a project refresh without completing the default lifecycle phase?

I have yet to find documentation on what exactly causes the force refresh, and I've seen it behave differently depending on which lifecycle phase is started. This led me to the conclusion, although this maven certainly cares about which stage you are using if you try to force update (with -U) and ignore the force update if not needed.

I would like to force the upgrade even though I am not following the default lifecycle phase. My use case is to release my application with temporary versions of snapshots using the command:

mvn clean release:perform release:prepare -U

      

I can see that even though the snapshots are versioned, internally it gets the latest SNAPSHOT in its local repo. If I run first mvn compile -U

, then my snapshots will be updated and the release will happen as expected.

I'm curious why the timestamp version is not being used to pull the new artifact out of the nexus, but I suppose it has something to do with the more limited release plugin and not maven itself.

Since I'm accepting defeat with the release plugin, is there a way to force it to update without going through a separate (and unnecessary) lifecycle phase. Or is there a way to pass in -U to run the maven release plugin when I build my project?

+3


source to share


2 answers


First, you mix different concepts. You are calling:

mvn release:prepare...

      

which does not run the lifecycle in contradictions, it runs the release plugin with a specific target prepare

and of course .. release:perform

runs the target perform

.

In addition, the release plugin starts a subprocess (running maven in the target / control subfolder) with a release (tag) generated, which does not normally pass the -U option to that subprocess. This can be done with `mvn -Darguments =" ... "'.



But if you want to force a snapshot update at build time, you can simply use mvn -U...

like:

mvn -U clean package 

      

This means simple let maven checked in the Nexus if there are new SNAPSHOTs, if so, upload them to your local repository, rather than wait until it's time to update the SNAPSHOT (see updatePolicy ).

If you want to change your versions in your build without the maven-release plugin, you can take a look at the versions-maven-plugin , but in that case you need to do your tags, etc. yourself.

+1


source


First of all, let the release

candidate never depend on SNAPSHOTS

, if you still want to do it,



mvn dependency:resolve -U

      

+1


source







All Articles