Gradle 2.2-rc-1 is now available for testing

The Gradle team is pleased to announce that the release candidate for Gradle 2.2 is now available.

Download links and release notes can be found as always at http://gradle.org/release-candidate.

Please try Gradle 2.2-rc-1 with your projects and let us know your experiences.

Cheers,

René

with new rc release, my build is broken, I have multi sub-projects, there is dependencies,

say if one module has :

dependencies {

compile project(path: ‘:shares’)

testCompile project(path: ‘:shares’, configuration: ‘testlib’) }

it will report: * Where: Build file ‘D:\REPO\root\module1\build.gradle’ line: 2

  • What went wrong: A problem occurred evaluating project ‘:module1’. > You can’t change configuration ‘default’ because it is already resolved!

How should I fix this?

Thanks.

Hello, thanks for reporting.

You saying with gradle 2.1 everything builds fine?

Could you provide a small reproducable example for your issue?

cheers, René

No any error with 2.1. In the parent project’s build.gradle, I have:

subprojects { dependencies {

compile([group: ‘org.slf4j’, name: ‘slf4j-api’, version: slf4jVersion])

testCompile([group: ‘junit’, name: ‘junit’, version: junitVersion]) … }

in the sub module’s build.gradle I have: dependencies {

compile project(path: ‘:shares’)

testCompile project(path: ‘:shares’, configuration: ‘testlib’)

}

that’s cause the issue in the 2.2

I can’t reproduce the issue based on the report. Would you be able to provide a complete build that exhibits the problem? Or at least a stacktrace obtained by running with the ‘-s’ flag?

Here is the stack trace:

Caused by: org.gradle.api.InvalidUserDataException: You can’t change configuration ‘default’ because it is already resolved!

at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.throwExceptionIfAlreadyResolved(DefaultConfiguratio n.java:391)

at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$400(DefaultConfiguration.java:45)

at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$VetoContainerChangeAction.run(DefaultConfiguration. java:491)

at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)

at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:203)

at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)

at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:203)

at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)

at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:203)

at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)

at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)

at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:165)

at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:160)

at org.gradle.api.internal.DelegatingDomainObjectSet.add(DelegatingDomainObjectSet.java:80)

at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAdd(DefaultDependencyHandler.java:84)

at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.java:1 19)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:163)

at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated.invokeMethod(Unknown Source)

at build_c31gvdp628sf18nzpj3oj5gr4$_run_closure1.doCall(D:\REPOs\horizon-root\horizon-common\build.gradle:2)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)

at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:843)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)

at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)

at build_c31gvdp628sf18nzpj3oj5gr4.run(D:\REPOs\horizon-root\horizon-common\build.gradle:1)

at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)

… 32 more

BUILD FAILED

Total time: 4.087 secs

In the parent’s build.gradle, I have this part:

subproject { … sourceSets {

main {

compileClasspath = configurations.compile + configurations.systemAPIProvided + configurations.systemImplProvided

}

test {

compileClasspath = compileClasspath + configurations.systemAPIProvided

}

} … }

Not sure if this cause the issue?

What do you have at the start of D:\REPOs\horizon-root\horizon-common\build.gradle?

Are you using configure on demand, or the ‘evaluationDependsOn’ or ‘evaluationDependsOnChildren’ methods?

dependencies {

compile project(path: ‘:horizon-cdi’)

testCompile project(path: ‘:horizon-cdi’, configuration: ‘arquillian’) }

uploadArchives.dependsOn ‘:horizon-cdi:uploadArchives’

how to tell if I use any of them?

You would literally see that text in the build script. We think we’ve deciphered what the problem is and will be releasing a second RC soon.

I just tried the new one, it works, but it report deprecated warning: Attempting to change configuration ‘:horizon:compile’ after it has been included in dependency resolution. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0

do you have any suggestion to avoid that?

Something in your build is eagerly closing this configuration. 

You should be able to find it by adding this to the buildscript for the horizon project…

<code>
configuration[“default”].incoming.beforeResolve { throw new RuntimeException(“configuration being resolved”) } 
</code>

The build should fail with that exception. If you provide the resultant stack trace I can help you pinpoint the problem.

I tried it, (actually should be configurations[“default”]), no matter where I put it, it stop there. just question, I enabled the -s, and I don’t see evaulationDependsOn or evaluationDependsOnChildren method, also how can I tell where close the configuration?

so here is my project setup, in the parent project’s build.gradle: subprojects {

apply plugin: ‘java’

dependencies {

servletAPIProvided([group: ‘javax.servlet’, name: ‘javax.servlet-api’, version: servletSpecVersion])

systemAPIProvided([group: ‘javax.el’, name: ‘el-api’, version: elSpecVersion])

compile [[group: ‘org.infinispan’, name: ‘infinispan-core’, version: infinispanVersion],

[group: ‘org.slf4j’, name: ‘slf4j-api’, version: slf4jVersion]

testCompile [group: ‘junit’, name: ‘junit’, version: junitVersion],

[group: ‘org.jboss.arquillian.junit’, name: ‘arquillian-junit-container’, version: arquillianVersion]

runtime [group: ‘org.slf4j’, name: ‘slf4j-jdk14’, version: slf4jVersion]

}

sourceSets {

main {

compileClasspath = configurations.compile + configurations.systemAPIProvided + configurations.systemImplProvided

}

test {

compileClasspath = compileClasspath + configurations.systemAPIProvided

}

}

… }

in the sub project I have:

dependencies {

compile project(path: ‘:horizon-cdi’)

testCompile project(path: ‘:horizon-cdi’, configuration: ‘arquillian’) }

not sure if the sourceSets part cause the issue, can you take a look?

my sub project dependencies are: the reset modules depends on horizon-banking-shares, horizon-banking-shares depends on horizon-common, horizon-common depends on horizon-cdi, each of these project may need some special dependencies, And I have added “evaluationDependsOn(’:horizon-common’)” into horizon-banking-shares, and also added "evaluationDependsOn(’:horizon-cdi’) into horizon-common project, it seems not working.

I tried it, (actually should be configurations[“default”]), no matter where I put it, it stop there

What do you mean by “stopped” ?

I figured out, there is one task in my build script try to do:

configurations.default.resolvedConfiguration.resolvedArtifacts.each {ModuleVersionIdentifier module=it.moduleVersion.id; systemProperties[module.group+":"+module.name+":"+module.version]=it.file;}

After I put that into doFirst {} block, the problem is gone.

Yep, that will do it.