HardTimeWithGradle
HardTimeWithGradle

Reputation: 3

Gradle failed to apply plugin FatJar

I've downloaded a project that uses Gradle, unzipped it, opened a cmd prompt in that directory and ran gradle. I get the following:

Y:\cuchaz-enigma-853f818ee7ac>gradle build
FAILURE: Build failed with an exception.
* Where:
Build file 'Y:\cuchaz-enigma-853f818ee7ac
\build.gradle' line: 16

* What went wrong:
A problem occurred evaluating root project 'cuchaz-enigma-853f818ee7ac'.
> Failed to apply plugin [id 'fatjar']
   > Could not find method add() for arguments [fatJarPrepareFiles, class eu.app
satori.gradle.fatjar.tasks.PrepareFiles] on task set.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 6.598 secs
Y:\cuchaz-enigma-853f818ee7ac>

Here is the Build.Gradle:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "eu.appsatori:gradle-fatjar-plugin:0.2-rc1"
        classpath "net.sf.proguard:proguard-gradle:5.0"
    }
}

apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "fatjar"

sourceCompatibility = 1.7
targetCompatibility = 1.7

group = "com.cuchazinteractive"
archivesBaseName = "enigma"
version = "0.5.1b"

sourceSets {
    main {
        java {
            srcDir "src"
        }
        resources {
            srcDir "conf"
        }
    }
    test {
        java {
            srcDir "test"
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree( dir: "libs", include: "*.jar" )
    compile "de.sciss:jsyntaxpane:1.0.0"
    compile "com.google.guava:guava:17.0"
    compile "org.javassist:javassist:3.18.1-GA"

    testCompile "junit:junit:4.11"
    testCompile "org.hamcrest:hamcrest-all:1.3"
}

fatJar {
    from( "." ) {
        include( "*.txt" )
    }
    manifest {
        attributes(
            "Title": archivesBaseName,
            "Manifest-Version": "1.0",
            "Version": version,
            "Main-Class" : "cuchaz.enigma.Main"
        )
    }
}

task jarLoneClass( type: Jar ) {
    from( sourceSets.test.output ) {
        include( "cuchaz/enigma/inputs/Keep.class" )
        include( "cuchaz/enigma/inputs/loneClass/**" )
    }
    archiveName( "testLoneClass.jar" )
}

task jarInheritanceTree( type: Jar ) {
    from( sourceSets.test.output ) {
        include( "cuchaz/enigma/inputs/Keep.class" )
        include( "cuchaz/enigma/inputs/inheritanceTree/**" )
    }
    archiveName( "testInheritanceTree.jar" )
}

task jarConstructors( type: Jar ) {
    from( sourceSets.test.output ) {
        include( "cuchaz/enigma/inputs/Keep.class" )
        include( "cuchaz/enigma/inputs/constructors/**" )
    }
    archiveName( "testConstructors.jar" )
}

task jarInnerClasses( type: Jar ) {
    from( sourceSets.test.output ) {
        include( "cuchaz/enigma/inputs/Keep.class" )
        include( "cuchaz/enigma/inputs/innerClasses/**" )
    }
    archiveName( "testInnerClasses.jar" )
}

tasks.withType( proguard.gradle.ProGuardTask ) {
    libraryjars( "${System.getProperty('java.home')}/lib/rt.jar" )
    overloadaggressively
    repackageclasses
    allowaccessmodification
    dontoptimize
    dontshrink
    keep( "class cuchaz.enigma.inputs.Keep" )
}

task obfLoneClass( type: proguard.gradle.ProGuardTask, dependsOn: jarLoneClass ) {
    def name = "LoneClass"
    injars( "build/libs/test${name}.jar" )
    outjars( "build/libs/test${name}.obf.jar" )
}

task obfInheritanceTree( type: proguard.gradle.ProGuardTask, dependsOn: jarInheritanceTree ) {
    def name = "InheritanceTree"
    injars( "build/libs/test${name}.jar" )
    outjars( "build/libs/test${name}.obf.jar" )
}

task obfConstructors( type: proguard.gradle.ProGuardTask, dependsOn: jarConstructors ) {
    def name = "Constructors"
    injars( "build/libs/test${name}.jar" )
    outjars( "build/libs/test${name}.obf.jar" )
}

task obfInnerClasses( type: proguard.gradle.ProGuardTask, dependsOn: jarInnerClasses ) {
    def name = "InnerClasses"
    injars( "build/libs/test${name}.jar" )
    outjars( "build/libs/test${name}.obf.jar" )
}

task obfTestCases( dependsOn: tasks.withType( proguard.gradle.ProGuardTask ) )

I've downloaded the Jar, put it in both Lib and Plugins, made sure the file also exists in my Gradle Cache, but it still errors. Any ideas? Thanks.

Upvotes: 0

Views: 5589

Answers (1)

Benjamin Muschko
Benjamin Muschko

Reputation: 33426

Looks like the identifier for the plugin has changed. I'd also recommend using the latest version of that plugin. Please note that version 0.3 is only available on JCenter and not in Maven Central.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "eu.appsatori:gradle-fatjar-plugin:0.3"
    }
}

apply plugin: 'eu.appsatori.fatjar'

Upvotes: 1

Related Questions