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
- id " org.sonarqube" version " 2.6.2"
14
- }
15
-
16
- import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
17
- import proguard.gradle.ProGuardTask
18
-
19
-
20
- sourceCompatibility = ' 1.8'
21
- [compileJava, compileTestJava]* . options* . encoding = ' UTF-8'
22
-
23
- if (! hasProperty(' mainClass' )) {
24
- ext. mainClass = ' com.annimon.ownlang.Main'
25
- }
26
-
27
- ext. generatedJavaDir = " ${ rootProject.projectDir} /src/main/generatedJava"
28
- sourceSets. main. java. srcDirs + = project. generatedJavaDir
29
-
30
- repositories {
31
- jcenter()
32
- }
33
-
34
- task generateJavaSources () {
35
- doLast {
36
- def source = """
37
- package com.annimon.ownlang;
38
- class Gen {
39
- private Gen() {}
40
- public static final String BUILD_DATE = "${ new Date().format('YYMMdd')} ";
41
- }
42
- """
43
- def genFile = new File (" ${ project.generatedJavaDir} /com/annimon/ownlang/Gen.java" )
44
- genFile. getParentFile(). mkdirs()
45
- genFile. write(source)
46
- }
47
- }
48
- compileJava. dependsOn(generateJavaSources)
49
-
50
- task run (dependsOn : classes, type : JavaExec ) {
51
- main = project. mainClass
52
- classpath = sourceSets. main. runtimeClasspath
53
- standardInput = System . in
54
- ignoreExitValue = true
55
- }
56
-
57
- task runOptimizing (dependsOn : classes, type : JavaExec ) {
58
- main = project. mainClass
59
- classpath = sourceSets. main. runtimeClasspath
60
- ignoreExitValue = true
61
- // args '-o 9 -m -a -f examples/game/minesweeper.own'.split(' ')
62
- args ' -o 9 -m -a -f program.own' . split(' ' )
63
- }
64
-
65
- task dist (type : ShadowJar ) {
66
- from sourceSets. main. output
67
- configurations = [project. configurations. runtime]
68
- destinationDir file(" $rootProject . projectDir /dist" )
69
-
70
- exclude ' META-INF/*.DSA'
71
- exclude ' META-INF/*.RSA'
72
- exclude ' META-INF/maven/**'
73
- exclude ' LICENSE*'
74
-
75
- manifest. attributes(
76
- ' Main-Class' : project. mainClass,
77
- ' Build-Date' : new Date (). format(' YYMMdd' )
78
- )
79
- }
80
-
81
- task proguard (dependsOn : dist, type : ProGuardTask ) {
82
- configuration " $rootProject . projectDir /proguard.properties"
83
- injars " $rootProject . projectDir /dist/OwnLang.jar"
84
- outjars " $rootProject . projectDir /store/OwnLang.jar"
85
-
86
- // Automatically handle the Java version of this build.
87
- if (System . getProperty(' java.version' ). startsWith(' 1.' )) {
88
- // Before Java 9, the runtime classes were packaged in a single jar file.
89
- libraryjars " ${ System.getProperty('java.home')} /lib/rt.jar"
90
- } else {
91
- // As of Java 9, the runtime classes are packaged in modular jmod files.
92
- def jmods = files { file(" ${ System.getProperty('java.home')} /jmods" ). listFiles() }
93
- jmods. each {
94
- libraryjars it, jarfilter : ' !**.jar' , filter : ' !module-info.class'
95
- }
96
- }
97
- }
98
-
99
- task sandbox (dependsOn : proguard, type : Jar ) {
100
- from zipTree(" $rootProject . projectDir /store/OwnLang.jar" )
101
- libsDirName = " $rootProject . projectDir /store"
102
- appendix = " Sandbox"
103
-
104
- exclude " **/modules/canvas/**" , " **/modules/canvasfx/**" , " **/modules/forms/**" ,
105
- " **/modules/java/**" , " **/modules/jdbc/**" , " **/modules/robot/**" ,
106
- " **/modules/socket/**" , " io/**" ,
107
- " **/modules/aimp/**" , " aimpremote/**" ,
108
- " **/modules/downloader/**" ,
109
- " **/modules/zip/**" , " **/modules/gzip/**" ,
110
- " jline/**" , " org/fusesource/**" , " META-INF/native/**"
111
-
112
- manifest {
113
- attributes ' Main-Class' : project. mainClass
114
- }
115
- }
116
-
117
- dependencies {
118
- compile (' io.socket:socket.io-client:1.0.0' ) {
119
- exclude group : ' org.json' , module : ' json'
120
- }
121
- compile ' org.json:json:20180130'
122
- compile ' org.yaml:snakeyaml:1.20'
123
- compile ' jline:jline:2.14.5'
124
-
125
- testImplementation ' junit:junit:4.12'
126
- testImplementation ' org.openjdk.jmh:jmh-core:1.13'
127
- testImplementation ' org.openjdk.jmh:jmh-generator-annprocess:1.13'
128
- }
129
-
130
- sonarqube {
131
- properties {
132
- property " sonar.projectName" , " Own-Programming-Language-Tutorial"
133
- property " sonar.projectKey" , " aNNiMON_Own-Programming-Language-Tutorial"
134
- property " sonar.host.url" , " https://sonarcloud.io"
135
- }
136
- }
137
-
138
- test {
139
- testLogging {
140
- events " passed" , " skipped" , " failed"
141
- exceptionFormat " full"
142
- }
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
+ id " org.sonarqube" version " 2.6.2"
14
+ }
15
+
16
+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
17
+ import proguard.gradle.ProGuardTask
18
+
19
+
20
+ sourceCompatibility = ' 1.8'
21
+ [compileJava, compileTestJava]* . options* . encoding = ' UTF-8'
22
+
23
+ if (! hasProperty(' mainClass' )) {
24
+ ext. mainClass = ' com.annimon.ownlang.Main'
25
+ }
26
+
27
+ ext. generatedJavaDir = " ${ rootProject.projectDir} /src/main/generatedJava"
28
+ sourceSets. main. java. srcDirs + = project. generatedJavaDir
29
+
30
+ repositories {
31
+ jcenter()
32
+ }
33
+
34
+ task generateJavaSources () {
35
+ doLast {
36
+ def source = """
37
+ package com.annimon.ownlang;
38
+ class Gen {
39
+ private Gen() {}
40
+ public static final String BUILD_DATE = "${ new Date().format('YYMMdd')} ";
41
+ }
42
+ """
43
+ def genFile = new File (" ${ project.generatedJavaDir} /com/annimon/ownlang/Gen.java" )
44
+ genFile. getParentFile(). mkdirs()
45
+ genFile. write(source)
46
+ }
47
+ }
48
+ compileJava. dependsOn(generateJavaSources)
49
+
50
+ task run (dependsOn : classes, type : JavaExec ) {
51
+ main = project. mainClass
52
+ classpath = sourceSets. main. runtimeClasspath
53
+ standardInput = System . in
54
+ ignoreExitValue = true
55
+ }
56
+
57
+ task runOptimizing (dependsOn : classes, type : JavaExec ) {
58
+ main = project. mainClass
59
+ classpath = sourceSets. main. runtimeClasspath
60
+ ignoreExitValue = true
61
+ // args '-o 9 -m -a -f examples/game/minesweeper.own'.split(' ')
62
+ args ' -o 9 -m -a -f program.own' . split(' ' )
63
+ }
64
+
65
+ task dist (type : ShadowJar ) {
66
+ from sourceSets. main. output
67
+ configurations = [project. configurations. runtime]
68
+ destinationDir file(" $rootProject . projectDir /dist" )
69
+
70
+ exclude ' META-INF/*.DSA'
71
+ exclude ' META-INF/*.RSA'
72
+ exclude ' META-INF/maven/**'
73
+ exclude ' LICENSE*'
74
+
75
+ manifest. attributes(
76
+ ' Main-Class' : project. mainClass,
77
+ ' Build-Date' : new Date (). format(' YYMMdd' )
78
+ )
79
+ }
80
+
81
+ task proguard (dependsOn : dist, type : ProGuardTask ) {
82
+ configuration " $rootProject . projectDir /proguard.properties"
83
+ injars " $rootProject . projectDir /dist/OwnLang.jar"
84
+ outjars " $rootProject . projectDir /store/OwnLang.jar"
85
+
86
+ // Automatically handle the Java version of this build.
87
+ if (System . getProperty(' java.version' ). startsWith(' 1.' )) {
88
+ // Before Java 9, the runtime classes were packaged in a single jar file.
89
+ libraryjars " ${ System.getProperty('java.home')} /lib/rt.jar"
90
+ } else {
91
+ // As of Java 9, the runtime classes are packaged in modular jmod files.
92
+ def jmods = files { file(" ${ System.getProperty('java.home')} /jmods" ). listFiles() }
93
+ jmods. each {
94
+ libraryjars it, jarfilter : ' !**.jar' , filter : ' !module-info.class'
95
+ }
96
+ }
97
+ }
98
+
99
+ task sandbox (dependsOn : proguard, type : Jar ) {
100
+ from zipTree(" $rootProject . projectDir /store/OwnLang.jar" )
101
+ libsDirName = " $rootProject . projectDir /store"
102
+ appendix = " Sandbox"
103
+
104
+ exclude " **/modules/canvas/**" , " **/modules/canvasfx/**" , " **/modules/forms/**" ,
105
+ " **/modules/java/**" , " **/modules/jdbc/**" , " **/modules/robot/**" ,
106
+ " **/modules/okhttp/**" ,
107
+ " **/modules/socket/**" , " io/**" ,
108
+ " **/modules/aimp/**" , " aimpremote/**" ,
109
+ " **/modules/downloader/**" ,
110
+ " **/modules/zip/**" , " **/modules/gzip/**" ,
111
+ " jline/**" , " org/fusesource/**" , " META-INF/native/**"
112
+
113
+ manifest {
114
+ attributes ' Main-Class' : project. mainClass
115
+ }
116
+ }
117
+
118
+ dependencies {
119
+ compile (' io.socket:socket.io-client:1.0.0' ) {
120
+ exclude group : ' org.json' , module : ' json'
121
+ }
122
+ compile ' org.json:json:20180130'
123
+ compile ' org.yaml:snakeyaml:1.20'
124
+ compile ' jline:jline:2.14.5'
125
+
126
+ testImplementation ' junit:junit:4.12'
127
+ testImplementation ' org.openjdk.jmh:jmh-core:1.13'
128
+ testImplementation ' org.openjdk.jmh:jmh-generator-annprocess:1.13'
129
+ }
130
+
131
+ sonarqube {
132
+ properties {
133
+ property " sonar.projectName" , " Own-Programming-Language-Tutorial"
134
+ property " sonar.projectKey" , " aNNiMON_Own-Programming-Language-Tutorial"
135
+ property " sonar.host.url" , " https://sonarcloud.io"
136
+ }
137
+ }
138
+
139
+ test {
140
+ testLogging {
141
+ events " passed" , " skipped" , " failed"
142
+ exceptionFormat " full"
143
+ }
143
144
}
0 commit comments