Amazon S3 seems to be a good candidate for keeping private Maven artifacts. You can have , both, private and public repositories, saving you from the trouble of maintaining any other maven repository server like nexus, artifactory etc
Private artifacts are those you don’t want visible to anyone except members of your team. Thus, you want to deploy your .jar
files there and make sure they are visible only by your team. I assume you keep public artifacts in Maven Central because you want them to be available to everybody.
I am a big fan of nexus but due to some other requirements, I needed to setup S3 as maven repository. Here are some steps that I have taken to accomplish the same.
Create an S3 Bucket
First, you create a new S3 bucket repo.rcherara.ca
for example, with repo
is a prefix and rcherara.ca
is the domain. This Bucket for a component micro-service-book with 2 folders in for release and snapshot.
If you prefer this to be a public repository, then make these two folders as publicly accessible. Or else move to the next step. but I don't recommend to you, because AWS charge for you when peoples download from this Bucket.
Note : You can shall create the S3 bucket with command $ aws s3 createbucket artifactbucket
Create an IAM User
I create a new IAM user like micro-service-book-maven
because my project name is micro-service-book
.
Your policy should be like:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::repo.rcherara.ca",
"arn:aws:s3:::repo.rcherara.ca/*"
]
}
]
}
Here, repo.rcherara.ca
is the name of the S3 bucket I created a minute ago.
Make sure you have an “access key” for this new user micro-service-book-maven
. It must look similar to this:
key: AKIAI9MMMMJD5D7X4DSVA
secret: a4tSQdsdwrkfnfjlVFfbFD5aRDEFw34iFyxdF54av
Extend settings.xml
Add this configuration to your ~/.m2/settings.xml
file:
<settings>
<servers>
<server>
<id>repo.rcherara.ca</id>
<username>AKIAI9MMMMJD5D7X4DSVA</username>
<password>a4tSQdsdwrkfnfjlVFfbFD5aRDEFw34iFyxdF54av</password>
</server>
[...]
</servers>
[...]
</settings>
Configure pom.xml
Add this configuration to pom.xml
:
<project>
<distributionManagement>
<snapshotRepository>
<id>repo.rcherara.ca</id>
<url>s3://repo.rcherara.ca/snapshot</url>
</snapshotRepository>
<repository>
<id>repo.rcherara.ca</id>
<url>s3://repo.rcherara.ca/release</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>repo.rcherara.ca</id>
<url>s3://repo.rcherara.ca/release</url>
</repository>
</repositories>
[...]
</project>
Then, configure S3 Wagon, also in pom.xml
:
<project>
<build>
<extensions>
<extension>
<groupId>org.kuali.maven.wagons</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.2.1</version>
</extension>
</extensions>
[...]
</build>
</project>
I can now deploy my artifacts just by running Maven from the command line:
$ mvn clean deploy