Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading Dependences From Private Amazon S3 Repository with Gradle

I am looking to add Groovy support to an existing java project so that I can seemlessly compile mixed Java and Groovy code using invokedynamic so that I can get Java-like execution speed without needing to waste excessive amounts of time with verbose Java syntax

After reading that the gmaven plugin no longer supports compilation -and that the groovy eclipse compiler plugin doesn't yet support invokedynamic, I asked myself, why would I want to continue using Maven if it compiles Groovy code that is needlessly slow?

Consequently, I decided I would try scrapping maven for Gradle so that I could obtain faster code while also porting some python deployment scripts to Gradle tasks so as to only need one codebase.

I have some libraries stored on a simple password protected s3 maven repository (in order to avoid needing enterprise overkill like artifactory). After doing some basic research, I have found that Gradle has no built in support for adding in custom dependency management as determined by this stack overlow question and this support forums post.

I did manage to find a s3 plugin for gradle -but it doesn't deal with management of dependencies.

If the whole point of Gradle is to be more flexible than Maven and if the core purpose of a dependency management/ build system is to effectively manage dependencies from a variety of sources-then lack of support for custom repositories appears to be a fairly significant significant design flaw which makes any issues I have encounted with Maven thus far pale in comparison.

However, it is quite possible that I am missing something, and I have already invested several hours learning Gradle -so I figured I would see if there is some reasonable way to emulate dependency management for these s3 dependencies until Gradle developers fix this critical issue. Otherwise I will have to conclude that I am better off just using Maven and tolerating slower Groovy code until the compiler plugin supports invokedynamic.

Basically I need a solution that does the following:

  1. Downloads dependencies and transitive dependencies to the gradle cache
  2. Doesn't require me to hardcode the path to the gradle cache -so that my build script is platform independent.
  3. Doesn't download the dependencies again if they are already in the cache.
  4. Works with a multi-module project.

However, I cannot find anything in the documentation that would even give me a clue as to where to begin:

like image 273
THX1138 Avatar asked May 03 '14 17:05

THX1138


People also ask

Can S3 buckets be private?

By default, all S3 buckets are private and can be accessed only by users who are explicitly granted access. Restrict access to your S3 buckets or objects by doing the following: Writing IAM user policies that specify the users that can access specific buckets and objects.

What is amazon S3 bucket?

A bucket is a container for objects stored in Amazon S3. You can store any number of objects in a bucket and can have up to 100 buckets in your account. To request an increase, visit the Service Quotas Console . Every object is contained in a bucket.


1 Answers

Gradle 2.4 has native support for S3 repositories. Both downloading dependencies and publishing artifacts.

To download with IAM credentials (paraphrased from the link above):

repositories {
    maven {
        url "s3://someS3Bucket/path/to/repo/root"
        credentials(AwsCredentials) {
            accessKey 'access key'
            secretKey 'secret key'
        }
    }
}

Then specify your dependencies as usual.

like image 87
ThorinII Avatar answered Sep 30 '22 09:09

ThorinII