我是 gradle 新手,想从中访问我的工件存储库。如果我将所有配置放入一个构建脚本中,则构建成功。以下是我的 build.gradle 的相关部分:
allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'artifactory'
}
// ...
buildscript {
repositories {
maven {
url 'http://repo.jfrog.org/artifactory/gradle-plugins'
}
maven {
url artifactory_contextUrl + 'plugins-release'
credentials {
username = artifactory_user
password = artifactory_password
}
}
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
}
}
artifactory {
contextUrl = artifactory_contextUrl
publish {
repository {
repoKey = 'libs-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
username = artifactory_user
password = artifactory_password
maven = true
}
}
}
dependencies {
// My dependencies ...
}
// Rest of the build script ...
现在,我想将工件部分提取到单独的 gradle 脚本中,以便更好地组织。这就是构建出错的地方。非常令人惊讶的是,即使我将 build.gradle 复制到 foo.gradle,并将 build.gradle 更改为仅包含单行,我也会收到以下错误
apply from: 'foo.gradle'
错误是
FAILURE: Build failed with an exception.
* Where:
Script '/path/to/my/project/foo.gradle' line: 5
* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'artifactory' not found.
如果这不是错误,任何人都可以解释 gradle 的这种行为apply from
并提出解决方案吗?
谢谢