web analytics

Michelle & Automated Testing 3: Using Maven AWS S3 Repository Instead of Nexus Server

This article is a quick tutorial to set up a private maven s3 repository using Amazon S3 instead of Nexus server.

In Java programming environments, Nexus repository manager is very popular. But these years, a lot of Java developer starts using AWS S3 to do repository and artifacts manager as well. The solution is to help you manage your project’s internal and external repositories.

There are four major methods to get artifact:

  1. Maven center repository (remote)
  2. Your own public Maven repository(remote)
  3. Your own private Maven repository(remote)
  4. Single jar (local)

Following are the steps to set up the dependency with local single jar:

Step 1: Use Maven install to generate the .jar file
Step 2: Copy the jar file into your own path such as src/test/resources/
Step 3: In the pom.xml

<dependency>
<groupId>com.yours</groupId>
<artifactId>test-library</artifactId>
<version>${testlib-version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/test/resources/test-library-${testlib-version}.jar</systemPath>
</dependency>

Following are the steps to set up a Private Maven S3 repository:

Step 1: Set up your s3 bucket in AWS
Step 2: in ~/.m2, create or modify the file settings.xml

<settings>
<servers>
<server>
<id>repo.yours.com</id>
<username>$username</username>
<password>$password</password>
</server>
</servers>
</settings>

Step 3: In your pom.xml, add these code:

<build>
<…….>
<extensions>
<extension>
<groupId>org.kuali.maven.wagons</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.2.1</version>
</extension>
</extensions>
</build>
<distributionManagement>
<snapshotRepository>
<id>repo.yours.com</id>
<url>s3://yours-maven-repo/SNAPSHOT</url>
</snapshotRepository>
<repository>
<id>repo.yours.com</id>
<url>s3://yours-maven-repo/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>repo.yours.com</id>
<url>s3://yours-maven-repo/release</url>
</repository>
</repositories>

Step 4: mvn clean deploy – This step deploys the artifact to your S3
Step 5: in the pom.xml which will get this artifact, add the following code:

<repositories>
<repository>
<id>repo.yours.com</id>
<url>s3://yours-maven-repo/</url>
</repository>
</repositories>

and

<dependency>
<groupId>com.your</groupId>
<artifactId>test-library</artifactId>
<version>${testlib-version}</version>
</dependency>

Nexus server vs. S3 + Maven, which one is a better solution? It really depends on your team or company’s need.

You may also like

(Views: 3k)

Michelle Xie

Michelle Xie is a Quality Assurance Analyst at PrintFleet in Kingston, Canada. Michelle is a passionate software engineer and a software QA expert. Most of her efforts focus on automation test best practices and common tech issues that can be avoided in automation tests, and she hopes to continue sharing her technical expertise through ECM TechNews.

Leave a Reply

Your email address will not be published. Required fields are marked *