我已经下载了一个使用Gradle的项目,解压缩它,在该目录中打开了一个cmd提示符并运行了gradle。我得到以下内容:
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>
这是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 ) )
我已经下载了Jar,将它放在Lib和Plugins中,确保该文件也存在于我的Gradle Cache中,但它仍然存在错误。有任何想法吗?感谢。
答案 0 :(得分:1)
看起来插件的标识符已更改。我还建议使用该插件的最新版本。请注意,版本0.3仅适用于JCenter,而不适用于Maven Central。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "eu.appsatori:gradle-fatjar-plugin:0.3"
}
}
apply plugin: 'eu.appsatori.fatjar'