I tried to create a fatJar with Gradle. I found a good example on this site that worked well for me in another project. In my recent project an error occurs during the 'gradlew build' task, namely the following:
FAILURE: Build failed with an exception.
Where: Build file 'D:\dev\MarkPublished\build.gradle' line: 40
What went wrong: A problem occurred evaluating root project 'markpublished'. Could not find method Attributes() for arguments [{Implementation->Title=Gradle Jar File, Implementation-Version=1.0-Snapshot, Main-Class=path.classname}] on root project 'myproject'.
This is my (shortened) 'build.gradle'-file:
plugins {
id 'java'
id 'idea'
}
group 'mygroup'
version '1.0-Snapshot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
idea {
...
}
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
repositories {
...
}
dependencies {
...
}
task fatJar(type: Jar) {
manifest {
Attributes ('Implementation-Title': 'Gradle Jar File',
'Implementation-Version': version,
'Main-Class': 'path.classname')
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with Jar
}
I use Win7 and IntelliJ Idea 14.1.5.
Honestly, I absolutely have no clue and I wouldn't ask here if it didn't already work for me in another project.
Try to make a fatJar task as:
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File',
'Implementation-Version': version,
'Main-Class': 'path.classname'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with Jar
}
Attributes must be in lowercase, like attributes
.