How to fix “Cannot change dependencies of configuration ':rest-common:compile' after it has been included in dependency resolution.”?

I’ve read similar posts with the same question, but the issues seem to be specific so I haven’t been able to find a generic answer that works for me.

$ ./gradlew -version

------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------

Build time:   2017-03-03 19:45:41 UTC
Revision:     9eb76efdd3d034dc506c719dac2955efb5ff9a93

Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Mac OS X 10.15.7 x86_64

I have 2 modules, module2 depends on module 1. I built and published module1-2.0.0.jar with this build.gradle file

apply plugin: 'java'
version=parent.rest_common_version

jar {
    manifest {
    attributes 'artifactId': artifactId,
                   'groupId': project.group,
                   'version': project.version
    }
    baseName artifactId
}

eclipse {
    project {
        natures 'org.springsource.ide.eclipse.gradle.core.nature',
                'org.eclipse.jdt.core.javanature'
    }
}

publishing {
    publications {
        restCommon(MavenPublication){
            artifactId artifactId
            from components.java
        }
    }
}

configurations.compile.exclude group: 'velocity', module: 'velocity'
configurations.compile.exclude group: 'javax.servlet', module: 'servlet-api'
configurations.compile.exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
configurations.compile.exclude group: 'org.springframework.boot'
configurations.all*.exclude group: 'com.vaadin.external.google', module: 'android-json'
configurations.compile.exclude group: 'bouncycastle'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcpkix-jdk15on'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcmail-jdk15on'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcprov-jdk15'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcprov-jdk14'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcmail-jdk14'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bctsp-jdk14'

dependencies {
  compile "$parent.group:rest-client:$parent.ziftrestclient_version"

  compile 'javax.servlet:javax.servlet-api:3.1.0'
  compile('org.apache.tika:tika-parsers:1.11'){
    exclude group: "org.ow2.asm", module: "asm"
    exclude group: "org.bouncycastle", module: "bcprov-jdk15on"
    exclude group: "org.bouncycastle", module: "bcmail-jdk15on"
    exclude group: "c3p0", module: "c3p0"
  }

    // These are the versions of Bouncycastle JARs needed by ZiftSAML
    compile ("org.bouncycastle:bcmail-jdk15:1.38") {
        force = true
    }

    compile ("org.bouncycastle:bctsp-jdk15:1.38") {
        force = true
    }

    compile 'org.slf4j:slf4j-api:1.7.25'

    testCompile "com.zift.test:zift-test-util:1.0.53"

    testCompile "org.codehaus.groovy:groovy:2.4.15"
    testCompile "org.codehaus.groovy:groovy-nio:2.4.15"
    testCompile "org.codehaus.groovy:groovy-json:2.4.15"
    testCompile "org.codehaus.groovy:groovy-xml:2.4.15"

    // For REST Stub generator
    testCompile 'commons-cli:commons-cli:1.2'
    testCompile 'org.json:json:20140107'
    testCompile 'org.reflections:reflections:0.9.10'
    testCompile 'org.apache.velocity:velocity:1.7'

    testCompile 'org.easymock:easymock:3.+'
}

task testJarForStubs(type: Jar) {
    classifier 'tests'
    from sourceSets.test.output
}

Now I build module2 with the following build.gradle file

apply plugin: 'org.springframework.boot'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.4.RELEASE")
    }
}

version=parent.ziftprocessor_version

eclipse {
    project {
        natures 'org.springsource.ide.eclipse.gradle.core.nature',
                'org.eclipse.jdt.core.javanature',
                'org.springframework.ide.eclipse.core.springnature'
    }
}

jar {
    manifest {
        attributes 'artifactId': applicationName,
                      'groupId': group,
                      'version': project.version
    }
    baseName applicationName
}

publishing {
    publications {
        processor(MavenPublication) {
            artifactId applicationName
            from components.java
        }
    }
}

springBoot {
    mainClass = 'com.zift.processor.Application'
    classifier = 'boot'
}

dependencyManagement {
    // These versions are needed by HtmlUnit - but the resolution without this was using 4.5.1
    dependencies {
        dependency 'org.apache.httpcomponents:httpclient:4.5.2'
        dependency 'org.apache.httpcomponents:httpmime:4.5.2'
        dependency 'com.google.guava:guava:23.0'
        dependency 'org.seleniumhq.selenium:selenium-java:3.141.59'
        dependency 'org.seleniumhq.selenium:selenium-api:3.141.59'
        dependency 'org.seleniumhq.selenium:selenium-support:3.141.59'
        dependency 'org.seleniumhq.selenium:selenium-chrome-driver:3.141.59'
        dependency 'org.seleniumhq.selenium:selenium-remote-driver:3.141.59'
        dependency 'com.hazelcast:hazelcast:4.0.1'
    }
}

task copyToDist(type: Copy, dependsOn: bootRepackage) {
    from bootRepackage
    into "$dist_dir"
    rename { name ->
        "proc.jar"
    }
}

task buildDocker(type: Docker, dependsOn: bootRepackage) {
    doFirst {
        copy {
            from bootRepackage
            rename { name -> 'app.jar' }
            into stageDir
        }
    }
    def dockerTag = project.hasProperty('applicationName') ? project.applicationName : project.name
    tag = dockerTag
    dockerfile = file("$rootDir/deploy/docker/java/Dockerfile")
    doLast {
        exec {
            commandLine 'docker', 'tag', tag, "${dockerTag}:latest"
        }
    }
}

tasks.build.dependsOn copyToDist

configurations.compile.exclude group: 'nekohtml', module: 'nekohtml'
configurations.compile.exclude group: 'c3p0', module: 'c3p0'
configurations.compile.exclude module: 'spring-boot-starter-logging'
configurations.compile.exclude group: 'bouncycastle'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcmail-jdk15on'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcprov-jdk15'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcprov-jdk14'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bcmail-jdk14'
configurations.compile.exclude group: 'org.bouncycastle', module: 'bctsp-jdk14'

dependencies {
    compile "$parent.group:rest-common:$parent.rest_common_version"

    compile "org.springframework.boot:spring-boot-starter"
    compile "org.springframework.boot:spring-boot-starter-log4j2"
    compile "org.springframework.boot:spring-boot-starter-integration"
    compile "org.springframework.integration:spring-integration-file"
    compile "org.springframework.integration:spring-integration-jdbc"
    compile "org.springframework.integration:spring-integration-jms"
    compile "org.springframework.cloud:spring-cloud-starter-aws:1.1.3.RELEASE"
    compile "org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.3.RELEASE"
    compile "org.springframework.integration:spring-integration-aws:1.0.0.RELEASE"
    compile 'org.projectlombok:lombok:1.16.18'

    compile "org.springframework.cloud:spring-cloud-starter-feign:$springCloudVersion"

    compile("org.togglz:togglz-spring-boot-starter:${togglzVersion}")
    compile("com.zift.common:boot-admin-commons:1.0.72")

    compile "org.springframework.security:spring-security-core:$springSecurityVersion"
    compile "org.springframework.security:spring-security-config:$springSecurityVersion"
    compile 'net.sf.uadetector:uadetector-core:0.9.9'
    compile 'net.sf.uadetector:uadetector-resources:2013.09'
    compile 'jython:jython:20020827:no-oro@jar'
    compile 'org.quartz-scheduler:quartz:2.2.3'
    compile 'org.json:json:20140107'

    compile('org.hibernate:hibernate-core:3.6.10.Final') {
        exclude group: 'net.sf.ehcache'
    }

    compile('commons-beanutils:commons-beanutils-core:1.8.0') {
        force = true
    }

    compile "net.sourceforge.htmlunit:htmlunit:2.30"

    // These are the versions of Bouncycastle JARs needed by ZiftSAML
    compile("org.bouncycastle:bcmail-jdk15:1.38") {
        force = true
    }

    compile("org.bouncycastle:bctsp-jdk15:1.38") {
        force = true
    }
    // Hazelcast jars
    compile("com.hazelcast:hazelcast:4.0.1") {
        force = true
    }

    compile("com.zift.hz:zift-hazelcast:1.0.9") {
        force = true
        exclude group: 'org.apache.commons', module: 'commons-lang3'
        exclude group: 'com.google.guava', module: 'guava'
        exclude group: 'org.projectlombok', module: 'lombok'
    }

    compile("com.amazonaws:amazon-kinesis-client:1.7.5") {
        exclude group: 'com.amazonaws'
    }

    // JavaPNS contains org.json classes which conflict with newer needed ones.
    // If Apple Push Notifications are needed in the future, we need to modify JavaPNS 
    // to use updated org.json classes.
    // compile files("$zift_lib/JavaPNS_2.2.jar")

    testCompile "org.springframework.boot:spring-boot-starter-test"
    testCompile "com.zift.test:zift-test-util:1.0.61"
    testCompile "org.codehaus.groovy:groovy:2.4.15"
    testCompile "org.codehaus.groovy:groovy-nio:2.4.15"
    testCompile "org.codehaus.groovy:groovy-json:2.4.15"
    testCompile "org.codehaus.groovy:groovy-xml:2.4.15"
    testCompile "org.easymock:easymock:3.5"

}
import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    filesMatching("**/application*.properties") {
        filter(ReplaceTokens, tokens: [
                "application-name"           : applicationName,
                "implementation-build-number": build_number
        ])
    }
}

But I get the following dreaded error

* Where:
Build file '/path/rest-common/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':rest-common'.
> Cannot change dependencies of configuration ':rest-common:compile' after it has been included in dependency resolution.

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

I can alleviate the error by commenting out everything after the publishing{} block of module1, but that won’t work since I need those when I build module1.

What to do?

You could try putting something like the following into the build in order to trace the resolutions.

configurations.all { conf ->
    conf.incoming.beforeResolve {
        String err = "Configuration '${conf.name}' of project ${rootProject.name}${project.path} is being resolved."
        try {
            throw new RuntimeException()
        } catch ( Exception e ) {
            logger.warn( err, e )
        }
    }
}

I put the above line in module2’s build.gradle file and got

Configuration 'runtime' of project project:module2 is being resolved.
java.lang.RuntimeException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:239)
        at build_d7xhslyp1e31srvoqpypgcdf8$_run_closure8$_closure22.doCall(/Users/cfouts/git-repos/zift/ziftsolutions/ZiftProcessor/build.gradle:88)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
        at groovy.lang.Closure.call(Closure.java:414)
        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.$Proxy26.beforeResolve(Unknown Source)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.performPreResolveActions(DefaultConfiguration.java:474)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$500(DefaultConfiguration.java:106)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$3.execute(DefaultConfiguration.java:452)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$3.execute(DefaultConfiguration.java:446)
        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:446)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:422)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:414)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
        at org.springframework.boot.gradle.repackage.ProjectLibraries.getLibraries(ProjectLibraries.java:109)
        at org.springframework.boot.gradle.repackage.ProjectLibraries.doWithLibraries(ProjectLibraries.java:90)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.addLibraryDependencies(RepackagePluginFeatures.java:158)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.setupInputOutputs(RepackagePluginFeatures.java:151)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.execute(RepackagePluginFeatures.java:136)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.execute(RepackagePluginFeatures.java:114)
        at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:205)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:135)
        at org.gradle.api.internal.tasks.RealizableTaskCollection.all(RealizableTaskCollection.java:192)
        at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:158)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$1.execute(RepackagePluginFeatures.java:84)
        at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$1.execute(RepackagePluginFeatures.java:81)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)
        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.$Proxy15.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:82)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:76)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.access$000(LifecycleProjectEvaluator.java:33)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:53)
        at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:50)
        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:599)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)
        at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
        at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuildAction.execute(DefaultGradleLauncher.java:233)
        at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuildAction.execute(DefaultGradleLauncher.java:230)
        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:160)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
        at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
        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:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:49)
        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:31)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
        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:47)
        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.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

* Where:
Build file '/path/rest-common/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':rest-common'.
> Cannot change dependencies of configuration ':rest-common:compile' after it has been included in dependency resolution.

* 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: 10.344 secs

I just noticed that you’re using very old versions of Gradle and spring-boot. Is this a new project or an existing one that was previously working and is now broken? If it’s new, have you tried upgrading these?

@Chris_Dore, long story. (And thanks for your help!)

We can’t update Gradle since it’ll break a LOT of our build.gradle files, and can’t update Spring Boot since it’ll break our applications. I’ve been in the company ~ 3 yrs, and I’ve tried upgrading both to no avail - something always gets broken. One of these days, I’ll dedicate time to do this right, but 'til then 'tis what 'tis.

This project is a “monolith” projects where I have a top-level project, then is broken down into sub-directories, with each sub-directory representing a “module.” Say the following

application/
-----------/module-core
-----------/module1-depends-on-module-core
-----------/module2-depends-on-module1

So what I’m trying to do is create jar files for the modules, that other modules can then just consume. So we used to have this for module1 for example

module1 build.gradle file
dependencies {
    compile project(":module-core")
}

module2 build.gradle file
dependencies {
    compile project(":module-core")
    compile project(":module1")
}

What I’m trying to do is build module-core-1.0.0.jar and module1-2.0.0.jar files for example (which I’ve successfully done), and then just have this for module2

module1 build.gradle file (builds fine!)
dependencies {
    compile "com.company.module-core:module-core:1.0.0"
}

module2 build.gradle file
dependencies {
    compile "com.company.module1:module1:2.0.0"
}

Oddly enough, I have “other” modules I’ve setup this way, and they build, but this particular module is giving me this issue.