2017-01-23 10 views
0

私は複数のプロジェクトGradleのプロジェクトに取り組んでいると、メインbuild.gradleはこのようなものです:cobertura + gradle - なぜ私はcoberturaタスクを実行できませんか?

buildscript { 
repositories { 
    mavenLocal() 
    mavenCentral() 
} 
    dependencies { 
     classpath 'net.saliman:gradle-cobertura-plugin:2.2.4' 
    } 
} 

plugins { 
    id "org.sonarqube" version "2.2.1" 
} 

apply plugin: 'groovy' 
apply plugin: 'cobertura' 

def getVersionName = { -> 
    def stdout = new ByteArrayOutputStream() 
    exec { 
     commandLine 'git', 'describe', '--tags', '--always' 
     standardOutput = stdout 
    } 
    return stdout.toString().trim() 
} 

ext { 
    springFrameworkVersion = '4.3.4.RELEASE' 
} 

subprojects { 
    apply plugin: 'eclipse' 
    apply plugin: 'idea' 
    apply plugin: 'java' 
    apply from: "${parent.projectDir.canonicalPath}/cobertura.gradle" 

    sourceCompatibility = 1.8 
    targetCompatibility = 1.8 

    repositories { 
     mavenCentral() 
    } 

    dependencies { 
     compile("org.springframework:spring-context:${springFrameworkVersion}") 

     testCompile("junit:junit:4.+") 
     testCompile("org.springframework:spring-test:${springFrameworkVersion}") 
    } 
    jar { 
     version = getVersionName() 
    } 
} 

project(':projectA') { 

} 

project(':projectB') { 
    dependencies { 
      compile project(':projectA') 
     } 
    } 

project(':projectC') { 
    dependencies { 
     compile project(':projectB') 
    } 
} 

cobertura { 
    coverageFormats = ['html', 'xml'] 
    coverageIgnoreTrivial = true 
    coverageIgnores = ['org.slf4j.Logger.*'] 
    coverageReportDir = new File("$buildDir/reports/cobertura") 
} 

しかし、私はCoberturaのタスクとGradleのラッパーを実行しようとすると、それは失敗し、コンソール出力は次のとおりです。

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':instrument'. 
> Could not resolve all dependencies for configuration ':cobertura'. 
    > Cannot resolve external dependency net.sourceforge.cobertura:cobertura:2.0.3 because no repositories are defined. 
    Required by: 
     :main-project:unspecified 

ここでは何が起こっていますか?

答えて

2

エラーメッセージのように表示されます。

ルートプロジェクトにnet.sourceforge.cobertura:cobertura:2.0.3の依存関係が宣言されています(明示的に追加されていないため、暗黙のうちにGradle coberturaプラグインが暗黙的に追加すると思います)。あなたのルートプロジェクトのために。あなたは、subprojectsクロージャのbuildscript(Gradleプラグインやものを解決するため)とすべてのサブプロジェクトのリポジトリを宣言しました。リポジトリもルートプロジェクト用に別途に定義するか、allprojectsクロージャを使用して定義してください。少なくともこの点に関しては、ビルドはうまくいくはずです。

関連する問題