Maven Jar File Deployment in Sonatype Nexus

04-08-2016

1. Create settings xml file in the ${user.home}/.m2 directory if not exists

2. Add following server config as follows:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
          http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>codesenior</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
</settings>

You can use any id name as server id attribute.

3. Run following command in cmd:

mvn deploy:deploy-file -Durl=http://localhost:9090/repository/maven-releases \ 
-DrepositoryId=codesenior-local \ 
-DgroupId=com.codesenior.telif \ 
-DartifactId=generic-dao-service \ 
-Dversion=1.0.0-SNAPSHOT \ 
-Dpackaging=jar \ 
-Dfile=generic-dao-service-1.0.0-SNAPSHOT.jar \ 
-DgeneratePom=true

Note: If you got an error while running above script please select new version instead of 1.0.0-SNAPSHOT, such as 1.0.1-SNAPSHOT.

Note: If you add -SNAPSHOT suffix to -Dversion, you have to choose Version policy as Snapshot as follows:

    

Note: When uploading snapshot, maven deploy plugin automatically adds suffix timestamp to the version number. If you want to disable it, you can set uniqueVersion parameter to false. This parameter is removed in Maven 3, so only works in Maven 2. Whether timestamp is added or removed, there is no difference to download. You can always add dependency without timestamp suffix. For more information please click

© 2019 All rights reserved. Codesenior.COM