New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change dependencies of configuration :<sub-project>:providedCompile after it has been included in dependency resolution. #306

Open
Hubbitus opened this Issue Nov 18, 2016 · 8 comments

Comments

Projects
None yet
6 participants
@Hubbitus

Hubbitus commented Nov 18, 2016

We have multi-project setup like:

plugins {
    id 'org.akhikhl.gretty' version '1.4.0'
}
apply plugin: 'org.akhikhl.gretty'

configure([project(':portal-ui'), project(':portal-api:core'), project(':api-docs')]) {
    apply plugin: 'war'
    apply plugin: 'org.akhikhl.gretty' // <--

    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

I got error: Cannot change dependencies of configuration ':portal-api:core:providedCompile' after it has been included in dependency resolution:

$ ./gradlew tomcatRunWarDebug --stacktrace
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dsun.java2d.pmoffscreen=false -XX:+UseCompressedOops -XX:+DoEscapeAnalysis -XX:+AggressiveOpts -XX:+EliminateLocks -XX:+UseNUMA -XX:+TieredCompilation
[versioning] WARNING - the working copy has unstaged or uncommitted changes.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':portal-api:core'.
> Cannot change dependencies of configuration ':portal-api:core:providedCompile' after it has been included in dependency resolution.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':portal-api:core'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
        at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:124)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:121)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:82)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:59)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:49)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.HintGCAfterBuild.execute(HintGCAfterBuild.java:44)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:240)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.InvalidUserDataException: Cannot change dependencies of configuration ':portal-api:core:providedCompile' after it has been included in dependency resolution.
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:631)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.extendsFrom(DefaultConfiguration.java:232)
        at org.akhikhl.gretty.GrettyPlugin.addConfigurationsAfterEvaluate(GrettyPlugin.groovy:75)
        at org.akhikhl.gretty.GrettyPlugin.afterProjectEvaluate(GrettyPlugin.groovy:695)
        at org.akhikhl.gretty.GrettyPlugin$_apply_closure63$_closure114.doCall(GrettyPlugin.groovy:799)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
        ... 52 more


BUILD FAILED

If I comment out line marked with "<--" project built fine.

@tkgospodinov

This comment has been minimized.

Show comment
Hide comment
@tkgospodinov

tkgospodinov Dec 14, 2016

I'm seeing this too with gradle 3.0. Doesn't seem to happen with gradle 2.10.

tkgospodinov commented Dec 14, 2016

I'm seeing this too with gradle 3.0. Doesn't seem to happen with gradle 2.10.

@Hubbitus

This comment has been minimized.

Show comment
Hide comment
@Hubbitus

Hubbitus Dec 29, 2016

So it seams related to #300

Hubbitus commented Dec 29, 2016

So it seams related to #300

@h3adache

This comment has been minimized.

Show comment
Hide comment
@h3adache

h3adache Jan 27, 2017

I don't know if this project is being maintained anymore. It seems the author(s) haven't commented or responded to anything since August.

But I'm using the plugins { id 'org.akhikhl.gretty' version '1.4.0' } syntax with Gradle 3.3 and it works fine.

I changed my config (which has the apply false and removes the 4th line of your script) to match yours and it still works fine for Gradle 3.3.

I am, however, applying the plugin as so:

if(subproject.name.startsWith("view")) {
    apply plugin: 'org.akhikhl.gretty'
}

h3adache commented Jan 27, 2017

I don't know if this project is being maintained anymore. It seems the author(s) haven't commented or responded to anything since August.

But I'm using the plugins { id 'org.akhikhl.gretty' version '1.4.0' } syntax with Gradle 3.3 and it works fine.

I changed my config (which has the apply false and removes the 4th line of your script) to match yours and it still works fine for Gradle 3.3.

I am, however, applying the plugin as so:

if(subproject.name.startsWith("view")) {
    apply plugin: 'org.akhikhl.gretty'
}
@akhikhl

This comment has been minimized.

Show comment
Hide comment
@akhikhl

akhikhl Jan 31, 2017

Owner

@Hubbitus , can you provide a toy project, allowing to reproduce the problem?

Owner

akhikhl commented Jan 31, 2017

@Hubbitus , can you provide a toy project, allowing to reproduce the problem?

@akhikhl akhikhl self-assigned this Jan 31, 2017

@Hubbitus

This comment has been minimized.

Show comment
Hide comment
@Hubbitus

Hubbitus Feb 27, 2017

I spent around 8 hours to setup toy project, but it disappeared in some strange way… and after some few hours I have small reliable reproduce. In my proguard obfuscation task I need enumerate classpath jars and just read access to configurations.runtime leads to that error!

Please try to add this task:

task bug306test{
    (configurations.runtime + configurations.providedRuntime).findAll{
        println it.path
    }
}

And I immediately got evaluation error on run farm task:

> Failed to apply plugin [id 'org.akhikhl.gretty']
   > Cannot change dependencies of configuration ':portal-api:core:compile' after it has been included in dependency resolution.

What interesting, it work under gradle 2.14!

Hubbitus commented Feb 27, 2017

I spent around 8 hours to setup toy project, but it disappeared in some strange way… and after some few hours I have small reliable reproduce. In my proguard obfuscation task I need enumerate classpath jars and just read access to configurations.runtime leads to that error!

Please try to add this task:

task bug306test{
    (configurations.runtime + configurations.providedRuntime).findAll{
        println it.path
    }
}

And I immediately got evaluation error on run farm task:

> Failed to apply plugin [id 'org.akhikhl.gretty']
   > Cannot change dependencies of configuration ':portal-api:core:compile' after it has been included in dependency resolution.

What interesting, it work under gradle 2.14!

@Hubbitus

This comment has been minimized.

Show comment
Hide comment
@Hubbitus

Hubbitus Feb 28, 2017

As workaround I could wrap that task into project.afterEvaluate {} block and it became functional.

Hubbitus commented Feb 28, 2017

As workaround I could wrap that task into project.afterEvaluate {} block and it became functional.

@zggame

This comment has been minimized.

Show comment
Hide comment
@zggame

zggame Dec 20, 2017

I have the same problem and the work-around solves it. However, do we consider this an issue? Do we plan to solve it? Thanks.

zggame commented Dec 20, 2017

I have the same problem and the work-around solves it. However, do we consider this an issue? Do we plan to solve it? Thanks.

@Akvel

This comment has been minimized.

Show comment
Hide comment
@Akvel

Akvel Jul 3, 2018

@Hubbitus Thanks, this work-around solves all problems

Akvel commented Jul 3, 2018

@Hubbitus Thanks, this work-around solves all problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment