1- apply plugin : ' java'
1+ buildscript {
2+ repositories {
3+ mavenCentral()
4+ }
5+ dependencies {
6+ classpath ' net.sf.proguard:proguard-gradle:6.0.1'
7+ }
8+ }
9+
10+ plugins {
11+ id " java"
12+ id " com.github.johnrengelman.shadow" version " 2.0.2"
13+ }
14+
15+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
16+ import proguard.gradle.ProGuardTask
17+
218
319sourceCompatibility = ' 1.8'
420[compileJava, compileTestJava]* . options* . encoding = ' UTF-8'
@@ -14,15 +30,6 @@ repositories {
1430 jcenter()
1531}
1632
17- buildscript {
18- repositories {
19- mavenCentral()
20- }
21- dependencies {
22- classpath ' net.sf.proguard:proguard-gradle:5.2.1'
23- }
24- }
25-
2633task generateJavaSources () {
2734 doLast {
2835 def source = """
@@ -53,22 +60,38 @@ task runOptimizing(dependsOn: classes, type: JavaExec) {
5360 args ' -o 9 -m -a -f program.own' . split(' ' )
5461}
5562
56- task dist (dependsOn : classes, type : Jar ) {
57- from files(sourceSets. main. output. classesDir)
58- from files(sourceSets. main. output. resourcesDir)
59- from {configurations. compile. collect {zipTree(it)}}
63+ task dist (type : ShadowJar ) {
64+ from sourceSets. main. output
65+ configurations = [project. configurations. runtime]
6066 destinationDir file(" $rootProject . projectDir /dist" )
6167
68+ exclude ' META-INF/*.DSA'
69+ exclude ' META-INF/*.RSA'
70+ exclude ' META-INF/maven/**'
71+ exclude ' LICENSE*'
72+
6273 manifest. attributes(
6374 ' Main-Class' : project. mainClass,
6475 ' Build-Date' : new Date (). format(' YYMMdd' )
6576 )
6677}
6778
68- task proguard (dependsOn : dist, type : proguard.gradle. ProGuardTask ) {
79+ task proguard (dependsOn : dist, type : ProGuardTask ) {
6980 configuration " $rootProject . projectDir /proguard.properties"
7081 injars " $rootProject . projectDir /dist/OwnLang.jar"
7182 outjars " $rootProject . projectDir /store/OwnLang.jar"
83+
84+ // Automatically handle the Java version of this build.
85+ if (System . getProperty(' java.version' ). startsWith(' 1.' )) {
86+ // Before Java 9, the runtime classes were packaged in a single jar file.
87+ libraryjars " ${ System.getProperty('java.home')} /lib/rt.jar"
88+ } else {
89+ // As of Java 9, the runtime classes are packaged in modular jmod files.
90+ def jmods = files { file(" ${ System.getProperty('java.home')} /jmods" ). listFiles() }
91+ jmods. each {
92+ libraryjars it, jarfilter : ' !**.jar' , filter : ' !module-info.class'
93+ }
94+ }
7295}
7396
7497task sandbox (dependsOn : proguard, type : Jar ) {
@@ -80,22 +103,23 @@ task sandbox(dependsOn: proguard, type: Jar) {
80103 " **/modules/java/**" , " **/modules/jdbc/**" , " **/modules/robot/**" ,
81104 " **/modules/socket/**" , " io/**" ,
82105 " **/modules/aimp/**" , " aimpremote/**" ,
83- " **/modules/downloader/**"
106+ " **/modules/downloader/**" ,
107+ " jline/**" , " org/fusesource/**" , " META-INF/native/**"
84108
85109 manifest {
86110 attributes ' Main-Class' : project. mainClass
87111 }
88112}
89113
90114dependencies {
91- compile (' io.socket:socket.io-client:0.7 .0' ) {
115+ compile (' io.socket:socket.io-client:1.0 .0' ) {
92116 exclude group : ' org.json' , module : ' json'
93117 }
94- compile ' org.json:json:20160212 '
95- compile ' org.yaml:snakeyaml:1.17 '
118+ compile ' org.json:json:20180130 '
119+ compile ' org.yaml:snakeyaml:1.20 '
96120 compile ' jline:jline:2.14.5'
97121
98- testCompile ' junit:junit:4.12'
99- testCompile ' org.openjdk.jmh:jmh-core:1.13'
100- testCompile ' org.openjdk.jmh:jmh-generator-annprocess:1.13'
122+ testImplementation ' junit:junit:4.12'
123+ testImplementation ' org.openjdk.jmh:jmh-core:1.13'
124+ testImplementation ' org.openjdk.jmh:jmh-generator-annprocess:1.13'
101125}
0 commit comments