How to configure Gradle to find local SNAPSHOT resource?
Asked Answered
I

1

6

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"
}
Ignacia answered 5/10, 2015 at 22:30 Comment(2)
Could you add the dependencies and repositories snippets from your build.gradle file, as well as the gradle plug-ins you've applied? If you haven't already, add apply plugin: 'maven' to the file (I can't remember if I added it to my workings attempt at this to allow a repository of mavenLocal() or for the thing in the same files which pushes to my local maven)Earwig
#8384021Carmarthenshire
I
11

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.

Ignacia answered 6/10, 2015 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.