Maven deploy plugin keep the file name when uploading - maven

I am using maven deploy plugin to upload a file inside bamboo deployment stage. I am uploading the file without pom file. When I upload the file to Nexus, the file name is changing completely. Its appending with project name, version number and build number. I want to keep the filename as it is. Any one know how to do this?
mvn deploy:deploy-file
-Dfile=${bamboo.artifacts.path.artifactFile}
-Dpackaging=cba
-url=https://nexus.internal.organisation.com/content/repositories/snapshots/
-DrepositoryId=snapshots
-DgroupId=com.organisation.art
-DartifactId=myproject
-Dversion=0.0.1-SNAPSHOT

A maven managed repository, such as that provided by Nexus et al, is set up in a way that is intended for deployed products to be returned to a maven build process that has them declared as dependencies.
It is not intended to be a generic file server.
If you have Nexus 3.0 or newer then you have access to so called "raw" repositories that you can set up any way you like.
However you would not use mvn deploy:deploy-file to add files to it. Instead you would follow the instructions in Uploading Files to Hosted Raw Repositories.

Related

Customize build and release role in maven

I have a Non-Java Maven project. By default the deploy goal generates a JAR file, however I would like to generate a zip file instead that should be published to nexus at a later phase.
If I create the zip file manually and place it in the target folder, Maven is not publishing it to nexus, it only publishes the JAR file automatically created.
So my question is: Is there any way to upload to nexus all the content of the target folder? If not, how do I tell Maven not to create a jar file and create a custom zip instead?
Maven has the deploy:deploy-file goal which can be configured in your pom.xml It can be used to upload arbitrary files, including zips.
You can avoid the creation of a jar if you change <packaging> to pom.

Change the artifact name while uploading to Maven Repository through command line

I am new to Maven and looking out for ways to upload many 'XML'(not jars) files to a Maven Repository.
I came across the 'mvn deploy' command which allows me to successfully upload the files to a Maven Nexus Repository.
I am using below command to upload single file successfully. So my XML gets uploaded with name com/xxx/test/test/0.1/test-0.1.xml.
call mvn deploy:deploy-file -DgroupId=com.xxx.test -DartifactId=test -Dversion=0.1 -DgeneratePom=false -DrepositoryId=kepler-releases -Durl=http://example.com:8081/repository/xxx-release -Dfile=xxx/abc.xml
Is there a way that I can upload multiple xml files under this same group 'com.xxx.test' with their existing file names (like abc.xml in this case)?
I saw there is some option -finalName but couldnt find many examples around its use. Any help with this would be appreciated.
Thanks.

How to deploy artefacts to Artifactory using Maven without a POM

I need to send a jar file to artifactory maven repo. I don't want to use pom.xml. I have configured settings.xml with details of artifactory. What would be the full commandline command to send jar to artifactory. I need maven-matadata.xml to be generated so that with every upload I can fetch tag in .xml file.
And also what would be default location of settings.xml? I see there are two locations. One is withing "apache-maven" folder and other one is inside .m2 folder under user's home directory.
Thank you
After using double quotes in mvn command (as I am executing it in powershell), it is working fine.

Backup Maven dependencies to repository

I am frequently using maven artifacts as dependencies from external repositories which go (permanently) offline surprisingly often. I'd like to save all dependencies a given project has and save them in a local repository - just like using maven deploy -DaltDeploymentRepository=... for a single project. This repository should then be usable like any other maven repo when put on an HTTP server.
I tried using mvn dependency:copy-dependencies -Dmdep.useRepositoryLayout=true, but it does not create files like maven-metadata.xml or copy .pom files.
I do not want to use any repository managers like Artifactory, I just have a static file server.
Thanks in advance.

maven - how to deploy non-jar files

In my project I have many modules.
One of the modules requires a jar file to be deployed to the repository which it does fine.
The others involve every other kind of file: zip, kar etc.
I can see the zip get uploaded if I look for it via the terminal but if I browse Archiva it is not there.
The kar file, for example, does not need to be built but it's being worked on and is currently manually uploaded to the repository (Archiva). This is not desirable.
Each module has a POM and each POM uploads empty jar files to Archiva when it is built (with Jenkins). How can I avoid that? And can I copy files to Archiva without them having to be built into a jar file?
You can also give a try to "maven-deploy-plugin"
Invoke a maven target in jenkins with this plugin and provide the suitable parameters.
You would also need the repository to be added in you settings.xml if your repository requires login credentials and then use the ID, you mentioned in settings.xml, in the maven target.
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file
-Durl=<artifact-repo URL>
-Dfile=<name of the file>
-DgroupId=<Group Id>
-DartifactId=<Artifact Id>
-Dversion=<VERSION>
-Dpackaging=<packaging Type>
-DrepositoryId=<ID as mentioned in settings.xml>
Hope this may be of some help.

Resources