Ivy artifactPattern vs group:name:version

I’ve been digging around in the userguide for a good part of the day and only because it’s still not clear do I bring it up here. Ok, moving forward with my question, how should my dependencies be fined by using group:name:version with the following artifact pattern? Basically, I want to get everything from, for example, http://svn/ivy/spring/3.6.8.RELEASE/*.jar. Here’s part of my build.gradle:

//start code repositories {

ivy {

url ‘http://svn/ivy/

//artifactPattern “http://svn/ivy/[module]/[revision]/[artifact]-[revision].[ext]”

} }

dependencies {

//compile|runtime|testCompile|testRuntime group:name:version

compile ‘hibernate-distribution:hibernate-distruibution:3.6.8’

compile ‘spring:spring:3.6.8.RELEASE’

compile ‘mybatis-spring:mybatis-spring:1.0.3’

compile ‘mybatis:mybatis:3.1.0’

testCompile ‘junit:junit:4.10.0’

testRuntime ‘junit:junit:4.10.0’ } //end code

//start output g -dependencies The -dependencies option is deprecated - use ‘gradle dependencies’ instead :dependencies

------------------------------------------------------------ Root project ------------------------------------------------------------

archives - Configuration for archive artifacts. No dependencies

compile - Classpath for compiling the main sources.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:dependencies’. Cause: Could not resolve all dependencies for configuration ‘:compile’. Cause: Could not find group:hibernate-distribution, module:hibernate-distruibution, version:3.6.8. Required by:

:gradle:unspecified Cause: Could not find group:spring, module:spring, version:3.6.8.RELEASE. Required by:

:gradle:unspecified Cause: Could not find group:mybatis-spring, module:mybatis-spring, version:1.0.3. Required by:

:gradle:unspecified Cause: Could not find group:mybatis, module:mybatis, version:3.1.0. Required by:

:gradle:unspecified

  • 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: 2.962 secs //end output

//start version gradle --version

------------------------------------------------------------ Gradle 1.0-milestone-6 ------------------------------------------------------------

Gradle build time: Thursday, November 17, 2011 5:54:12 AM UTC Groovy: 1.8.4 Ant: Apache Ant™ version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_11 (Sun Microsystems Inc. 11.0-b16) OS: Linux 2.6.18-194.el5 i386

The way you specify the dependencies is correct (it’s independent of the artifact pattern), but the dependencies can’t be found. Maybe the artifact pattern is wrong. Note that “module:group:version” always refers to the default configuration of a module. If the ivy.xml for a module specifies other configurations, you can refer to them with the long notation:

dependencies {
  compile group: ..., name: ..., version: ..., configuration: ...
}

PS: Why do you get these dependencies from an Ivy repository? It would be simpler to get them straight from Maven Central (or an artifact repository that proxies Maven Central).

PPS: Please format source code with the code tag.

Thanks, Peter! My company already has ivy set-up for dependency management, so thought I’d try to use it.

apply plugin: 'java'
  repositories {
    ivy {
      url 'http://svn/ivy/'
      //artifactPattern "http://svn/ivy/[module]/[revision]/ivy-module.xml"
        }
}
  //compile|runtime|testCompile|testRuntime group:name:version
  dependencies {
   compile 'hibernate-distribution:hibernate-distribution:3.6.8'
   compile 'spring:spring:3.6.8.RELEASE'
   compile 'mybatis-spring:mybatis-spring:1.0.3'
   compile 'mybatis:mybatis:3.1.0'
   testCompile 'junit:junit:4.10.0'
   testRuntime 'junit:junit:4.10.0'
}

When I run debug I get:

10:17:01.923 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper]

trying http://svn/ivy/spring/spring/3.6.8.RELEASE/ivy-3.6.8.RELEASE.xml

So close, but I have yet to figure out what the deal is…I’m turning knobs and pushing buttons :stuck_out_tongue:

I’ve been following Jira 197, but meh, I need to move forward. Maybe Maven Central ought to be considered at this point.

If it can’t find the ivy.xml, maybe the ivyPattern is wrong.

Thanks again, Peter. I persisted a bit and made it work. I have been playing around with the artifactPattern and lengthened the dependency notation per your suggestion, and voila. Thanks for the help.

apply plugin: 'java'
  repositories {
    ivy {
      url 'http://svn/ivy/'
      artifactPattern "http://svn/ivy/[module]/[revision]/ivy-module.xml"
        }
}
  //compile|runtime|testCompile|testRuntime group:name:version
  dependencies {
   compile group: 'myorg', name: 'hibernate-distribution', version: '3.6.8', configuration: 'all'
   compile group: 'myorg', name: 'spring', version: '3.6.8.RELEASE', configuration: 'all'
   compile group: 'myorg', name: 'mybatis-spring', version: '1.0.3', configuration: 'all'
   compile group: 'myorg', name: 'mybatis', version: '3.1.0', configuration: 'all'
   testCompile group: 'myorg', name: 'junit', version: '4.10.0', configuration: 'all'
   testRuntime group: 'myorg', name: 'junit', version: '4.10.0', configuration: 'all'
}