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

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.

Related

Maven artifact of same project failed

I have a Maven project with following structure
/app
/- pom.xml
/- app-api
/- pom.xml
/- app-impl
/- pom.xml
There are some external dependencies, but when I tried to build the project Maven failed while trying to retrieve app-api from external source with error
[ERROR] Failed to execute goal on project app-impl: Could not resolve
dependencies for project com.examp:app-impl:jar:0.0.0.1: Could not
transfer artifact com.example:app-api:jar:0.0.0.1 from/to
nexus-snapshot (http://example.com/repository/snapshot): Failed to
transfer file:
http://example.com/repository/snapshot/com/example/app-api/0.0.0.1/app-api-0.0.0.1.jar.
Return code is: 400 , ReasonPhrase:Bad Request. -> [Help 1]
The snapshot repository policies forbid 4 digit version. But I cannot understand why Maven does not associate that dependency locally.
If the desired artifact is in your local repository (.m2/repository), Maven should find it there (without looking in remote repositories).
Otherwise, have a look at your settings.xml and see whether you misconfigured your repositories.

Create release without specifying repository

In my Maven project, I am trying to make a release, but for now I don't want to deploy it anywhere(I will do that later).
I would like the JAR file or whatever is generated because of the release to remain on my local machine, without being deployed anywhere.
I am running this:
mvn release:prepare
mvn release:perform
The problem is that on the second line I am getting this error:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-project: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
What is this about?
I don't have any distributionManagement tag in my project and if I would have one, I wouldn't know what to do with it.
You have 2 options:
set the value for the goals parameter of the maven-release-plugin to install
if you never want to deploy to a remote repository, set the skip parameter of the maven-deploy-plugin to true.
Add this to the code:
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

Can't deploy Maven jars to S3 from Intellij

I'm trying to deploy a Maven jar to S3 from within IntelliJ (meaning, using the Maven Projects panel). This fails constantly, saying:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MyProject: Failed to deploy artifacts: Could not transfer artifact Project:MyProject:jar:1.0.0 from/to s3-spark.release (s3://MyS3): Unable to load AWS credentials from any provider in the chain -> [Help 1]
But, when I try to do the same from within the terminal using mvn deploy, everything works great. Any ideas what am I missing? (Using Maven 3.3.9, IntelliJ Comumnity 2016.1)

maven deploy-file to private artifactory

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.

Maven build issues - can anyone help me in knowing why I see this error when I do run as maven install

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project resteasy: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.maven.shared:maven-common-artifact-filters:jar:1.3: Could not transfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 from/to central (http://repo.maven.apache.org/maven2): Remotely Closed [id: 0x3004ed34, /192.168.200.22:59080 :> repo.maven.apache.org/93.184.215.223:80] -> [Help 1]
You can try a couple of options:
Use the debugging options. This will produce a lot of output, and probably you'll be able to understand whats really going on.
mvn -X test
In case you're running some kind of proxy on the repository (Nexus, Artifactory, and so on), you can try to disable it in your settings.xml and try to bring the artifact directly from the central repository.
Its theoretically possible that something went wrong in your local repository (by default ~/.m2) In this case try to remove all the packages from ''org.apache.maven.shared:maven-common-artifact-filters:jar:1.3'' and rerun the build.
How this helps

Resources