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:
- Maven center repository (remote)
- Your own public Maven repository(remote)
- Your own private Maven repository(remote)
- 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.
- Michelle & Automated Testing 5:Internal API and External API Automation Testing, Lessons Learned - August 15, 2017
- Michelle & Automated Testing 4: How to Integrate Jenkins, Sonar and Github for your Pull Request? - July 27, 2017
- Michelle & Automated Testing 3: Using Maven AWS S3 Repository Instead of Nexus Server - June 28, 2017