I have 3 Gradle 2.3 projects. The 1st is a simple commons projects that gets uploaded to my local Maven repository using uploadArchives. The 2nd projects has three sub-projects; common, client and server. I can build and run, bootRun, the 2nd server sub-project with dependencies on the 1st project and the 2nd common sub-project. I can upload the 2nd client sub-project and use it in my 3rd project if the client sub-project only depends on external dependencies. When the 2nd client project depends on my 1st project, the pom file is bad/truncated and the 3rd project does not build.
Here is the error the 3rd project gets.
Could not resolve all dependencies for configuration ':passport-service-common:compile'.
> Could not resolve com.wstrater:contact-service-client:0.0.1-SNAPSHOT.
Required by:
com.wstrater:passport-service-common:0.0.1-SNAPSHOT
> Could not parse POM file:/home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134727-4.pom
> XML document structures must start and end within the same entity.
A look at the end of the bad/truncated pom file.
$ tail -5 /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134727-4.pom
<groupId>commons-jxpath</groupId>
</exclusion>
<exclusion>
<artifactId>jsr166y</artifactId>
Looking at the pom files I have generated with the uploadArchives task in the 2nd client sub-project. The shorter file, 9841 bytes, is a valid pom generated without the dependency on the 1st project.
$ ls -l /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.13*.pom
-rw-r--r-- 1 wstrater users 9841 May 20 09:40 /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134038-2.pom
-rw-r--r-- 1 wstrater users 12288 May 20 09:42 /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134249-3.pom
-rw-r--r-- 1 wstrater users 12288 May 20 09:47 /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134727-4.pom
Here is some of the gradle build script from the 1st project.
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${System.properties['user.home']}/.m2/repository")
}
}
}
dependencies {
compile('javax.servlet:javax.servlet-api:3.1.0')
compile('org.hamcrest:hamcrest-core:1.3')
compile('log4j:log4j:1.2.17')
testCompile('junit:junit:4.11')
}
Here is some of the gradle build script from the 2nd project.
project(':contact-service-common') {
}
project(':contact-service-client') {
apply plugin: 'maven'
dependencies {
compile project(':contact-service-common')
// ******* Breaks the pom *******
compile("com.wstrater:commons:${version}")
compile("org.springframework.cloud:spring-cloud-starter-eureka:${springCloudVersion}")
compile("org.springframework.cloud:spring-cloud-starter-hystrix:${springCloudVersion}")
}
jar {
from files(
project(':contact-service-common').sourceSets.main.output
)
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from files(
sourceSets.main.allSource,
project(':contact-service-common').sourceSets.main.allSource
)
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from(
javadoc.destinationDir,
project(':contact-service-common').javadoc.destinationDir
)
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(url: "file://${System.properties['user.home']}/.m2/repository")
}
}
}
}
The 1st and 2nd projects build successfully even with the truncated pom file.
Thanks, Wes.
In case you haven’t given up reading a long post here are some more details.
The Gradle details.
$ ./gradlew -v
------------------------------------------------------------
Gradle 2.3
------------------------------------------------------------
Build time: 2015-02-16 05:09:33 UTC
Build number: none
Revision: 586be72bf6e3df1ee7676d1f2a3afd9157341274
Groovy: 2.3.9
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_40 (Oracle Corporation 24.0-b56)
OS: Linux 2.6.18-402.el5 amd64
The differences between the pom files.
--- /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134038-2.pom 2015-05-20 09:40:38.000000000 -0400
+++ /home/wstrater/.m2/repository/com/wstrater/contact-service-client/0.0.1-SNAPSHOT/contact-service-client-0.0.1-20150520.134727-4.pom 2015-05-20 09:47:27.000000000 -0400
@@ -6,9 +6,9 @@
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-hystrix</artifactId>
- <version>1.0.1.RELEASE</version>
+ <groupId>com.wstrater</groupId>
+ <artifactId>contact-service-common</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -98,9 +98,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>com.wstrater</groupId>
- <artifactId>contact-service-common</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-hystrix</artifactId>
+ <version>1.0.1.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -190,9 +190,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-eureka</artifactId>
- <version>1.0.1.RELEASE</version>
+ <groupId>com.wstrater</groupId>
+ <artifactId>commons</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -281,8 +281,80 @@
</exclusion>
</exclusions>
</dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies/>
- </dependencyManagement>
-</project>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-eureka</artifactId>
+ <version>1.0.1.RELEASE</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>guice-multibindings</artifactId>
+ <groupId>com.google.inject.extensions</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>asm-all</artifactId>
+ <groupId>asm</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>annotations</artifactId>
+ <groupId>com.google.code.findbugs</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>stringtemplate</artifactId>
+ <groupId>org.antlr</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>guice-grapher</artifactId>
+ <groupId>com.google.inject.extensions</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>hibernate-validator</artifactId>
+ <groupId>org.hibernate</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>antlr-runtime</artifactId>
+ <groupId>org.antlr</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>validation-api</artifactId>
+ <groupId>javax.validation</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xbean-finder</artifactId>
+ <groupId>org.apache.xbean</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>joda-time</artifactId>
+ <groupId>joda-time</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-math</artifactId>
+ <groupId>org.apache.commons</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>antlr</artifactId>
+ <groupId>antlr</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>netflix-infix</artifactId>
+ <groupId>com.netflix.netflix-commons</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-logging</artifactId>
+ <groupId>org.jboss.logging</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>classmate</artifactId>
+ <groupId>com.fasterxml</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-jxpath</artifactId>
+ <groupId>commons-jxpath</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jsr166y</artifactId>
+
\ No newline at end of file