Hi,
I’m converting a set of maven projects that eventually should result in an EAR to a Gradle build. So far so good. But now I encounter an issue I cannot seem to figure out myself:
One of the projects had a dependency to hibernate-spatial-mysql (in the original pom). This pom has eventually a parent called hibernate- spatial-maven (here: http://bit.ly/wxu2Jl ) that has amongst others a dependency to com.vividsolutions:jts:1.10.
This vividsolutions jar is used in the project at hand.
Now when I build the original project with maven, things go fine. But my gradle build fails, it cannot find the com.vividsolutions jar.
I reproduced the problem in a simple setup. First the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>wouda.test</groupId>
<artifactId>spatial-ding</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>org.hibernatespatial</groupId>
<artifactId>hibernate-spatial-mysql</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Hibernate Spatial repo</id>
<url>http://www.hibernatespatial.org/repository</url>
</repository>
</repositories>
</project>
The same goal but with maven:
apply plugin: 'java'
dependencies {
compile group: 'org.hibernatespatial', name: 'hibernate-spatial-mysql', version: '1.0'
}
repositories {
maven {
url "http://download.java.net/maven/2"
artifactUrls "http://www.hibernatespatial.org/repository"
}
}
Now when you run “mvn dependency:tree” is shows something like:
[INFO] \- org.hibernatespatial:hibernate-spatial-mysql:jar:1.0:provided
[INFO]
+- org.hibernatespatial:hibernate-spatial:jar:1.0:provided
[INFO]
+- org.hibernate:hibernate-core:jar:3.3.2.GA:provided
[INFO]
|
+- antlr:antlr:jar:2.7.6:provided
[INFO]
|
+- commons-collections:commons-collections:jar:3.1:provided
[INFO]
|
+- dom4j:dom4j:jar:1.6.1:provided
[INFO]
|
|
\- xml-apis:xml-apis:jar:1.0.b2:provided
[INFO]
|
+- javax.transaction:jta:jar:1.1:provided
[INFO]
|
\- org.slf4j:slf4j-api:jar:1.5.8:provided
[INFO]
+- com.vividsolutions:jts:jar:1.10:provided
<-- This is wat we need
But when I run gradle dependencies I get:
compile - Classpath for compiling the main sources.
\--- org.hibernatespatial:hibernate-spatial-mysql:1.0 [default]
That’s it. The ‘upwards’ dependencies that are defined in the parent pom (hibernate-spatial-maven) are not put on the compile time classpath.
I’ve tried things with ResolutionStrategy but that does not work.
Also when I remove the url “http://download.java.net/maven/2” in the repositories block, I get an error that It cannot find vividsolutions.
So it seems, the gradle build is working fine in the sense that it fetches all the dependencies of the parent pom, however it is used during compile time?
How can I get these parent dependencies on the classpath?
tia,
Alex