Permalink
Browse files

Patch that allows the S3 client to use DefaultCredentials with AWS

Use the following to build:
```
   gradle :resourcesS3:build -x :resourcesS3:integTest
```
  • Loading branch information...
boneill42 committed Oct 27, 2015
1 parent f19c3a8 commit d221c6e5078636fd56636858188e2d10ba49ed85
@@ -58,7 +58,11 @@ public S3Client(AwsCredentials awsCredentials, S3ConnectionProperties s3Connecti
}
private AmazonS3Client createAmazonS3Client(AWSCredentials credentials) {
AmazonS3Client amazonS3Client = new AmazonS3Client(credentials, createConnectionProperties());
if(credentials != null) {
amazonS3Client = new AmazonS3Client(credentials, createConnectionProperties());
} else {
amazonS3Client = new AmazonS3Client(createConnectionProperties());
}
S3ClientOptions clientOptions = new S3ClientOptions();
Optional<URI> endpoint = s3ConnectionProperties.getEndpoint();
if (endpoint.isPresent()) {
@@ -43,9 +43,6 @@
@Override
public ExternalResourceConnector createResourceConnector(ResourceConnectorSpecification connectionDetails) {
AwsCredentials awsCredentials = connectionDetails.getCredentials(AwsCredentials.class);
if(awsCredentials == null) {
throw new IllegalArgumentException("AwsCredentials must be set for S3 backed repository.");
}
return new S3ResourceConnector(new S3Client(awsCredentials, new S3ConnectionProperties()));
}
}
@@ -21,7 +21,7 @@ import org.gradle.internal.resource.connector.ResourceConnectorSpecification
import spock.lang.Specification
class S3ConnectorFactoryTest extends Specification {
/*
S3ConnectorFactory factory = new S3ConnectorFactory()
def "fails when no aws credentials provided"() {
setup:
@@ -35,4 +35,5 @@ class S3ConnectorFactoryTest extends Specification {
def e = thrown(IllegalArgumentException)
e.message == "AwsCredentials must be set for S3 backed repository."
}
*/
}

1 comment on commit d221c6e

@boneill42

This comment has been minimized.

Show comment
Hide comment
@boneill42

boneill42 Oct 27, 2015

Collaborator

To build replacement jar perform the following:

   $ git clone git@github.com:monetate/gradle.git
   $ git fetch
   $ git checkout 2.8.monetate
   $ gradle :resourcesS3:build -x :resourcesS3:integTest

That will produce the following jar file:

   $ ls subprojects/resources-s3/build/libs/gradle-resources-s3-2.8-20151027210818+0000.jar

To deploy this version to a Gradle install,

   $ rm -fr $GRADLE_HOME/lib/plugins/gradle-resources-s3*
   $ cp gradle-resources-s3-2.8-20151027210818+0000.jar $GRADLE_HOME/lib/plugins/
Collaborator

boneill42 commented on d221c6e Oct 27, 2015

To build replacement jar perform the following:

   $ git clone git@github.com:monetate/gradle.git
   $ git fetch
   $ git checkout 2.8.monetate
   $ gradle :resourcesS3:build -x :resourcesS3:integTest

That will produce the following jar file:

   $ ls subprojects/resources-s3/build/libs/gradle-resources-s3-2.8-20151027210818+0000.jar

To deploy this version to a Gradle install,

   $ rm -fr $GRADLE_HOME/lib/plugins/gradle-resources-s3*
   $ cp gradle-resources-s3-2.8-20151027210818+0000.jar $GRADLE_HOME/lib/plugins/
Please sign in to comment.