We had a simple requirement to host our internal deployed artifacts in the Amazon Cloud. We have migrated most of our builds to Gradle. Since version 2.4, Gradle added support for repositories hosted in Amazon AWS S3.
Both Ivy and Maven repositories in S3 are supported by Gradle. But since Ivy is trying to mimic maven and we already had a maven repo, I picked maven.
I’ve created an S3 bucket and inside a simple structure:
The following code in
build.gradle enables download of the dependencies:
I played with the uploadArchives gradle task, but it was creating the Ivy structure. I have decided to go with the newer maven-publish plugin.
The following shows how to switch between two repositories and how to reference previously defined repositories. The switching works very well
with Gradle Release Plugin that we are using now.
To include source jars, test jars or other archives, e.g. from distribution plugin, add this to the publication.
Group Id, Artifact Id can be set here as well.
I have successfully migrated Apache Archiva to S3 simply by copying the whole directory structure from Archiva’s data folder to S3. Any maven repository should be possible to migrate the same way.
The main disadvantage of this solution is the lack of administration and inability to prune snapshots. I am planning to create a utility that will take care of that.
Fortunately the S3 cost is very small so this will do for now.