Hi,
I am pretty new to Gradle, I come from a Maven background. I want to be able to override the repository url when performing a deploy to a repository from the command line or some other mechanism similar to using
-DaltDeploymentRepository=… in Maven. I don’t see any way of doing it, probably because of my limited knowledge/experience with Gradle.
You can use project properties for this and simply pass them via the command line using the -P
option.
Hi Mark,
I tried that but had no luck. This is what I am trying to do. Suppose I have a build.gradle file that has this in it:
uploadArchives {
repositories {
mavenDeployer {
repository(url: “http://my.deploy.repository.com/”) {
authentication(userName:"user , password: “s3cr3t”)
}
}
}
}
If I run the following from the command line:
gradle -PuploadArchives.repositories.mavenDeployer.repository.url=http://some.other.repository.com/ upload
the repository url that was declared in the build.gradle file is not overriden on the command line. Is there something I am missing? Is what I want to do possible?
You can do
repositories {
mavenDeployer {
repository(url: "${project.properties.MYREPO?:'http://my.deploy.repository.com/'}") {
authentication(userName:"user , password: "s3cr3t")
}
}
}
}
and then do gradle -PMYREPO=http://foo/bar
.