带有id' jacoco'的插件找不到+ Gradle

时间:2014-03-26 11:25:45

标签: java eclipse groovy gradle jacoco

我正在尝试将jacoco支持添加到我的gradle项目中,但是当我添加jacoco插件时,它会给我一个错误。

这是我的gradle.build

task wrapper(type: Wrapper) { gradleVersion = '1.11' }
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'application'
apply plugin: 'project-report'
apply plugin: 'jacoco'

eclipse {
  classpath { downloadSources=true }
}

eclipse.classpath.file {
  // Classpath entry for Eclipse which changes the order of classpathentries; otherwise no sources for 3rd party jars are shown
  withXml { xml ->
    def node = xml.asNode()
    node.remove( node.find { it.@path == 'org.eclipse.jst.j2ee.internal.web.container' } )
    node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true'])
  }
}

tasks.withType(Compile) { options.encoding = 'UTF-8' }

repositories {
  mavenCentral()
  mavenLocal()
}

dependencies {
  providedCompile 'javax.servlet:servlet-api:2.5'
  runtime 'javax.servlet:jstl:1.1.2'

  compile 'org.springframework.batch:spring-batch-core:2.2.5.RELEASE'
  compile 'org.springframework:spring-webmvc:4.0.2.RELEASE'
  compile 'org.springframework:spring-jdbc:4.0.2.RELEASE'
  compile 'org.springframework:spring-orm:4.0.2.RELEASE'
  compile 'org.springframework.data:spring-data-mongodb:1.4.0.RELEASE'
  compile 'org.springframework.security:spring-security-web:3.2.1.RELEASE'
  compile 'org.springframework.security:spring-security-config:3.2.1.RELEASE'

  compile 'org.slf4j:slf4j-simple:1.6.1'
  compile 'org.codehaus.groovy:groovy-all:2.2.0'
  compile 'org.mongodb:mongo-java-driver:2.11.4'

  compile 'c3p0:c3p0:0.9.1.2'
  compile 'org.hibernate:hibernate-core:4.3.4.Final'
  compile 'org.hibernate:hibernate-ehcache:4.3.4.Final'
  compile 'org.hsqldb:hsqldb:2.0.0'

  compile 'com.google.guava:guava:16.0'
  compile 'commons-io:commons-io:2.4'

  compile 'com.google.code.gson:gson:2.2.4'
  compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
  compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

  testCompile 'junit:junit:4.11'
  testCompile 'commons-collections:commons-collections:3.2'
  testCompile 'org.springframework:spring-test:4.0.2.RELEASE'
  testCompile 'org.codehaus.groovy:groovy-all:2.2.0'
  testCompile 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:1.35'
  testCompile 'org.springframework.batch:spring-batch-test:2.2.5.RELEASE'

  compile localGroovy()
}

test {
  testLogging { // Show that tests are run in the command-line output
    events 'started', 'passed' }
  exclude 'com/bambilon/All*'
  exclude 'com/bambilon/**/slow/*'
}

当我在Eclipse中运行刷新依赖项时,它给了我这个错误:

Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'jacoco' not found.
    at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:86)
    at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.getTypeForId(DefaultProjectsPluginContainer.java:102)
    at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
    at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:846)
    at org.gradle.api.Project$apply.call(Unknown Source)
    at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
    at org.gradle.api.Script$apply.callCurrent(Unknown Source)

请帮助,谢谢!

2 个答案:

答案 0 :(得分:2)

我不太确定哪个版本引入了jacoco插件,但使用Gradle 2.x肯定有效。如果您在运行$buildDir/jacoco后有gradle build文件夹,则可以确定它有效。有关http://www.gradle.org/docs/current/userguide/jacoco_plugin.html的更多信息。

答案 1 :(得分:0)

我也遇到了同样的问题,我在日食中设置了gradle路径。它为我解决了。设置路径

  

Eclipse -Window->偏好型Gardle

单击文件夹单选按钮,然后将路径设置为系统中的gradle文件夹。