Friday 26 April 2019

How to add S3 based maven repo into gradle repositories


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
buildscript {
 repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
    jcenter()
    mavenCentral()
  }
  dependencies {
    classpath 'com.amazonaws:aws-java-sdk:1.11.214' 
    classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1'
  }
}



def awsProfile = "prfilename" //default/saml/east1/anything your configured in aws credentials file
def mavenRepo   = "s3://repo.your.com"

ext {
    samlCredentials = new com.amazonaws.auth.profile.ProfileCredentialsProvider(awsProfile).credentials
}




repositories {
    maven {
        //url "s3://myCompanyBucket/maven2"
        url "${mavenRepo}/releases"
        credentials(AwsCredentials) {
          //  accessKey "someKey"
          //  secretKey "someSecret"
            // optional
           // sessionToken "someSTSToken"
            accessKey samlCredentials.getAWSAccessKeyId()
         secretKey samlCredentials.getAWSSecretKey()
         if (System.env.BUILD_NUMBER==null) {
            if (samlCredentials.getSessionToken()!=null) {
              sessionToken samlCredentials.getSessionToken()
            }
         }
        }
    }
  
  mavenCentral()
  jcenter()
    
 }

No comments:

Post a Comment

Please comment here