We have similar configuration closures in multiple different projects (not multi-module projects). Is it possible to reuse the below configuration to avoid having to duplicate it in the projects? how can we override some values? maybe a plugin?
artifactory {
contextUrl = '...'
publish {
repository {
repoKey = 'libs-release-local'
username = '...'
password = '...'
}
defaults {
publications('mavenJava')
}
}
resolve {
repository {
repoKey = 'libs-release'
}
}
}
Thanks for your help very much!
This works.
class ArtifactoryConfigurationPlugin implements Plugin<Project> {
void apply(Project project) {
project.apply plugin: "com.jfrog.artifactory"
project.artifactory {
contextUrl = 'http://localhost:8081/artifactory/'
publish {
repository {
repoKey = 'calidad-local'
username = 'admin'
password = 'password'
}
defaults {
publications('mavenJava')
}
}
resolve {
repository {
repoKey = 'libs-release'
}
}
}
}
}
Gradle rocks!
1 Like
You could also create a script plugin by placing the configuration in a .gradle file. Take note that the location of a script plugin can be any valid URI.
apply from: ‘http://intranet.my.org/artifactory.gradle’