1

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
Community
  • 1
  • 1
ksl
  • 4,519
  • 11
  • 65
  • 106
  • First i have doubts that using `scp` as protocol is a good idea nor usually used by Nexus. (http/https) is used. Furthermore you need to change the distributionManagement somewhere in pom.xml.... – khmarbaise Jun 23 '16 at 14:55
  • I don't know where or how `scp` comes into the deployment. It's nothing I have specified, knowingly. – ksl Jun 23 '16 at 14:58
  • @ksl the id in your settings snippet is `thirdparty` while from command line you passed `nexus`, that's a mismatch – A_Di-Matteo Jun 23 '16 at 20:47
  • @ksl from your second update, you are using the option correctly, but the url you are passing is not. You should pass a valid repository URL like `http://localhost:8081/nexus/content/repositories/releases` where `releases` is a configured repository on your Nexus. So it is not an issue with the `deploy` plugin in this case. – A_Di-Matteo Jun 29 '16 at 08:26

1 Answers1

1

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.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
  • So I should just add the dcm4che repo to my nexus config then? And when I build my application which depends on dcm4che maven will pull in what it needs from it and build it then? – ksl Jun 23 '16 at 15:17
  • @ksl yes, that's the recommended approach, no need to upload each and every external dependency you need. Nexus will pull them for you and store in its cache. – A_Di-Matteo Jun 23 '16 at 15:37