如何配置Gradle查找本地SNAPSHOT资源? [英] How to configure Gradle to find local SNAPSHOT resource?

查看:511
本文介绍了如何配置Gradle查找本地SNAPSHOT资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对 springfox 项目进行一些工作,该项目已分解为两个单独的项目项目:springfox运行时,以及一整套演示.

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.

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

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.

springfox中,我构建并发布了springfox-petstore的新版本,并验证了它在~/.m2/repository/io/springfox/springfox-petstore/2.2.2-SNAPSHOT中是否正确存在.

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.

接下来,在springfox-demos中,我添加了mavenLocal()作为存储库,并添加了springfox-petstore-2.2.2-SNAPSHOT作为changing=true依赖项.

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

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

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

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

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.

这是顶层build.gradle:

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"
}

推荐答案

因此,顶层build.gradle似乎可以包含多个repositories{}块.我已经将mavenLocal()正确地添加到其中一个,但是错过了另一个.将mavenLocal()添加到第二个块后,一切工作正常.

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.

这篇关于如何配置Gradle查找本地SNAPSHOT资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆