@@ -6,7 +6,6 @@ import org.sonatype.aether.artifact.Artifact
66import org.sonatype.aether.repository.Authentication
77import org.sonatype.aether.repository.RemoteRepository
88import org.sonatype.aether.util.artifact.DefaultArtifact
9- import org.sonatype.aether.util.artifact.JavaScopes.COMPILE
109import org.sonatype.aether.util.artifact.JavaScopes.RUNTIME
1110import java.io.File
1211
@@ -68,12 +67,26 @@ fun resolveDependencies(depIds: List<String>, customRepos: List<MavenRepo> = emp
6867 }
6968}
7069
70+ fun decodeEnv (value : String ): String {
71+ return if (value.startsWith(" {{" ) && value.endsWith(" }}" )) {
72+ val envKey = value.substring(2 , value.length - 2 )
73+ val envValue = System .getenv()[envKey]
74+ if (null == envValue) {
75+ errorMsg(" Could not resolve environment variable {{$envKey }} in maven repository credentials" )
76+ quit(1 )
77+ }
78+ envValue
79+ } else {
80+ value
81+ }
82+ }
83+
7184fun resolveDependenciesViaAether (depIds : List <String >, customRepos : List <MavenRepo >, loggingEnabled : Boolean ): List <Artifact > {
7285 val jcenter = RemoteRepository (" jcenter" , " default" , " http://jcenter.bintray.com/" )
7386 val customRemoteRepos = customRepos.map { mavenRepo ->
7487 RemoteRepository (mavenRepo.id, " default" , mavenRepo.url).apply {
7588 if (! mavenRepo.user.isNullOrEmpty() && ! mavenRepo.password.isNullOrEmpty()) {
76- authentication = Authentication (mavenRepo.user, mavenRepo.password)
89+ authentication = Authentication (decodeEnv( mavenRepo.user), decodeEnv( mavenRepo.password) )
7790 }
7891 }
7992 }
0 commit comments