ソースを参照

added launch4j plugin to gradle (for exe-creation)

I. Dix 7 年 前
コミット
7d2eb9082c
1 ファイル変更67 行追加20 行削除
  1. 67 20
      build.gradle

+ 67 - 20
build.gradle

@@ -6,44 +6,60 @@
  * For more details take a look at the Java Quickstart chapter in the Gradle
  * user guide available at http://gradle.org/docs/2.2.1/userguide/tutorial_java_projects.html
  */
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'gradle.plugin.edu.sc.seis.gradle:launch4j:2.3.0'
+    }
+}
 
 
+plugins {
+    id 'edu.sc.seis.launch4j' version '2.3.0'
+}
+
 // Apply the java plugin to add support for Java
 apply plugin: 'java'
 apply plugin: 'application'
+apply plugin: 'edu.sc.seis.launch4j'
+
 
 version = '1.0'
 
 mainClassName = 'ui.view.Main'
+def projectName = 'Cyber Physical Systems'
+def mainClass = 'ui.view.Main'
 
 // the fatJar includes all dependencies (all used libraries)
-task fatJar(type:Jar){
-    manifest{
-        attributes 'Implmenetation-Title': 'Cyber Physical Systems',
+task fatJar(type: Jar) {
+    manifest {
+        attributes 'Implmenetation-Title': projectName,
                 'Implementation-Version': version,
-                'Main-Class': 'ui.view.Main'
+                'Main-Class': mainClass
     }
-    baseName = project.name + '-all'
+    baseName = projectName + '-all'
     from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
     with jar
 }
 
 jar {
-
     manifest {
-        attributes 'Main-Class': 'ui.view.Main'
+        attributes 'Main-Class': mainClass
     }
+    baseName = projectName
 }
 
 sourceSets {
-    test{
-		java{
-			srcDirs = ["src/tests"]
-		}
-		resources{
-			srcDir 'res'
-		}
-	}
+    test {
+        java {
+            srcDirs = ["src/tests"]
+        }
+        resources {
+            srcDir 'res'
+        }
+    }
     main {
         java {
             srcDir 'src'
@@ -55,14 +71,45 @@ sourceSets {
 }
 
 repositories {
- mavenCentral()
+    mavenCentral()
+    jcenter()
+}
+
+dependencies {
+    compile fileTree(dir: 'jars', include: ['*.jar'])
+    compile fileTree(dir: 'jars/commons-compress-1.13', include: ['*.jar'])
+    testCompile group: 'junit', name: 'junit', version: '4.+'
 }
 
- dependencies {   
-       compile fileTree(dir: 'jars', include: ['*.jar'])
-       compile fileTree(dir: 'jars/commons-compress-1.13', include: ['*.jar'])
-       testCompile group: 'junit', name: 'junit', version: '4.+'
+
+// execute by command-line with 'gradlew clean jar createAllExecutables -Pl4j-debug --stacktrace'
+// then add jre8-distribution to folder 'jre8' in same directory
+//
+// the directory-structure afterwards should look like
+// |- praktikum-holons.exe
+// |> lib
+//   |- commons-compress-1.13.jar
+//   ...
+// |> jre8
+//   |> bin
+//   |> lib
+//   ...
+
+launch4j {
+    mainClassName='ui.view.Main'
+
+    // relative path at which the bundled JRE lies
+    bundledJrePath = 'jre8'
+//
+//    // for 64b: comment in, for 32b: leave commented out
+//    bundledJre64Bit = true
+
+    // names of output file
+    productName = projectName
+    outfile = projectName + '.exe'
 }
+
+
 /*
 // In this section you declare where to find the dependencies of your project
 repositories {