【问题标题】:How to configure Gradle to find local SNAPSHOT resource?如何配置 Gradle 以查找本地 SNAPSHOT 资源?
【发布时间】:2015-10-07 00:10:48
【问题描述】:

我正在尝试使用 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-SNAPSHOT 添加为changing=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"
}

【问题讨论】:

  • 你能从你的build.gradle文件中添加依赖和仓库sn-ps,以及你应用的gradle插件吗?如果您还没有,请将apply plugin: 'maven' 添加到文件中(我不记得我是否将其添加到我的工作尝试中以允许 mavenLocal() 的存储库或相同文件中的东西推送到我的本地行家)

标签: maven gradle gradlew springfox


【解决方案1】:

看来顶级 build.gradle 可以有多个 repositories{} 块。我已正确地将mavenLocal() 添加到一个,但错过了另一个。将mavenLocal() 添加到第二个块后,一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 2019-04-29
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    相关资源
    最近更新 更多