我有以下項目結構(用於一個搖籃多項目構建):Artifactory的搖籃插件拋出奇怪的轉換異常
myproj/
build.gradle
settings.gradle
fizzbuzz-client/
build.gradle
settings.gradle
src/
main/
groovy/
resources/
test/
groovy/
resources/
fizzbuzz-shared/
build.gradle
settings.gradle
src/
main/
groovy/
resources/
test/
groovy/
resources/
fizzbuzz-server/
build.gradle
settings.gradle
src/
main/
groovy/
resources/
test/
groovy/
resources/
其中myproj/build.gradle
是:
buildscript {
repositories {
maven {
url 'http://localhost:8081/artifactory/plugins-release'
credentials {
username = "admin"
password = "password"
}
name = "maven-main-cache"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
}
}
subprojects {
apply plugin: 'groovy'
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
}
在哪裏myproj/settings.gradle
是:
include ':fizzbuzz-shared'
include ':fizzbuzz-client'
//include ':fizzbuzz-service' Commented out since I have no actual code for this yet
而且其中myproj/fizzbuzz-shared/build.gradle
是:
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
version="0.0.31"
group = "mygroup"
repositories {
mavenCentral()
add buildscript.repositories.getByName("maven-main-cache")
maven {
url "http://localhost:8081/artifactory/my-snapshots"
}
}
dependencies {
// All my libs; omitted for brevity
}
artifactory {
contextUrl = "http://localhost:8081/artifactory"
publish {
repository {
repoKey = 'my-snapshots'
username = "admin"
password = "password"
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
當我瀏覽到myproj
根目錄下,並運行gradle build
,我得到:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':fizzbuzz-client'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:177)
<omitted for brevity>
Caused by: org.gradle.api.artifacts.UnknownRepositoryException: Repository with name 'maven-main-cache' not found.
at org.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.createNotFoundException(DefaultArtifactRepositoryContainer.java:168)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:192)
at org.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.getByName(DefaultArtifactRepositoryContainer.java:41)
at org.gradle.api.artifacts.ArtifactRepositoryContainer$getByName.call(Unknown Source)
盡我所能估計:
- 我的項目配置不正確(東西我的
build.gradle
文件中有一個錯誤);或 - 我沒有使用正確的構建調用(
gradle build
)。
任何有關我要去哪裏的錯誤的想法?
編輯:請注意,在建議的重複問題中,問題是由於用戶在CI服務器中配置了錯誤的Gradle,並且解決方案是在CI服務器內正確配置Gradle。就我而言,我在命令行上本地運行Gradle。因此我不認爲這是重複的。
看起來你在你的類路徑中有這個類的兩個版本 – 2014-12-05 13:18:17
Thanks @tim_yates(+1) - 但是如果我只聲明'apply plugin:「com.jfrog.artifactory」'one時間? – IAmYourFaja 2014-12-05 13:36:40
[gradle artifactory plugin]可能的重複(http://stackoverflow.com/questions/12446516/gradle-artifactory-plugin) – JBaruch 2014-12-05 14:03:15