Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven deploy:deploy-file removes extension from file

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?

like image 555
zakaria amine Avatar asked Jun 30 '16 13:06

zakaria amine


People also ask

What happens on mvn deploy?

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.

Does maven deploy include package?

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.

Does maven deploy also build?

So, the answer is yes, mvn deploy will execute install and build the project artifacts.

What is maven deploy command?

mvn deploy. This command invokes the deploy phase: deploy : copies the final package to the remote repository for sharing with other developers and projects.


1 Answers

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.

like image 136
A_Di-Matteo Avatar answered Sep 19 '22 12:09

A_Di-Matteo