mvn deploy:deploy-file RPM and tgz - maven

I am able to deploy an RPM by itself using the following mvn command line options:
mvn -e deploy:deploy-file \
-Durl=http://repo.myorg.com/content/repo/snapshots \
-DrepositoryId=myorgsnapshots \
-DgroupId=com.myorg.mygroup \
-DartifactId=testApp \
-Dversion=1.0.15-SNAPSHOT \
-Dpackaging=rpm \
-Dfile="testApp-1.0.15-1.el6.x86_64.rpm"
I now want to also include a .tgz file along with the RPM. What are the correct options to accomplish this task? I've tried using sources, files, types, and classifiers options, as described here in various combinations with no effect, not even an error.

The simple solution would be to have another execution of the deploy:deploy-file goal.
There won't be any clash since both artifacts will have a different packaging: the first one is deployed with the rpm packaging and the second one is deployed with the tgz packaging. From packaging:
Defaults to the file extension if it is not specified via command line or POM.
As such, you don't need to provide that argument, it will default to the extension.
The only cave-at is that the plugin will try to generate another POM for the second execution. From generatePom:
Will generate a default POM if none is supplied with the pomFile argument. Default: true
You can however disable that by setting generatePom to false.
mvn -e deploy:deploy-file \
-Durl=http://repo.myorg.com/content/repo/snapshots \
-DrepositoryId=myorgsnapshots \
-DgroupId=com.myorg.mygroup \
-DartifactId=testApp \
-Dversion=1.0.15-SNAPSHOT \
-Dfile="testApp-1.0.15-1.el6.x86_64.rpm"
mvn -e deploy:deploy-file \
-Durl=http://repo.myorg.com/content/repo/snapshots \
-DrepositoryId=myorgsnapshots \
-DgroupId=com.myorg.mygroup \
-DartifactId=testApp \
-Dversion=1.0.15-SNAPSHOT \
-DgeneratePom=false \
-Dfile="testApp-1.0.15-1.el6.x86_64.tgz"

Related

Push Jar file instead of Zip using maven nexus

I am trying to push zip file using mvn deploy command. The command I am using is:
mvn clean -s settings.xml \
package deploy:deploy-file \
-Dfile=${ARTIFACT_ID}-${VERSION}.zip \
-Durl=${NEXUSURL}/repository/maven-${PKGREPO} \
-DrepositoryId=nexus-${PKGREPO} -DpomFile=pom.xml \
-DskipTests -Dpitest.execution.skip=true -Ddependency-check.skip=true
but I can find .jar file instead of zip?
Able to resolve after adding -Dpackage=zip.

Install project artifacts to specific directory not .m2

I to install my project artifacts to specific directory rather than the default .m2 directory. How can I do this (where should I edit in the pom.xml file)
You can use the Maven Deploy Plugin's altDeploymentRepository parameter. It can be given from the command line, so it should not be necessary to edit the POM file. Here is an example of using it.
The relevant section is:
mvn clean deploy \
--batch-mode \
--errors \
-Psonatype-oss-release \
-Dgpg.keyname="$GPG_KEYNAME" \
-Dgpg.passphrase="" \
-DaltDeploymentRepository="staging::default::file:staging"

How to install library to external maven repository

in your company we are using archiva as our maven repository. How I can install there some library which is not mavenized remotely ? In my local repository I can do something like this:
mvn install:install-file -D groupId=cz.i -D artifactId=sql-processor \
-D version=1.0 -D packaging=jar \
-D file=~/programy/cro/lib/sql-processor.jar
When I want to add some maven project to our archiva, I can run this command: mvn:deploy. But I have no idea how to install just library there
You're closer than you think - just replace install:install-file with deploy:deploy-file and add a bit of sugar, as can be read here:
mvn deploy:deploy-file -DgroupId=cz.i \
-DartifactId=sql-processor \
-Dversion=1.0 \
-Dpackaging=jar \
-Dfile=~/programy/cro/lib/sql-processor.jar \
-DrepositoryId=<id-to-archiva-map-on-server-section-of-settings.xml> \
-Durl=<your-archiva-URL>
As you - correctly - state, this should only be used for "non-mavenized" external artifacts, otherwise mvn deploy is the way to go.
Cheers,

install maven archetype project jar with *.pom file to local repo

i`m kinda new to maven and want to know how to install an archetype jar to my local repo
i got a directory com.foo with the following files:
maven_metadata_local.xml
[1.00.00-SNAPSHOT]
which containes these files
_maven.repository
foo-archetype-1.00.00-SNAPSHOT.jar
foo-archetype-1.00.00-SNAPSHOT.pom
maven_metadata_local.xml
from what i read i understand that there is a way to build a template project using this archetype but first i need to install it to my local repo
how can i do this?
thanks
i managed to do that:
what i did is opened the maven_metadata_local.xml to get the groupId, artifactId, and version
run this command from that directory
mvn install:install-file
-Dfile=foo-archetype-1.00.00-SNAPSHOT.jar \
-DgroupId=com.foo \
-DartifactId=foo-archetype \
-Dversion=1.00.00-SNAPSHOT \
-Dpackaging=jar \
-DgeneratePom=true
once compleated (BUILD SUCCESS) i got the build in my local repository
go to a folder from which i want to create a project
run this command
mvn archetype:generate \
-DarchetypeGroupId=com.foo \
-DarchetypeArtifactId=foo-archetype \
-DarchetypeVersion=1.00.00-SNAPSHOT \
-DgroupId=com.mycom \
-DartifactId=myApp \
-Dversion=myversion-SNAPSHOT
in eclipse i imported an existing maven project, right click on the project->maven->update
and i got the full build ready to work
Adding an archetype to your local repository is no different than adding any other dependency. You can simply run a mvn install command on it.

How to add a jar, source and Javadoc to the local Maven repository?

I'm wanting to add the latest version of JGoodies Forms (1.5.0) as a dependency, but I can't find anything newer than 1.0.5 in the main repository, so if I understand correctly, the next best thing I can do is add it to my local repository.
When I download it from the website, I get a ZIP file that contains the javadoc files, the source code and the jar (with just class files in it).
What is the procedure for adding this to my local Maven repository in such a way that Eclipse will be able to see the source and Javadoc? (I've only just started using Maven)
Update: Even though this is the accepted answer, please check the answer of Emmanuel Bourg below - his answer is probably what you would like to do, especially if you're having a snapshot version.
You can use the maven deploy plugin for that. It has a goal for deploying a single file to any repository.
For the jar itself:
mvn deploy:deploy-file \
-DgroupId=com.yourname.jgoodies \
-DartifactId=jgoodies-forms \
-Dversion=1.50 \
-Dfile=/path/to/jgoodies-1.50.jar \
-Dpackaging=jar \
-Durl=file://path/to/your/local/repository
For the sources:
mvn deploy:deploy-file \
-DgroupId=com.yourname.jgoodies \
-DartifactId=jgoodies-forms \
-Dversion=1.50 \
-Dfile=/path/to/jgoodies-sources.jar \
-Dpackaging=jar \
-Durl=file://path/to/your/local/repository \
-Dclassifier=sources
For the javadoc:
mvn deploy:deploy-file \
-DgroupId=com.yourname.jgoodies \
-DartifactId=jgoodies-forms \
-Dversion=1.50 \
-Dfile=/path/to/jgoodies-javadoc.jar \
-Dpackaging=jar \
-Durl=file://path/to/your/local/repository \
-Dclassifier=javadoc
Note that this will generate a standard POM, so you won't have the dependencies of JGoodies (if any) pulled automatically but have to specify them manually in your project.
Here is the syntax to deploy the binary, the sources and the javadoc with a single command:
mvn deploy:deploy-file \
-DgroupId=com.jgoodies \
-DartifactId=jgoodies-forms \
-Dversion=1.6.0 \
-Dfile=jgoodies-forms-1.6.0.jar \
-Dsources=jgoodies-forms-1.6.0-sources.jar \
-Djavadoc=jgoodies-forms-1.6.0-javadoc.jar \
-Durl=file://path/to/your/local/repository
Install the jar you have downloaded using this mini guide :
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
You should install jgoodies-form-1.5.0.jar by typing:
mvn install:install-file -Dfile=<path-to-file>/jgoodies-form-1.5.0.jar \
-DgroupId=jgoodies -DartifactId=forms -Dversion=1.5.0 -Dpackaging=jar
don't forget to do the same with jgoodies-commons.
For you to be able to access the source code and the contextual javadoc you can either
uncompress the jgoodies form zip and make eclipse points to the src folder
generates a jgoodies-form-1.5.0-src.jar by putting the src directory in it and install it in your local repo the same way you did for the jar

Resources