Gradle Multiple Maven Repo

时间:2015-02-22 23:55:57

标签: gradle build.gradle

我在build.gradle中添加了一个依赖项: spring-data-neo4j 它需要 neo4j-cypher-dsl-2.0.1.jar / pom ,它只位于仓库:https://repo1.maven.org/maven2/

然而,根据gradle下面的输出,永远不会看这个神器的回购。我怎样才能获得gradle来搜索这个回购。

//build.gradle
buildscript {
repositories {
    mavenCentral()
    maven {
        url "https://repo1.maven.org/maven2/"
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}

}

gradle build:
FAILURE: Build failed with an exception.

What went wrong: Could not resolve all dependencies for configuration ':compile'.
Could not find org.neo4j:neo4j-cypher-dsl:2.0.1.   Searched in the following locations:
https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.pom

https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.jar Required by:

  **:feedserver:1.0.0 > org.springframework.data:spring-data-neo4j:3.2.2.RELEASE**

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

编辑:--------------------------------------- 抱歉,我意外地发布了上面不正确的build.gradle内容,该内容重复了maven中心位置。这是我的实际build.gradle文件...当我使用这些设置构建时,我仍然得到上面的错误:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "http://m2.neo4j.org/content/repositories/releases/" 
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
    }
} 

1 个答案:

答案 0 :(得分:1)

neo4j-cypher-dsl不在Maven中心。它可以在Neo4j存储库中使用,你必须添加另一个这样的repo:

repositories {
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/" 
    }
}

注意没有必要使用另一个maven ponting到maven central使用mavenCentral()就足够了

编辑1

repositories中的

buildscript部分仅适用于内部的依赖项。在这种情况下,对于spring-boot-gradle-plugin

buildscript {
    ext {
        springBootVersion = '1.1.9.RELEASE'
    }
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

在您的情况下,您希望为项目添加其他依赖项。因此,您需要在repositories

中添加另一个buildscript部分
repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/"
    }
}