Private Maven Repository in Amazon S3

 A few days ago I had an interesting task with Maven and AWS S3. We decided to use S3 bucket as a private Maven repository. Amazon S3 is a good place for keeping private Maven artifacts.

If you want to use S3 bucket as a private or public maven repo, first of all, you need to create an s3 bucket, create IAM user and configure AWS access by keys. It's a very simple task, let's do it.

Create an S3 Bucket

1. Create a new S3 bucket. Name it using your project domain and a prefix. For example,, repo is a prefix and is the domain.

There's no need to configure any permissions for this bucket. Just create it through the Amazon S3 console.

Create an IAM User

Create a new IAM user.Name it like project-maven if your project name is project 😀

Add a new "inline policy" to the user:

  "Statement": [
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": [

So is the name of the S3 bucket we created a few minutes ago.

Make sure you have an "access key" for this new user. It must look similar to this:

secret: wuaRZQCCErX32avyxf5aTtfbmlFGE4iMFBOht5w3

The key is 20 characters (all caps), and the secret is 40 characters.


Configure maven settings.xml

Add this configuration to your ~/.m2/settings.xml file: 



Now I need to deploy one *.jar file to our privet repo. How can I do that?

I will use mvn deploy file. For my example, lets take Java Wialon SDK 

1. Download wialon.jar Place it for example to a directory /opt/.

2. Unpack and try to deploy to S3 bucket.

Our command will look:

mvn deploy:deploy-file -Dfile=wialon-sdk-1.3.57.jar -DgroupId=com.wialon -DartifactId=sdk-core -Dversion=1.3.57 -Dpackaging=jar -Durl=s3://

I received several errors like:


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file: java.lang.NoSuchFieldError: USE_DEFAULTS


That's why I downloaded few libraries. Placed it to main Maven lib directory.


Also I removed apache-httpcomponents-httpcore.jar which was an old version in the maven/lib. It caused  a conflict with httpcore.jar

Run our command once more and Voila!

mvn deploy:deploy-file -Dfile=wialon-sdk-1.3.57.jar -DgroupId=com.wialon -DartifactId=sdk-core -Dversion=1.3.57 -Dpackaging=jar -Durl=s3://



Also, you can delete all the deployed files with:

aws s3 rm s3:// –recursive

Stay tuned!

  • balarang007

    Very nicely written and useful post

  • balarang007

    Also need to remove jackson-annotations-2.1.2.jar since there are two versions of this jar and we need the latest one