So I’ve done some playing around. Here is the layout of my custom disto:
-Inside the init.d directory I have my init script. In the init.d directory I also have a directory called ‘libs’, and in there are all of the jar files that I have packaged (which contain my custom plugins & other libraries I am shipping with the distribution.
Here’s the init script:
// Make the plugin visible to all projects, by including it in the build script classpath.
rootProject {
buildscript {
dependencies {
classpath fileTree(dir: "${initscript.sourceFile.parentFile}/libs", include: '**/*.jar')
}
}
}
// Also make the plugins available to this init script
initscript {
dependencies {
classpath fileTree(dir: "${initscript.sourceFile.parentFile}/libs", include: '**/*.jar')
}
}
import some.package.to.build.util.BuildSystemProperty
import some.package.to.build.versionChecking.DistributionUtil
// Print out the version information
println "\n-------------------------------------------------------------------------------"
println "My Company Gradle Build System ${DistributionUtil.getInstance().getBuildSystemProperty(BuildSystemProperty.DISTRIBUTION_VERSION)}"
println "My Company Plugins Version: ${DistributionUtil.getInstance().getBuildSystemProperty(BuildSystemProperty.PLUGINS_VERSION)}"
println "Core Gradle Distribution Version: ${gradle.gradleVersion}"
println "-------------------------------------------------------------------------------\n"
gradle.allprojects {
// Want to apply the mycompany-base plugin to all projects by default
apply plugin: 'mycompany-base'
}
The output looks like this when I run any task:
-------------------------------------------------------------------------------
My Company Gradle Build System 1.2-UNCONTROLLED ARTIFACT
My Company Plugins Version: UNCONTROLLED ARTIFACT
Core Gradle Distribution Version: 1.2
-------------------------------------------------------------------------------
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\gradle\custom-gradle-bin\init.d\custom-plugins.gradle' line: 29
* What went wrong:
Failed to notify action.
> Plugin with id 'mycompany-base' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.367 secs
But yet, if in the project’s build.gradle file I include the line
apply plugin: 'mycompany-base'
It works fine.
What am I doing wrong here? I know it is finding the jars for my plugins, since the println outputs call into classes that are in the jars and they work.