3

To release my app I am using maven-release-plugin.

One step in this process is deploying the release into the repository. I would like to avoid this step, but when I remove distributionManagement from my pom file I am getting the error:

Deployment failed: repository element was not specified in the POM inside distributionManagement element 

How to configure maven-release-plugin to skip deploying?

Thanks for any advice!

Tomas Marik
  • 4,053
  • 3
  • 31
  • 62
  • Why would you like to to avoid that? Are you not working with a repository? – khmarbaise Jan 26 '20 at 09:07
  • The plugin will do several things for me, eg.: increase version, create a tag in the git repo, etc. All of these are very useful, but I really don't need to deploy jar for every release. May sounds funny but I do release quite often (several times a day) and I dont have that much space on VPS :). If I need to get the old version in the future, I can check out the tag and build it. – Tomas Marik Jan 26 '20 at 09:46

2 Answers2

4

This is nothing unusual or funny to release several times a day..space issue might be questionable but this is a separate discussion.

You can configure the maven release plugin what kind of goals will be done during the release. This can be achieved by configuring the plugin in a pluginManagement at best. And also you should define all the versions of all plugins you are using (most of the time it is most convenient to create a parent pom for your environment).

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <arguments>${arguments}</arguments>
    <goals>The Goal You would like to execute</goals>
    <autoVersionSubmodules>true</autoVersionSubmodules>
  </configuration>
</plugin>

So you could define to only make install instead of deploy like this:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <arguments>${arguments}</arguments>
    <goals>install</goals>
    <autoVersionSubmodules>true</autoVersionSubmodules>
  </configuration>
</plugin>
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
2

As mentioned here, you can use:

mvn release:perform -Darguments="-Dmaven.deploy.skip=true"

(which is also available on other plugins, like github-release-plugin)

As seen in glib-briia/cucumber-jvm-scala pom.xml, you can also define a profile in your pom.xml in order to activate the skip when you want.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Arguments will only work if you have configured the maven-release-plugin within your hierarchy accordingly. Apart from that if you have to do that several times you likely miss the parameters and makes it more inconvenient than necessary. – khmarbaise Jan 26 '20 at 10:17
  • A profile means you have to add the option to the command line which is is not very convenient... – khmarbaise Jan 26 '20 at 10:24