Reputation: 3809
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.
Upvotes: 6
Views: 3956
Reputation: 3775
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 ')
}
Upvotes: 2
Reputation: 123910
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.
Upvotes: 1