I am trying to deploy signature files separately using deploy-file
goal to Nexus staging repository, but I noticed that mvn deploy plugin removes the extension. My file is something like: azerty-0.1.jar.asc
but the file that gets deployed is: azerty-0.1.asc
I tried adding a classifier: -Dclassifier=jar
the file that gets deployed is: azerty-0.1-jar.asc
This seems like a strange behaviour.
Question: Any ideas how to work around it?
The mvn deploy runs the deploy plugin which deploys an artifact to the remote repository. A project may include the main jar and associated sources and Javadoc jars. The sources jar contains the Java sources, and the Javadoc jar contains the generated Javadoc.
When you call mvn deploy , mvn will also execute every lifecycle phase before deploy , in order: validate , compile , test , package , verify , install . Same for verify : validate , compile , test , package . Same for all other phases.
So, the answer is yes, mvn deploy will execute install and build the project artifacts.
mvn deploy. This command invokes the deploy phase: deploy : copies the final package to the remote repository for sharing with other developers and projects.
This is rather a normal behavior, Maven is using the file extension as artefact packaging
, from maven-deploy-plugin
, deploy-file
, packaging
option:
Type of the artifact to be deployed. Retrieved from the
<packaging>
element of the POM file if a POM file specified. Defaults to the file extension if it is not specified via command line or POM.
Note: bold is mine.
Moreover, the classifier
option would indeed add an -
between the version and the string provided as classifier: that's maven convention.
In your case you want to specify a special packaging
, which would be jar.asc
if you really want the remote file to have as extension jar.asc
.
The following would hence work:
mvn deploy:deploy-file -Dfile=azerty-0.1.jar.asc -Dpackaging=jar.asc -DrepositoryId=your_id -Durl=http://your_repository -DgroupId=your_groupId -DartifactId=azerty -Dversion=0.1
Note the -Dpackaging=jar.asc
which effectively tells Maven the file extension would be jar.asc
.
As a general note, if you are using the repository as a build store, that would still be reasonable, otherwise in your case you would push to a Maven repository an artifact which would then be difficult (or rather weird) to import in a project.
If instead this is really an additional artifact of your project, you should look at the attach-artifact
goal of the build-helper-maven-plugin
, to effective define it as additional artifact, then Maven will automatically add it to its install
and deploy
phase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With