Using Ant + Maven to upload artifacts to Nexus OSS

Everyone uses Maven. But sometimes you don’t have the privilege of starting a new Maven project with fancy pom file – Maybe it’s because you’re exporting from Eclipse, maybe you have an existing project with different build tools etc…

For example I have a some Liferay plugins SDK projects that’s already using ANT. If you don’t know what is Liferay, you should check it out, it’s a nice open source, full-fledged JAVA content management system for enterprise websites.

So my developers are using ANT to build their plugin artifacts and I need to store these artifacts (mainly JARS and WARS) in Nexus OSS repository. So I came across the “deploy”  maven plugin with its “deploy-file” goal (deploy:deploy-file). It allows you to quickly upload any WAR/JAR file to a maven repository without having to build a complete POM file with millions of dependencies. You can include a pom.xml file if you like and override the properties from the command line.

Make sure you configure your Maven settings.xml file with the Nexus OSS repository credentials like this:

<?xml version="1.0"?>
<settings>
  <servers>
    <server>
      <id>liferay-releases</id>
      <username>admin</username>
      <password>*****</password>
    </server>
    <server>
      <id>liferay-snapshots</id>
      <username>admin</username>
      <password>*****</password>
    </server>
  </servers>
</settings>

When you execute maven from Jenkins, you need to pass some parameters: (‘properties’)

2016-08-29 16_46_32-qognify-theme Config [Jenkins]

 

 

Notice I’ve used parameter $JOB_NAME to pass the Jenkins job name as an artifact ID + $BUILD_NUMBER as maven version to Nexus OSS.

Finally you get this nice view in Nexus OSS UI after each build:

2016-08-28 15_58_56-Components - Nexus Repository Manager

 

 

Advertisements

Published by

Amir Barkal

"Music is the best" - FZ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s