简体   繁体   中英

Plugin with id 'jacoco' not found + Gradle

I'm trying to add jacoco support to my gradle project, but when I add the jacoco plugin, it gives me an error.

Here is my 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/*'
}

and when I run refresh dependencies in Eclipse, it gives me this error:

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)

Please help, thanks!

I am not quite sure which version introdueced jacoco plugin but with Gradle 2.x it for sure works. If you have a $buildDir/jacoco folder after running gradle build , you can be sure that it works. More information onhttp://www.gradle.org/docs/current/userguide/jacoco_plugin.html .

I have also got the same problem , I have set the gradle path in eclipse .It sloved for me.To set the path

Eclipse -Window->preference-type Gardle

Click on folder radio button , and set path to gradle folder located in your system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM