Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Release without pushing to Nexus (aka maven central)

Tags:

git

maven

nexus

I've got a java application that I want to follow the typical maven release cycle with, but I don't want or need to push the application to Nexus (or maven central).

When I run

mvn release:prepare release:perform -Darguments="-DskipTests=true -Dmaven.javadoc.skip=true"

I get an error during the perform stage that says the pom.xml file was missing the <distributionManagement> definitions required to push the built artifacts to NEXUS (our internal maven repo).

I'm using git and when I use git log I can see that all the other steps that I wanted to perform were performed properly.

  • The pom.xml file was changed from 1.2-SNAPSHOT to 1.2 and a commit was performed and a git tag was created at to tag that release.
  • The pom.xml file was then changed to 1.3-SNAPSHOT to ready the git branch to be used for subsequent development.

So... everything looks good. All I want to do is to tell maven not to try to do the push so the command completes without an error. NOTE: A couple files from release:prepare were left around, one was release.properties, but I can live with manually deleting that if necessary.

Some solutions I'm looking for are:

  • You can't do that.
  • Just take off the release:perform and only run release:prepare. I'm testing this now.
  • Add the flag -DmavenReleasePluginDontPushToNexus=true. I'm making this up but wondering if there is a flag.

I've looked for solutions to all the above and haven't found an answer yet.

Searching for solution

Maven Release Plugin

  • The maven release plugin documentation is at http://maven.apache.org/maven-release/maven-release-plugin/plugin-info.html. It looks like I don't want to use release:perform based on reading this!

  • Docs for release:perform goal. http://maven.apache.org/maven-release/maven-release-plugin/examples/perform-release.html - pretty useless.

  • https://maven.apache.org/guides/mini/guide-releasing.html - A pretty good guide on how to use the maven release plugin.

Stack Overflow Searches

  • How to setup the Maven release plugin with git - Poor person never got his question answered. Viewed 16K times!

  • Maven release plugin 2.2.2 doesn't push to distributionmanagement - This looked promising but basically says it should push and says to add <distributionManagement> elements to define where you want to push things to. Since I don't want to do this I'm not adding this definition.

  • Hudson and maven-release-plugin - OP was trying figure out how to use maven release plugin with hudson. It didn't help.

  • https://stackoverflow.com/search?q=%5Bmaven%5D+release - a search for questions with the maven tag and the word release. Too many results to be useful (over 10,000).

  • https://stackoverflow.com/search?q=%5Bmaven%5D+release+push - Now down to 300 results, better but I didn't find an answer.

My guess is that this has been asked and answered before but so far I can't find it.

like image 260
PatS Avatar asked Oct 30 '25 16:10

PatS


2 Answers

You can do this by changing the goal to install, by default it is deploy:

<artifactId>maven-release-plugin</artifactId>
<configuration>
    <goals>install</goal>
</configuration>

Also, I think you can ignore perform totally, because the updating and committing of BOTH release version and new development versions are done by prepare step: maven release plugin doc

like image 184
Mileyard Gigahertz Avatar answered Nov 02 '25 05:11

Mileyard Gigahertz


I confirm, the release:prepare phase will:

  • Verify that there are no uncommitted changes in the workspace.
  • Prompt the user for the desired tag, release and development version names.
  • Modify and commit release information into the pom.xml file.
  • Tag the entire project source tree with the new tag name.

The only missing step from release:perform that you might need is the increment of the version to the next SNAPSHOT, transforming the release version to a new snapshot, in order to prepare for the next batch of work.
Using version:set will be required.

like image 28
VonC Avatar answered Nov 02 '25 06:11

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!