xenoterracide
12/21/2017, 7:54 AMpublishing {
repositories {
maven {
url = uri(System.getenv("JRS_S3_URI") ?: "" )
gildor
12/21/2017, 8:04 AMgildor
12/21/2017, 8:05 AMgildor
12/21/2017, 8:06 AMxenoterracide
12/21/2017, 8:06 AMgildor
12/21/2017, 8:06 AMurl = System.getenv("JRS_S3_URI")?.run { uri(this) }
gildor
12/21/2017, 8:07 AMuri
for yougildor
12/21/2017, 8:08 AMuri()
constructor, because empty string is invalid urixenoterracide
12/21/2017, 8:08 AMgildor
12/21/2017, 8:10 AMval s3Uri = System.getenv("JRS_S3_URI")
url = if (s3Uri == null) null else uri(s3Uri)
xenoterracide
12/21/2017, 8:11 AMgildor
12/21/2017, 8:12 AMgildor
12/21/2017, 8:14 AM.
if expression before ?
is null
run - mens: get receiver object as context (this) and return result of lambda
, so run converts string to uri. If there is null instead of string just return nullgildor
12/21/2017, 8:16 AMgildor
12/21/2017, 8:17 AM.run
and .let
very similar, run gets receiver as this
but let gets receiver as first lambda argumentxenoterracide
12/21/2017, 8:21 AMxenoterracide
12/21/2017, 8:21 AMxenoterracide
12/21/2017, 8:21 AMgildor
12/21/2017, 8:22 AMgildor
12/21/2017, 8:22 AMxenoterracide
12/21/2017, 8:25 AMxenoterracide
12/21/2017, 8:26 AMgildor
12/21/2017, 9:07 AMval publishConigAvailable = System.getenv('JRS_S3_URI') != null
If (publishConigAvailable) {
publishing {
...
}
}
xenoterracide
12/21/2017, 9:09 AMrun
seems to work well enoughgildor
12/21/2017, 9:15 AMgildor
12/21/2017, 9:28 AMxenoterracide
12/21/2017, 11:32 AMSystem.getenv("JRS_S3_URI")?.let {
val sourcesJar by tasks.creating(Jar::class) {
classifier = "sources"
from(java.sourceSets["main"].allSource)
}
publishing {
repositories {
maven {
url = uri(it)
credentials(AwsCredentials::class.java) {
accessKey = System.getenv("JRS_ACCESSKEYID")
secretKey = System.getenv("JRS_SECRETACCESSKEY")
}
}
}
(publications) {
"mavenJava"(MavenPublication::class) {
from(components["java"])
artifact(sourcesJar)
}
}
}
}
going with this, presuming it's effectively the same