diff --git a/build.gradle b/build.gradle index 5e72a55..323da22 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,20 @@ -apply plugin: 'java' +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'net.sf.proguard:proguard-gradle:6.0.1' + } +} + +plugins { + id "java" + id "com.github.johnrengelman.shadow" version "2.0.2" +} + +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import proguard.gradle.ProGuardTask + sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' @@ -14,15 +30,6 @@ repositories { jcenter() } -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'net.sf.proguard:proguard-gradle:5.2.1' - } -} - task generateJavaSources() { doLast { def source = """ @@ -53,22 +60,38 @@ task runOptimizing(dependsOn: classes, type: JavaExec) { args '-o 9 -m -a -f program.own'.split(' ') } -task dist(dependsOn: classes, type: Jar) { - from files(sourceSets.main.output.classesDir) - from files(sourceSets.main.output.resourcesDir) - from {configurations.compile.collect {zipTree(it)}} +task dist(type: ShadowJar) { + from sourceSets.main.output + configurations = [project.configurations.runtime] destinationDir file("$rootProject.projectDir/dist") + exclude 'META-INF/*.DSA' + exclude 'META-INF/*.RSA' + exclude 'META-INF/maven/**' + exclude 'LICENSE*' + manifest.attributes( 'Main-Class': project.mainClass, 'Build-Date': new Date().format('YYMMdd') ) } -task proguard(dependsOn: dist, type: proguard.gradle.ProGuardTask) { +task proguard(dependsOn: dist, type: ProGuardTask) { configuration "$rootProject.projectDir/proguard.properties" injars "$rootProject.projectDir/dist/OwnLang.jar" outjars "$rootProject.projectDir/store/OwnLang.jar" + + // Automatically handle the Java version of this build. + if (System.getProperty('java.version').startsWith('1.')) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + def jmods = files { file("${System.getProperty('java.home')}/jmods").listFiles() } + jmods.each { + libraryjars it, jarfilter: '!**.jar', filter: '!module-info.class' + } + } } task sandbox(dependsOn: proguard, type: Jar) { @@ -80,7 +103,8 @@ task sandbox(dependsOn: proguard, type: Jar) { "**/modules/java/**", "**/modules/jdbc/**", "**/modules/robot/**", "**/modules/socket/**", "io/**", "**/modules/aimp/**", "aimpremote/**", - "**/modules/downloader/**" + "**/modules/downloader/**", + "jline/**", "org/fusesource/**", "META-INF/native/**" manifest { attributes 'Main-Class': project.mainClass @@ -88,14 +112,14 @@ task sandbox(dependsOn: proguard, type: Jar) { } dependencies { - compile ('io.socket:socket.io-client:0.7.0') { + compile ('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } - compile 'org.json:json:20160212' - compile 'org.yaml:snakeyaml:1.17' + compile 'org.json:json:20180130' + compile 'org.yaml:snakeyaml:1.20' compile 'jline:jline:2.14.5' - testCompile 'junit:junit:4.12' - testCompile 'org.openjdk.jmh:jmh-core:1.13' - testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.13' + testImplementation 'junit:junit:4.12' + testImplementation 'org.openjdk.jmh:jmh-core:1.13' + testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.13' } diff --git a/proguard.properties b/proguard.properties index be30bc3..ca1ee69 100644 --- a/proguard.properties +++ b/proguard.properties @@ -1,6 +1,4 @@ -target 1.8 --libraryjars /lib/rt.jar --libraryjars /lib/ext/jfxrt.jar -printmapping store/out.map -printusage store/out.txt @@ -9,6 +7,7 @@ -dontwarn okio.** -dontwarn okhttp3.** +-dontwarn org.fusesource.jansi.internal.** -keepclasseswithmembers public class * { public static void main(java.lang.String[]); diff --git a/src/main/java/com/annimon/ownlang/Main.java b/src/main/java/com/annimon/ownlang/Main.java index 9edd6b0..25cae18 100644 --- a/src/main/java/com/annimon/ownlang/Main.java +++ b/src/main/java/com/annimon/ownlang/Main.java @@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit; */ public final class Main { - public static final String VERSION = "1.3.0_" + Gen.BUILD_DATE; + public static final String VERSION = "1.3.1_" + Gen.BUILD_DATE; private static String[] ownlangArgs = new String[0];