Search code examples
javaeclipseintellij-ideainria-spoon

Execution failed for task ':spoon'. > org/eclipse/jdt/internal/core/util/CommentRecorderParser


I am new to Spoon. I just know that using Spoon we can analyze and transform source code. I want to use Spoon in my gradle project. I am using IntelliJ IDEA for this project. I am getting this error when I tried to build the project.

Error:

Execution failed for task ':spoon'.
> org/eclipse/jdt/internal/core/util/CommentRecorderParser

My build.gradle file is as follows :

group 'com.X'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'fr.inria.gforge.spoon:spoon-core:5.8.0'
}

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath group: 'fr.inria.gforge.spoon',
                name: 'spoon-gradle-plugin',
                version:'1.1'
    }
}

apply plugin: 'java'
apply plugin: 'spoon'

jar {
    manifest {
        attributes(
                'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
                'Main-Class': 'Main'
        )
    }
}

I got this when built with --stacktrace

Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/core/util/CommentRecorderParser

Please help me fix this. Thanks in advance


Solution

  • This happens with spoon because it's failing to find org/eclipse/jdt/internal/core/util/CommentRecorderParser class in the classpath. Adding the following to your buildscript dependencies should do the trick:

    buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath group: 'fr.inria.gforge.spoon',
                name: 'spoon-gradle-plugin',
                version:'1.1'
        classpath group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.core', version: '3.12.2'
    }
    

    }