I have a bunch of Team Foundation Server projects to be built that all use common build logic, saving a few properties that need to be set. Since I don’t want to replicate all of this code in each project, I have moved the logic into a common gradle file, and have a gradle.properties file in each project. There exists a build.gradle file in each project as well. It’s job is to pull down the common build script from Artifactory. The common build script then pulls down a custom plugin that I’ve written to handle a lot of the dirty work of building and adds a couple of tasks. The custom plugin is also in Artifactory. How can I get this chain of grabbing files working? I currently have:
project/build.gradle:
apply from: "http://artifactory/.../CommonBuildScript.gradle"
CommonBuildScript.gradle:
buildscript {
repositories {
...
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
classpath(group: '..', name: 'customplugin', version: '1.0') {
changing = true
}
}
}
buildscript {
configurations.classpath.resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
apply plugin: 'customplugin'
artifactory {
...
artifacts {
...
}
}
task taskname(type: custompluginType) {
...
}
It seems that I cannot change buildscript from the CommonBuildScript after ‘apply from’. Or, it will simply ignore it and then not grab my dependencies, so the plugins cannot be found. I would like to move as much from the project/build.gradle as possible, but I fear it may not be possible. I moved my CommonBuildScript.gradle as is into a project/build.gradle, and everything worked perfectly. Any suggestions?
Thank you for your time. Love love love Gradle in the couple weeks I’ve been able to use it. Very powerful.