Publishing Local JARs to a Private Nexus Repository
To push a local Java archive to an interanl Nexus server, the Maven deploy plugin is required. Begin by defining the repository details within the project's pom.xml under the distributionManagement node:
xml <distributionManagement> enterprise-releases Corporate Release Storage https://nexus.internal.net/repository/maven-releases/ </distributionManagement>
The id element must align with the server authentication block configured in the Maven settings.xml file. Add the corresponding credentials inside the <servers> secsion:
xml enterprise-releases deploy-user s3cr3tP@ss
With the authentication mappping established, execute the deploy:deploy-file goal from the terminal. This command bypasses the standard build lifecycle and directly transfers the specified artifact:
bash
mvn deploy:deploy-file
-DgroupId=com.corp.library
-DartifactId=custom-utils
-Dversion=1.0.0
-Dpackaging=jar
-Dfile=./target/custom-utils-1.0.0.jar
-Durl=https://nexus.internal.net/repository/maven-releases/
-DrepositoryId=enterprise-releases
Replace the coordinate parameters (groupId, artifactId, version) and the file path with the actual values for the target archive. The url and repositoryId flags dictate the dsetination and reference the ID used in settings.xml for credential resolution.