replace nexus staging maven plugin with maven-deploy-plugin - maven

Our project inherits nexus staging maven plugin from a parent pom which we don't have control on. I have this configuration in my root pom to disable the nexus staging maven plugin and this configuration seems to disabling the default-deploy execution.
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<serverId>nexus</serverId>
<nexusUrl>url</nexusUrl>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
</configuration>
</plugin>
and I have the maven deploy plugin defined in my root pom, but the maven-deploy plugin seems to be not kicking off
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
I am not able to figure out how i can replace the inherited nexus staging maven plugin with the maven deploy plugin. Any help is much appreciated

You may qualify the goal by the plugin groupID:artefactID:
mvn org.apache.maven.plugins:maven-deploy-plugin:deploy

I faced a similar issue, and for success disabling of nexus-staging-maven-plugin I only need to add following to my main pom:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>false</extensions>
</plugin>
And as one of my dependencies was disabling maven-deploy-plugin(I reccomend to check it also in your project) I also need to add:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>

Related

How can I execute following maven plugin before resolving the dependencies

I am from ANT background and newbie to Maven.
For some reason, I need to execute shell script before maven tries to fetch snapshot dependencies.
So I wrote following plugin configuration, but I not getting how can I make it invoke before resolving dependencies task.
I am using Apache Maven 3.0.5
Following is the part of my pom.xml
<build>
<finalName>edte</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>Docs/ci/delete_snapshots.sh</executable>
<arguments>
<argument>${user.home}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Any help is appreciated.

Maven jarsigner plugin

I just tried to configure the maven jarsigner plugin for signing a jar project.
As far as I can understand, the plugin should run automatically when I run mvn clean package but it doesn't.
I must run mvn clean package jarsigner:sign for the plugin to be executed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<configuration>
<executions>
<execution>
<id>sign</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<alias>java-code</alias>
<keystore>mykeystore.keystore</keystore>
<keypass>mykeypass</keypass>
<storepass>mystorepass</storepass>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
I could find the error on my own. The configuration element has to be within the execution element.
Thanks.

remove jar created by default in maven

I am using maven assembly plugin. in my pom.xml, pakaging type: jar and i dont use maven jar plugin.
Whenever i run mvn clean package, it create 2 jar files: one is from maven assembly, another one is created by default (due to packaging type =jar). I want to keep only the jar file created by assembly plugin only. How to do that?
You may have your reasons but I doubt that it is a good solution to skip the default jar being built and deployed.
Anyhow here is how you can disable the default jar being built.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<id>make-assembly</id>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- some configuration of yours... -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<!-- put the default-jar in the none phase to skip it from being created -->
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

Can I modify the Maven deploy phase to replace the maven-deploy-plugin with my own plugin?

I'm pretty new to Maven...
What I'm trying to do is skip the maven-deploy-plugin during the deploy phase, while replacing it with my own plugin (i.e. I'm deploying to a non-repository location).
I realize I could do this in multiple other ways, but the boss wants to be able to run:
mvn deploy
To get the results of my current workaround, which is disabling the maven-deploy-plugin (which seems to be disabling the entire deploy phase), and manually specifying the custom upload goal from the command line.
I'm currently failing to succeed in my mission with:
<executions>
<execution>
<phase>deploy</phase>
</execution>
</executions>
in the build/plugins/plugin section containing my plugin specification, since the deploy phase is skipped by:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Thanks!
disabling the maven-deploy-plugin (which seems to be disabling the entire deploy phase)
This is not correct. Disabling maven-deploy-plugin doesn't disable the entire deploy phase. This is how it should be done (looks like you're doing it already):
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Try this (untested) alternative for disabling the standard deploy plugin:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
I want to build on #yegor256's answer a bit... 8 years, 4 months later!
I found myself here getting into the weeds on some legacy Maven configurations that were full of cruft. Coming from a Maven mindset, albeit some years between now and active hacking, I was re-familiarizing myself with the Maven lifecycle.
TLDR... mvn help:effective-pom is your friend. Use your IDE's tools for viewing the effective POM often (NetBeans makes it easy. I added a keyboard shortcut in IntelliJ.)
In the configuration I was reviewing, the previous developers had created two (2) deploy-file executions, one war, one jar.
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-war</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
... omitted ...
</configuration>
</execution>
<execution>
<id>deploy-jar</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
... omitted ...
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
I was aware that these executions would be appended to the default-deploy bound to the deploy phase and observed this behavior in the logs. The default-deploy would run, uploading an empty war file, then the deploy-war would run, uploading, and overwriting, the first war file.
Several options exist.
skip and combine.self="override" (my preference)
As presented, using <skip> as a <configuration> option is viable. It is safe and more portable than setting setting the <phase> to none.
However, it will be inherited by the other executions (certainly as presented). To prevent this, you must explicitly tell your additional <execution> configurations to not inherit.
...
...
<executions>
<execution>
<id>deploy-war</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration combine.self="override">
... omitted ...
</configuration>
</execution>
...
...
Override default-deploy
Another option, possibly more verbose and lest esoteric than combine.self="override" is to override the execution of the default-deploy <id> of the plugin.
...
<execution>
<id>default-deploy</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
...
This will not be inherited by the additional <executions>.
Another option
As #yegor256 notes, but in the additional configurations explicitly state <skip>false</skip> to "reset" the inherited <skip> from the plugin.
HTH.

maven-site-plugin not generating apidocs folder with javadocs

I inherited a project that is supposed to build javadoc files and place them in the site directory. This is not being done. I have looked at all the examples I can find and I can't figure out where the configuration is broken.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</plugin>
</reportPlugins>
</configuration>
</execution>
</executions>
</plugin>
Any and all help is greatly appreciated.
You have bound maven site plugin's site goal to prepare-package phase. You have configured javadoc generation in this plugin configuration.
As such, if you run maven's default lifecycle goals like mvn package or mvn install you should get site report with javadocs.
If you ran mvn site, it would skip prepare-package phase to which your plugin configuration is bound and hence would not generate javadoc.

Resources