On 24/02/2011, at 2:50 AM, Jesper Skov wrote:
> Hi
>
> I am rewriting our build infrastructure to use Gradle.
>
> At the moment I am trying to make a clever (possibly too clever) bootstrap
> process that intends to do this:
>
> * Use an environment variable to find a bootstrap jar, containing a
> bootstrap plugin called 'buildscripts'
> * This plugin uses a specified BuildScripts version string copy the actual
> BuildScripts to a the local computer (our NAS is painfully slow)
> * The additional plugins in the BuildScripts project are then loaded.
>
> My code - that works - looks like this:
>
> ----------------------------------------------------------------------------------
> buildscript {
> dependencies {
> classpath
> files("file://${System.getenv('JB_BUILDSCRIPTS_BOOTSTRAP_JAR')}")
> }
> }
> apply(plugin: 'buildscripts')
>
> println buildScriptsHome
>
> buildscript {
> dependencies {
> // FAILS: classpath fileTree(dir: buildScriptsHome, include: "*.jar")
> classpath fileTree(dir:
> "d:/udvikler/ws/eclipse/jb.jbit.im.tools.buildscripts/dist", include:
> "*.jar") // WORKS
> }
> }
> apply plugin: 'ivy'
> ----------------------------------------------------------------------------------
One option which may work for you, is to use a script plugin instead of a jar
plugin:
buildscript {
apply from: System.getenv('JB_BUILDSCRIPTS_BOOTSTRAP_SCRIPT')
}
apply plugin: 'ivy'
In the bootstrap script, you'd do the same work that the plugin currently does.
In particular it would do:
buildScriptsHome = ...
project.buildscript.dependencies {
classpath fileTree(dir: buildScriptsHome, include: "*.jar")
}
You might also think about applying this only from the root project, and in
your bootstrap script you could do:
allprojects {
project.buildscript.dependencies { .... }
}
>
>
> But when I try to internalize the bottow half into the plugin code itself, it
> fails.
>
> If I put this in my 'buildscripts' plugin:
> -----
> project.buildscript {
> dependencies {
> classpath project.fileTree(dir:
> pluginConvention.buildScriptsHome, include: "*.jar")
> }
> }
> -----
>
> The result is "You can't change a configuration which is not in unresolved
> state!"
>
> Any ideas for how to fix this?
>
>
>
>
>
> In the end, I would like my projects to just contain:
>
> apply plugin: 'buildscripts'
>
> and let the 'buildscripts' plugin apply our default plugins (such as ivy).
> But adding my bootstrap jar to the Gradle classpath does not mean it gets
> added to the buildscript classpath. Any chance of getting such behavior in
> the future (and a GRADLE_EXTRA_CLASSPATH or somesuch in the wrapper?)
>
>
> Thanks,
> Jesper
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com