maven deploy-file to private artifactory - maven

I've set up an artifactory and I am able to to deploy my artifacts to it with mvn deploy.
However, I am unable to to deploy-file, which I am easily able to install:
mvn install:install-file -Dfile=my.jar -DgroupId=org.group -DartifactId=art -Dversion=3.0-SNAPSHOT -Dpackaging=jar
When I try:
mvn deploy:deploy-file -Durl=http://myartifactory/artifactory/repositoryId -DrepositoryId=repositoryId -Dfile=my.jar -DgroupId=org.group -DartifactId=art -Dversion=3.0-SNAPSHOT -Dpackaging=jar
I always get:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli) on project standalone-pom: Failed to retrieve remote metadata org.directwebremoting:dwr:3.0.0-rc3-SNAPSHOT/maven-metadata.xml: Could not transfer metadata org.directwebremoting:dwr:3.0.0-rc3-SNAPSHOT/maven-metadata.xml from/to repository (http://triphop:8081/artifactory/repository): Access denied to: http://triphop:8081/artifactory/repository/org/directwebremoting/dwr/3.0.0-rc3-SNAPSHOT/maven-metadata.xml -> [Help 1]
In the log of the artifactory I am getting:
20130809142431|0|REQUEST|non_authenticated_user|GET|/repository/org/group/art/3.0-SNAPSHOT/maven-metadata.xml|HTTP/1.1|401|0
Why the maven is trying to fetch the meta data? Why it does not upload them?

Maven 3 works with non unique snapshots only. Which means, it needs to know how to name your snapshot. The naming depends on what's already in repository. That's the reason it downloads the metadata.

Related

Where to manually download the JARS from when Maven cannot find a dependency

I want to create a Maven webapp sample project on a dev machine without internet, but with access a Nexus repo via the local network. The Nexus repo is years old, so it has most dependencies, but not all.
I have set up maven that it uses the local Nexus and then I typed:
$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.4
Maven goes off and downloads what it can from the local Nexus, but then it fails with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate failed: Plugin org.apache.maven.plugins:maven-archetype-plugin:2.4 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.codehaus.plexus:plexus-component-api:jar:1.0-alpha-16, org.codehaus.plexus:plexus-classworlds:jar:1.2-alpha-7: Failure to find org.codehaus.plexus:plexus-component-api:jar:1.0-alpha-16
Due to the fact that the machine is not connected to the internet and that I have no control over the Nexus repo (so cannot add jars to it), would need to download the depend JARs for org.codehaus.plexus:plexus-component-api and org.codehaus.plexus:plexus-classworlds manually (on another internet-connected computer).
Where on the Internet do I find them? -- I tried a search on https://jar-download.com/online-maven-download-tool.php. E.g. for org.codehaus.plexus:plexus-component-api I search with the following the XML snippet:
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
<version>1.0-alpha-16</version>
</dependency>
but this didn't yield any result.
You can use copy goal of dependency-plugin for download and copy artifacts:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.3.0:copy \
-Dartifact=org.codehaus.plexus:plexus-component-api:1.0-alpha-16:jar \
-DoutputDirectory=.
You can also download manually from Maven Central repository, eg:
https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/

On adding a jar using mvn install: install-file: On project standalone-pom: The artifact information is incomplete or not valid

I want to push the bahir jar to my local m2 repository.
I'm using maven-3.5.0 downloaded tar.gz and jdk8, both are set as environment variables and are working fine.
I built apache bahir for spark from the available download from git using maven, which was BUILD SUCCESS and it created a target folder which has the jar called bahir-parent_2.11-2.3.0-SNAPSHOT-tests.jar
now when I execute:
$mvn install:install-file -Dfile=/home/awisha/trial/bahir-master/target/bahir-parent_2.11-2.3.0-SNAPSHOT-tests.jar -DgroupId=org.apache.bahir -DartifactId=spark-streaming-mqtt_2.11 -Dversion=2.2.0
Its supposed to push the jar to my local .m2/repository. But instead it gives me the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: The artifact information is incomplete or not valid:
[ERROR] [0] 'packaging' is missing.
But when I used "apt install maven" : maven-3.3.9, I got BUILD SUCCESS
I'm not able to figure out why is it giving me error when using maven-3.5.0.
You need to simply add "-Dpackaging=jar" to your mvn install:install-file cmd:
$mvn install:install-file -Dpackage=jar
-Dfile=/home/awisha/trial/bahir-master/target/bahir-parent_2.11-2.3.0-SNAPSHOT-tests.jar
-DgroupId=org.apache.bahir -DartifactId=spark-streaming-mqtt_2.11 -Dversion=2.2.0

How to deploy a 3rd party set of libs to Nexus

I want to deploy a 3rd party set of libraries to nexus after building them from the source using maven.
I thought I'd be able to simply use mvn deploy but I get the following message:
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # dcm4che-parent ---
Uploading: scp://www.dcm4che.org:443/home/maven2/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom
The authenticity of host 'www.dcm4che.org' can't be established.
RSA key fingerprint is 41:7f:10:be:8d:15:30:f1:91:59:95:c7:5d:63:f7:31.
Are you sure you want to continue connecting? (yes/no): yes
Password: :
This looks to me like it's trying to deploy to the www.dcm4che.org and not my nexus repo.
Can I not use mvn deploy in this way?
I can deploy my own libs to nexus this way without any problems.
What am I doing wrong?
UPDATE
After following the advice in this answer I executed the following command:
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
and I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to nexus (http://192.168.50.200:8081/nexus/content/repositories/thirdparty): Failed to transfer file: http://192.168.50.200:8081/nexus/content/repositories/thirdparty/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
I have added an entry in my settings.xml as follows:
<servers>
<server>
<id>thirdparty</id>
<username>deployment</username>
<password>password</password>
<configuration></configuration>
</server>
</servers>
2nd UPDATE
I have tried the following command line variations but still can't get it to work. The maven documentation isn't any help.
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in thirdparty (http://192.168.50.200:8081) -> [Help 1]
and
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to thirdparty (http://192.168.50.200:8081/nexus/): Failed to transfer file: http://192.168.50.200:8081/nexus/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 405, ReasonPhrase: HTTP method PUT is not supported by this URL. -> [Help 1]
and
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in nexus (http://192.168.50.200:8081/nexus/content/repositories/) -> [Help 1]
Final UPDATE
For anyone else who might stumble across this, the following command worked. Thanks to A_Di-Matteo for his help.
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
You are probably refering to the dcm4che-parent-3.3.7.pom artifact, from which:
<distributionManagement>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>scp://www.dcm4che.org:443/home/maven2</url>
</repository>
</distributionManagement>
As you can see, its distributionManagement is refering to the host mentioned in the build error, which is used as the default one.
If you want to deploy to your internal Nexus, you should then use the altDeploymentRepository option:
Specifies an alternative repository to which the project artifacts should be deployed (other than those specified in <distributionManagement>).
Format: id::layout::url.
Its user property is altDeploymentRepository.
Hence, you can invoke Maven as following:
mvn clean deploy -DaltDeploymentRepository=yourId::layout::URL
Which should match a repository specified in your Maven settings.xml.
As a general rule, you should not upload to Nexus public artifacts in this way: Nexus can retrieve them for you and be used as a further centralized cache/governance point for other remote repositories.
If you are changing public artifacts and then publishing them in your internal Nexus, then it is really adviced to change their Maven coordinates, at least adding a classifier specifying something related to your patch/company-name/useful-detail.

maven error: The desired archetype does not exist (org.phpmaven:php5-web-archetype:2.0-SNAPSHOT)

I am trying to create php project using maven by tying below command:
sudo mvn archetype:generate -DarchetypeGroupId=org.phpmaven
-DarchetypeArtifactId=php5-web-archetype -DarchetypeVersion=2.0-SNAPSHOT
-DgroupId=org.sample -DartifactId=my-app -Dversion=0.0.1-SNAPSHOT
but it gives me error:
Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli)
on project standalone-pom: The desired archetype does not exist (org.phpmaven:php5-web-archetype:2.0-SNAPSHOT) -> [Help 1]
Apparently you're trying to follow these instructions. If you do, you should also do the preparation steps that have been listed.
Doing that you're relying on a snapshot archetype, and those do not exist in default repositories, so you have to configure php-maven snapshot repository.
After doing that,
Confirm your settings.xml location (in the comments you indicated you had that in the wrong folder)
try with
mvn archetype:generate -DarchetypeGroupId=org.phpmaven.sites
-DarchetypeArtifactId=php5-web-archetype -DarchetypeVersion=2.0.0-beta-1
-DgroupId=org.sample -DartifactId=my-app -Dversion=0.0.1-SNAPSHOT
Since you can see from the repo that that archetype version should be in place. Note the different archetypeversion and different archetypegroupid!

Maven deploy cant create directories

Whenever I try and do a maven deploy it can't seem to create directories and I need to do this manually.
Any idea why this might be?
mvn deploy:deploy-file -DgroupId=quickfixj -DartifactId=quickfixj-all
-Dversion=1.5.2 -Dpackaging=jar -Dfile=/dev/quickfixj/quickfixj-all-1.5.2.jar -DrepositoryId=maven-repo -Durl=https://subversion.assembla.com/svn/MYREPO/maven -X
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not find artifact quickfixj:quickfixj-all:jar:1.5.2 in maven-repo (https://subversion.assembla.com/svn/MYREPO/maven) -> [Help 1]
However if I manually create the directories quickfixj>quickfixj-all>1.5.2 it works fine.

Resources