Publishing Java Artifact to Nexus using Maven
Step 1: Configure Maven Settings
Open your Maven settings.xml
file, typically located in the conf
directory of your Maven installation or in the .m2
directory in your home folder. Add server details for Nexus in the <servers>
section:
<server> <id>nexus-releases</id> <username>your-username</username> <password>your-password</password> </server> <server> <id>nexus-snapshots</id> <username>your-username</username> <password>your-password</password> </server>
Step 2: Configure POM File
Update your project’s pom.xml
file to include the distribution management section with details of your Nexus repository. Add the following within the <project>
element:
<distributionManagement> <repository> <id>nexus-releases</id> <url>http://your-nexus-url/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <url>http://your-nexus-url/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement>
Step 3: Build and Deploy
Run the following Maven command to build and deploy your artifact to Nexus:
mvn clean deploy
Step 4: Check Nexus Repository
Open your Nexus Repository Manager and navigate to the appropriate repository (releases
or snapshots
) to verify that your artifact has been deployed successfully.
Comments are closed, but trackbacks and pingbacks are open.