Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Gradle to find local SNAPSHOT resource?

I'm trying to do some work with the springfox project which has been broken up into two separate projects: the springfox runtime, and a suite of demos.

In order to investigate the behavior of certain configurations, I need to change the module in springfox/springfox-petstore, and compile that into springfox-demos/springfox-java-swagger.

In springfox, I built and published a new version of springfox-petstore, and validated that it exists correctly in ~/.m2/repository/io/springfox/springfox-petstore/2.2.2-SNAPSHOT.

Next, in springfox-demos I added mavenLocal() as a repository, and added the springfox-petstore-2.2.2-SNAPSHOT as a changing=true dependency.

When I attempt to build the springfox-demos runtime, I get the following error:

* What went wrong:
A problem occurred configuring project ':spring-java-swagger'.
 > Could not resolve all dependencies for configuration ':spring-java-swagger:runtimeCopy'.
   > Could not find io.springfox:springfox-petstore:2.2.2-SNAPSHOT.
     Searched in the following locations:
         https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/maven-metadata.xml
         https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.pom
         https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.jar
         http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/maven-metadata.xml
         http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.pom
         http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.jar
     Required by:
         springfox-demos:spring-java-swagger:unspecified

I've tried a variety of combinations of build tasks but I can't seem to get Gradle to honor my request for using the local maven repo with a -SNAPSHOT artifact.

Here is the top-level build.gradle:

buildscript {
  repositories {
    mavenLocal()
    jcenter()
  }

  dependencies {
    classpath "com.github.adrianbk:gradle-jvmsrc-plugin:0.6.1"
    classpath 'com.ofg:uptodate-gradle-plugin:1.6.0'
  }
}

apply from: "$rootDir/gradle/dependencies.gradle"

subprojects {
  apply plugin: 'com.github.adrianbk.jvmsrc'

  jvmsrc {
    packageName "springfoxdemo"
  }
  apply plugin: 'java'
  apply plugin: 'com.ofg.uptodate'

  repositories {
    jcenter()
    maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
  }


  sourceCompatibility = 1.7
  targetCompatibility = 1.7

  configurations.all {
    //Dont cache snapshots
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  }
}

wrapper {
  gradleVersion = "2.4"
}
like image 246
PaulProgrammer Avatar asked Jan 07 '23 10:01

PaulProgrammer


1 Answers

So it appears that the top-level build.gradle can have more than one repositories{} block. I had correctly added the mavenLocal() to one, but missed the other. Once adding the mavenLocal() to the second block, all worked well.

like image 77
PaulProgrammer Avatar answered Jan 14 '23 21:01

PaulProgrammer