I am having a problem resolving a dependency via artifactory using gradle. But I can resolve that dependency using maven, so I'm not sure what I am doing wrong.
The maven build file is:
<dependencies>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>geoserver</artifactId>
<version>2.5.1</version>
<type>war</type>
</dependency>
</dependencies>
<repositories>
<repository>
<name>libs-releases</name>
<url>http://<artifactory-host>/artifactory/libs-releases</url>
</repository>
</repositories>
I can confirm that maven will resolve the dependency:
$ mvn dependency:resolve
Downloading: http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.pom
Downloading: http://<artifactory-host>/artifactory/libs-releases/org/geoserver/web/2.5.1/web-2.5.1.pom
Downloading: http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.war
[INFO] The following files have been resolved:
[INFO] org.geoserver:geoserver:war:2.5.1:compile
My gradle build script is:
repositories {
mavenCentral()
maven { url 'http://<artifactory-host>/artifactory/libs-releases' }
}
dependencies {
compile 'org.geoserver:geoserver:2.5.1@war'
}
But gradle will not resolve the dependency:
$ gradle dependencies
:dependencies
compile - Compile classpath for source set 'main'.
\--- org.geoserver:geoserver:2.5.1 FAILED
I've cleaned out the local repository and caches, to ensure that dependencies are resolved. If I turn on debug output I can see that there are HTTP requests for the POM file, but there are no HTTP requests for the WAR file.
[DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Sending request: HEAD /artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.pom HTTP/1.1
[DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 200 OK
I can download both the POM and the WAR file directly, so it's not a problem with the artifacts not existing, or proxy issues, or authentication issues:
$ wget http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.pom
`geoserver-2.5.1.pom' saved [32283/32283]
$ wget http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.war
`geoserver-2.5.1.war' saved [60164745/60164745]
I can't see what I am doing wrong here. It's probably something simple?
edit #1 I added a dependency on a JAR file in artifactory, which resolved without error. And then I added a dependency on another WAR file in artifactory, which also resolved without error. But for some reason the original geoserver WAR dependency resolves when using maven, but not when using gradle.
edit #2 I see the following warning when using the maven build:
[WARNING] The POM for org.geoserver:geoserver:war:2.5.1 is invalid, transitive dependencies (if any) will not be available: 2 problems were encountered while building the effective model for org.geoserver:geoserver:2.5.1
[ERROR] Invalid packaging for parent POM org.geoserver:geoserver:2.5.1, must be "pom" but is "war" @
[FATAL] The parents form a cycle: org.geoserver:geoserver:2.5.1 -> org.geoserver:web:2.5.1 -> org.geoserver:geoserver:2.5.1 @
Looking at the geoserver 2.5.1 soure code:
org.geoserver:geoserver
(WAR) has parentorg.geoserver:web
(POM)org.geoserver:web
(POM) has parentorg.geoserver:geoserver
(WAR)
So there is a cyclic dependency, and the parent of org.geoserver:web
has a non-POM packaging.
But maven goes on to download the WAR file despite this 'fatal' error:
Downloaded: http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.war (58755 KB at 8601.2 KB/sec)
Maybe gradle is more strict on this problem?
edit #3 I changed the dependency to exclude transitive dependencies on org.geoserver:geoserver
:
dependencies {
compile('org.geoserver:geoserver:2.5.1@war') {
transitive = false
}
...
but the dependency still did not resolve when I ran $ gradle dependencies
.
There is a stack overflow error when I run a task using this dependency:
$ gradle bundleArtifacts
:bundleArtifacts
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.geoserver:geoserver:2.5.1.
Required by:
<my-project>:1.0-SNAPSHOT
> Could not resolve org.geoserver:geoserver:2.5.1.
> Could not parse POM http://<artifactory-host>/artifactory/libs-releases/org/geoserver/geoserver/2.5.1/geoserver-2.5.1.pom
> Could not resolve org.geoserver:web:2.5.1.
> Could not parse POM http://<artifactory-host>/artifactory/libs-releases/org/geoserver/web/2.5.1/web-2.5.1.pom
> Could not resolve org.geoserver:geoserver:2.5.1.
...
This shows that gradle does not get to consider the transitive dependencies, because it cannot parse the POM files, because of the cyclic dependency.
I think the only solution here is to create a separate artifact (such as a ZIP file) that contains the org.geoserver:geoserver:2.5.1
WAR artifact, add a dependency on that ZIP file, and create a task that extracts the contents of that ZIP file to a target directory.
compile
toruntime
but still failed to resolve ... see my edits. – John Q Citizen