【发布时间】:2017-02-02 21:32:00
【问题描述】:
我有一个项目依赖于本地工件的几个依赖项。
此项目的 Gradle 构建工作正常,存储库设置正确:
buildscript {
repositories {
maven {
url "${artifactoryUrl}/libs-release"
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10'
}
}
repositories {
maven {
url "${artifactoryUrl}/repo"
}
}
artifactory {
contextUrl = "${artifactoryUrl}"
publish {
repository {
repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to
username = "${artifactoryUser}" // The publisher user name
password = "${artifactoryPassword}" // The publisher password
}
defaults {
// Reference to Gradle publications defined in the build script.
// This is how we tell the Artifactory Plugin which artifacts should be
// published to Artifactory.
publications('mavenJava')
publishArtifacts = true
// Properties to be attached to the published artifacts.
properties = ['qa.level': 'basic', 'dev.team' : 'core']
}
}
resolve {
repoKey = 'repo'
}
}
我遵循了关于多项目结构的 gradle 教程。看起来我可以将“存储库”部分移动到根 gradle.build 文件。但是,当我运行 gradle build 时,我在工件的所有依赖项上都出现错误:
无法解析外部依赖
注意:我还在根目录中添加了gradle.properties 文件,其中包含所有变量(artifactoryUrl 等)。
所以子项目似乎无法“看到”根gradle.build 文件中定义的存储库。有什么建议吗?
更新
我在根目录上的build.gradle 现在看起来像这样:
allprojects {
}
subprojects {
buildscript {
repositories {
maven {
url "${artifactoryUrl}/libs-release"
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10'
}
}
repositories {
maven {
url "${artifactoryUrl}/repo"
}
}
artifactory {
contextUrl = "${artifactoryUrl}"
publish {
repository {
repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to
username = "${artifactoryUser}" // The publisher user name
password = "${artifactoryPassword}" // The publisher password
}
defaults {
// Reference to Gradle publications defined in the build script.
// This is how we tell the Artifactory Plugin which artifacts should be
// published to Artifactory.
publications('mavenJava')
publishArtifacts = true
// Properties to be attached to the published artifacts.
properties = ['qa.level': 'basic', 'dev.team' : 'core']
}
}
resolve {
repoKey = 'repo'
}
}
}
【问题讨论】:
-
使用
-i或-d标志运行会得到什么?那里应该有线索。 -
我在
id看到的唯一相关消息是“在设置文件中未定义本地存储库。使用默认路径:/home/elad/.m2/repository” -
我认为你错过了
apply plugin:,请参阅我的更新答案
标签: gradle build.gradle artifactory gradlew