Hello,
I’m in the process of moving a big ant project to gradle. So far here is the build.gradle that I got :
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
}
apply plugin: 'checkstyle'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
dependencies {
compile 'log4j:log4j:1.2.16'
compile 'de.sciss:jsyntaxpane:1.0.0'
compile 'org.jdom:jdom:1.1'
}
configurations {
// custom config of files we want to include in our jar
includeInJar
}
mainClassName = "org.contikios.cooja.Cooja"
libsDirName = '../dist'
manifest
{
attributes 'Main-Class': "org.contikios.cooja.Cooja"}
sourceSets {
main {
java {
srcDirs = ["java"]
}
resources {
srcDirs = ["config/"]
}
}
}
run {
println workingDir
// fork="yes"
maxHeapSize "512m"
main = "org.contikios.cooja.Cooja"
workingDir = "build"
}
task run_64(dependsOn: jar, type: JavaExec) {
description = "Will run the cooja simulator for 64 architecture"
// fork: yes
main = "org.contikios.cooja.Cooja"
maxHeapSize = "512m"
systemProperty "user.language", "en"
//jvmArgs "-d64", "-XX:+ShowMessageBoxOnError"
}
task run_errorbox(dependsOn: jar, type: JavaExec) {
// fork: yes
main = "org.contikios.cooja.Cooja"
maxHeapSize = "512m"
systemProperty "user.language", "en"
//
<java fork="yes" dir="${build}">
//
<jvmarg value="-XX:+ShowMessageBoxOnError"/>
//
<env key="LD_LIBRARY_PATH" value="."/>
//
</java>
}
task runprof(dependsOn: jar, type: JavaExec) {
// fork: yes
main = "org.contikios.cooja.Cooja"
jvmArgs "-agentlib:yjpagent"
}
task runfree(dependsOn: jar, type: JavaExec) {
// fork: yes
main = "org.contikios.cooja.Cooja"
maxHeapSize = "1536m"
// <arg line="${args}"/>
}
task run_bigmem(dependsOn: jar, type: JavaExec) {
// fork: yes
main = "org.contikios.cooja.Cooja"
maxHeapSize = "1536m"
}
task run_nogui(dependsOn: jar, type: JavaExec) {
// fork: yes
// <arg line="-nogui=${args}"/>
main = "org.contikios.cooja.Cooja"
maxHeapSize = "512m"
}
task run_applet(dependsOn: jar, type: JavaExec) {
//
<exec executable="appletviewer" dir="${build}">
//
<arg value="-J-Djava.security.policy=cooja.policy"/>
//
<arg value="cooja.html"/>
//
<env key="CLASSPATH" path="${build}"/>
//
</exec>
}
task export_jar(dependsOn: jar, type: JavaExec) {
// fork: yes
maxHeapSize "512m"
main "org.contikios.cooja.util.ExecuteJAR"
//
<arg file="${CSC}"/>
//
<arg file="exported.jar"/>
}
I can build my JAR just fine with that. The problem is that I can’t launch the jar that I’ve created with a command like : java -jar cooja.jar because I get the following error : aucun attribut manifest principal dans cooja.jar
What did I do wrong. The project is quite old and I’m quite new to gradle Feel free to tell me all the mistakes I did
All code is live at : http://results.sieben.fr/cooja/