4

我正在尝试对springfox项目进行一些工作,该项目已被分解为两个独立的项目:springfox 运行时和一套演示。

为了调查某些配置的行为,我需要更改 中的模块springfox/springfox-petstore,并将其编译为springfox-demos/springfox-java-swagger.

在 .springfox中,我构建并发布springfox-petstore~/.m2/repository/io/springfox/springfox-petstore/2.2.2-SNAPSHOT.

接下来,在springfox-demos我添加mavenLocal()为存储库,并添加springfox-petstore-2.2.2-SNAPSHOTchanging=true依赖项。

当我尝试构建springfox-demos运行时,我收到以下错误:

* 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

我已经尝试了各种构建任务的组合,但我似乎无法让 Gradle 满足我使用带有 -SNAPSHOT 工件的本地 maven 存储库的请求。

这是顶级 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"
}
4

1 回答 1

9

所以看起来顶层的 build.gradle 可以有多个repositories{}块。我已经正确地添加了mavenLocal()一个,但错过了另一个。一旦添加mavenLocal()到第二个块,一切都很好。

于 2015-10-06T16:10:48.373 回答