The following code works fine with gradle 1.0-milestone-9 and earlier, however it throws a NullPointerException when using rc-1 through rc-3. The problem seems to be the ProfileEventAdapter.buildStarted method was not called before the ProfileEventAdapter.beforeResolve and thus buildProfile has not been initialised.
build.gradle
import org.gradle.GradleLauncher
import org.gradle.api.GradleScriptException
import org.gradle.configuration.ScriptPlugin
import org.gradle.configuration.ScriptPluginFactory
import org.gradle.groovy.scripts.ScriptSource
import org.gradle.groovy.scripts.UriScriptSource
import test.Test
Test t = new Test()
scriptPluginFactory = GradleLauncher.newInstance().gradle.services.get(ScriptPluginFactory)
ScriptSource source = new UriScriptSource("", new File("test.gradle"))
ScriptPlugin scriptPlugin = scriptPluginFactory.create(source)
scriptPlugin.setClassLoader(this.class.classLoader)
scriptPlugin.apply(t)
println t.data
Test.groovy:
package test;
public class Test {
String data;
}
test.gradle:
data="22"