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.
Related
Our project is using Nexus Repository Manager to store all the jars.
Along with the jar I see that under a group there are other files like pom.xml, .md5, .sha1 file. I am in need of these files at our server startup.
Is there a way that I can download all the files under a particular group programatically using Java/Curl command/mvn dependency command at runtime?
Maven also uses local repository for caching. The default location is Default: ${user.home}/.m2/repository. You can check this setting in file settings.xml under [maven_dir]/conf/.
To update dependencies, use -U option. i.e. mvn clean install -U
Do not forget setting nexus repo inside pom.xml file http://maven.apache.org/pom.html#Repository
I could do it with the simple approach.
Club all the xmls into a JAR/ZIP file and upload that zip file under my groupId to the Maven Repository.
Then programatically use CURL/WGET to download the zip and unzip the contents of that zip file (using any available utility) at runtime.
Put all XMLs under a zip file.
Use mvn deploy to load this zip file to my Maven Nexus Repo.
Then Programatically during runtime, download the zip file using simple weburl call to that ZIP file.
Use ZIP4J or any other library to unzip the contents to my required output folder
Pick files from this server when needed during the flow.
Hope its helpful to someone somewhere sometime. :)
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.
I've got a compiled Jar file and a Pom file. Now I want to deploy both of these to Artifactory or Nexus (I've got both).
I want to do it with either mvn:deploy or curl (REST API)
could someone tell me how I do this?
My answers are about Artifactory, of course.
For using mvn deploy you need to configure your pom file to include distributionManagement tag. You can copy-paste the whole tag from Artifactory UI (click on the repository you want to deploy to, on the right side you'll see the distributionMnagement tag for copying).
With REST API you can just issue two PUT requests (one for pom, other for jar). Start with the pom.
If you got a jar file already as well as a pom, you would want to use the deploy-file goal of the Maven deploy plugin. mvn deploy will build the project but that wont work if you already got the jar and pom file and no source code.
Of course you can also upload the files via the web user interface of Nexus or use the REST api. You can find some REST api examples with curl on github.
I am running nexus 2.9.1.02 to host artifacts for maven builds. I would like to load artifacts via the file system. I do not want to use the web UI. Instead, just putting the folders with required pom and jar files in the sonatype-work/nexus/storage folder.
After loading the files into the file system, the artifacts show up in the "browse storage" tab. However, they do not show up in the "browse index" tab and Maven can not download them.
Is it possible to load artifacts via the file system only? How do you sync the file system to the repo database/indexing?
Thanks,
Nathan
There's a way to do this that should be repository agnostic. Use the mvn deploy:deploy-file plugin. Here's an example:
mvn deploy:deploy-file
-DrepositoryId=repoId
-Durl=repoUrl
-Dfile=pathToFile
-DgroupId=groupId
-DartifactId=artifactId
-Dversion=versionNumber
-DgeneratePom=true
Yes, you can place artifacts directly into local storage. See here for tasks you will need to run after doing this:
https://support.sonatype.com/entries/38605563-Can-I-directly-update-artifacts-in-Nexus-local-storage-on-disk-
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.