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?