Having the following in build.gradle
:
uploadArchives {
repositories {
mavenDeployer {
repository(url: "$repoUrl") {
authentication(userName: "$repoUser", password: "$repoPassword")
}
}
}
}
how can I make $repoUrl
have a default value file://$buildDir/repo
?
I tried to put repoUrl=file://$buildDir/repo
in gradle.properties
, but it doesn't work as I expected, as it seems that $repoUrl
is not evaluated recursively.
Looks like it is because repoUrl=file://$buildDir/repo
is treated as plain string, without buildDir
substitution.
If may try this:
repository(url: repoUrl.replace('$buildDir', "$buildDir")) {
Or something like this:
// run as 'gradle build -PreportUrl=blabla'
def repoUrl = "file://$buildDir/repo"
if (binding.variables.containsKey('repoUrl ')) {
repoUrl = binding.variables.get('repoUrl ')
}
You cannot reference Gradle properties like project.buildDir
from properties files. Properties files are very limited, and in general, I'd recommend to keep all information in Gradle build scripts. You can have any number of build scripts, and include them with apply from: "path/to/script"
in other scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With