Hi,
I’m trying to build a gradle script that pulls in a specific version or SNAPSHOT from artifactory based on a command line variable. -Pdt=release or -Pdt=snapshot {default}
Based on the ‘dt’ parameter, it would either get from libs-release-local or libs-snapshot-local which we deploy to.
My problem seems to be that I cannot define the repoUrl before hand and I cannot define it afterwards as artifactory.
This is a bit messy since I was just testing but you’ll get the general idea of where I am:
configurations{
deploy
}
def repoUrl = "http://127.0.0.1:8081/artifactory/"
def finalUrl = ""
if (project.hasProperty('dt')) {
println "dt = ${dt}"
if (!(dt.equalsIgnoreCase('release') || (dt.equalsIgnoreCase('snapshot')
))) {
println "*****************************************"
println "* dt must either be release or snapshot *"
println "*****************************************"
System.exit(0)
} else {
finalUrl = repoUrl + 'libs-release-local'
if (dt.equalsIgnoreCase('snapshot')) {
finalUrl = repoUrl + 'libs-snapshot-local'
}
}
} else {
println "**************************************"
println "* Please tell us the deployment type *"
println "* by using -Pdt=release,snapshot *"
println "**************************************"
System.exit(0)
}
repositories {
maven { url ${finalUrl} }
}
dependencies{
deploy 'com.test.myApp:+''
}
task deploy (type:Copy) {
from configurations.deploy
into "/opt/myApp/lib"
}
task clean << {
println "In Local Clean..."
def dirs = ["lib"]
dirs.each {
delete it
}
}