-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
686 lines (558 loc) · 27.7 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
/*
* Copyright 2016-2020 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
// Freemaker FMPP (http://fmpp.sourceforge.net/, Apache 2.0)
classpath group: 'net.sourceforge.fmpp', name: 'fmpp', version: '0.9.16'
// JavaCC (https://github.com/johnmartel/javaccPlugin, MIT License)
classpath group: 'ca.coglinc', name: 'javacc-gradle-plugin', version: '2.4.0'
// Shadowing; used to make a fat jar (https://github.com/johnrengelman/shadow, Apache 2.0)
classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: '5.2.0'
// Lombok (https://github.com/franzbecker/gradle-lombok, Apache 2.0)
classpath group: 'io.franzbecker', name: 'gradle-lombok', version: '4.0.0'
// SonarQube (https://plugins.gradle.org/plugin/org.sonarqube, GNU LGPL 3)
classpath group: 'org.sonarsource.scanner.gradle', name: 'sonarqube-gradle-plugin', version: '2.8.0.1969'
// Packr (https://github.com/hendraanggrian/packr-gradle-plugin, Apache 2.0)
classpath group: 'com.hendraanggrian', name: 'packr-gradle-plugin', version: '0.2'
// The Badass Runtime Plugin (https://github.com/beryx/badass-runtime-plugin/, Apache 2.0)
classpath group: 'gradle.plugin.org.beryx', name: 'badass-runtime-plugin', version: '1.8.0'
// Gradle Download Task (https://github.com/michel-kraemer/gradle-download-task, Apache 2.0)
classpath group: 'de.undercouch', name: 'gradle-download-task', version: '4.0.4'
// Gradle Test Logger Plugin (https://github.com/radarsh/gradle-test-logger-plugin, Apache 2.0)
classpath group: 'com.adarshr', name: 'gradle-test-logger-plugin', version: '2.0.0'
}
ant.taskdef(name: 'fmpp', classname: 'fmpp.tools.AntTask', classpath: buildscript.configurations.classpath.asPath)
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'ca.coglinc.javacc'
apply plugin: 'com.adarshr.test-logger'
apply plugin: 'com.hendraanggrian.packr'
apply plugin: 'de.undercouch.download'
apply plugin: 'io.franzbecker.gradle-lombok'
apply plugin: 'org.beryx.runtime'
apply plugin: 'org.sonarqube'
rootProject.version_build = rootProject.hasProperty('version_build') && !rootProject.property('version_build').toString().trim().isEmpty() ? rootProject.property('version_build').toString().trim().toLowerCase() : ''
version = "${rootProject.version_major}.${rootProject.version_minor}.${rootProject.version_patch}" + (rootProject.hasProperty('isRelease') ? '' : '-SNAPSHOT')
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
def resourcesSrcDir = 'src/main/resources'
def classesDir = "${project.buildDir}/classes"
def distributionsDir = "${project.buildDir}/distributions"
def docsDir = "${project.buildDir}/docs"
def extractedDir = "${project.buildDir}/extracted"
def generatedDir = "${project.buildDir}/generated"
def resourcesBuildDir = "${project.buildDir}/resources"
sourceSets {
main {
java {
srcDir "${generatedDir}/main/javacc"
}
resources {
srcDir 'src/dist/conf'
}
}
}
configurations {
fmppTemplates { transitive = false }
standaloneImplementation.extendsFrom implementation
pdbModuleImplementation.extendsFrom implementation
compileClasspath.extendsFrom compileOnly, implementation, standaloneImplementation, pdbModuleImplementation
runtimeClasspath.extendsFrom implementation, runtimeOnly, runtime, standaloneImplementation
testCompileClasspath.extendsFrom testCompileOnly, testImplementation, standaloneImplementation, pdbModuleImplementation
testRuntimeClasspath.extendsFrom testRuntimeOnly, testRuntime, testImplementation, standaloneImplementation
all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://nexus.dmi.unibas.ch/repository/maven2/' }
}
def calciteVersion = '1.22.0' /* KEEP THIS VERSION */
def avaticaVersion = '1.16.1-POLYPHENY-SNAPSHOT' /* Requires the repository https://nexus.dmi.unibas.ch/repository/maven2/ */
def log4jVersion = '2.12.1'
dependencies {
//
// ///// //// /// // /
// POLYPHENY-DB MODULE
//
// ///// //// /// // /
// STANDALONE DDBMS
// Apache Calcite Avatica (Apache 2.0)
standaloneImplementation group: 'org.apache.calcite.avatica', name: 'avatica-core', version: avaticaVersion, changing: true
standaloneImplementation group: 'org.apache.calcite.avatica', name: 'avatica-server', version: avaticaVersion, changing: true
// Apache Calcite (Apache 2.0)
standaloneImplementation group: 'org.apache.calcite', name: 'calcite-core', version: calciteVersion
standaloneImplementation group: 'org.apache.calcite', name: 'calcite-server', version: calciteVersion
// HSQLDB (BSD)
standaloneImplementation group: 'org.hsqldb', name: 'hsqldb', version: '2.5.0'
// Log4j (Apache 2.0)
standaloneImplementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: log4jVersion
standaloneImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4jVersion
standaloneImplementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: log4jVersion
standaloneImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4jVersion
// CLI parsing (Apache 2.0)
standaloneImplementation group: 'com.github.rvesse', name: 'airline', version: '2.7.2'
//
// ///// //// /// // /
// COMPILE (Required for both runtime environments)
//
// Apache Commons (Apache 2.0)
implementation group: 'commons-transaction', name: 'commons-transaction', version: '1.2'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.14'
// Google GUAVA (Apache 2.0)
implementation group: 'com.google.guava', name: 'guava', version: '29.0-jre'
// Byte Units (Apache 2.0)
implementation group: 'com.jakewharton.byteunits', name: 'byteunits', version: '0.9.1'
// Cluster Management, JGroups (Apache 2.0)
implementation group: 'org.jgroups', name: 'jgroups', version: '4.0.20.Final' /* KEEP THIS VERSION */
// Metrics, Micrometer Application Metrics (Apache 2.0)
implementation group: 'io.micrometer', name: 'micrometer-core', version: '1.5.1'
implementation group: 'io.micrometer', name: 'micrometer-registry-influx', version: '1.5.1'
implementation group: 'io.micrometer', name: 'micrometer-registry-jmx', version: '1.5.1'
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
// Typesafe Config - Configuration library for JVM languages (Apache 2.0)
implementation group: 'com.typesafe', name: 'config', version: '1.4.0'
// Vavr - object-functional library (Apache 2.0)
implementation group: 'io.vavr', name: 'vavr', version: '0.10.2'
//
// ///// //// /// // /
// TESTING (Eclipse Public License 2.0)
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.6.2'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.2'
// Apache Calcite (Apache 2.0)
testImplementation group: 'org.apache.calcite', name: 'calcite-core', version: calciteVersion
testImplementation group: 'org.apache.calcite', name: 'calcite-core', version: calciteVersion, classifier: 'tests'
//
testImplementation group: 'org.polypheny', name: 'polypheny-jdbc-driver', version: '1.4-SNAPSHOT', changing: true /* Requires the repository https://nexus.dmi.unibas.ch/repository/maven2/ */
//
// ///// //// /// // /
// Freemarker Template Sources, Apache Calcite (Apache 2.0)
fmppTemplates group: 'org.apache.calcite', name: 'calcite-core', version: calciteVersion
//
// ///// //// /// // /
// JAVACC (BSD 2-clause)
javacc group: 'net.java.dev.javacc', name: 'javacc', version: '4.0' /* KEEP THIS VERSION */
}
lombok {
// https://projectlombok.org/
version = '1.18.12'
sha256 = '49381508ecb02b3c173368436ef71b24c0d4418ad260e6cc98becbcf4b345406'
}
task fmpp(group: 'javacc') {
inputs.files(
file("${extractedDir}/main/resources/codegen/templates/Parser.jj"), // The parser template
fileTree("${resourcesSrcDir}/codegen/includes/"), // The extensions
file("${resourcesSrcDir}/codegen/config.fmpp") // Our configuration
)
outputs.dir(file("${generatedDir}/main/fmpp"))
doLast {
copy {
from zipTree(configurations.fmppTemplates.singleFile).matching {
include 'codegen/**'
}
into "${extractedDir}/main/resources/"
}
ant.fmpp configuration: "${resourcesSrcDir}/codegen/config.fmpp", sourceRoot: "${extractedDir}/main/resources/codegen/templates", outputRoot: "${generatedDir}/main/fmpp"
}
}
compileJavacc {
dependsOn fmpp
inputDirectory = file("${generatedDir}/main/fmpp/javacc")
outputDirectory = file("${generatedDir}/main/javacc")
arguments = [
LOOKAHEAD : '2', // Default: '1'
FORCE_LA_CHECK : 'false', // Default: 'false'
CHOICE_AMBIGUITY_CHECK: '2', // Default: '2'
OTHER_AMBIGUITY_CHECK : '1', // Default: '1'
]
}
jjdoc {
dependsOn fmpp
inputDirectory = file("${generatedDir}/main/fmpp/javacc")
outputDirectory = file("${docsDir}/jjdoc")
arguments = [TEXT: 'false']
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes 'Manifest-Version': '1.0'
attributes 'Copyright': 'The Polypheny Project'
attributes 'Group': rootProject.group
attributes 'Name': rootProject.name
attributes 'Version': rootProject.version
attributes 'Build': rootProject.version_build
}
exclude 'log4j2.properties', 'application.conf', 'sample-application.conf'
}
// Standalone JAR which bundles all dependencies (except the once required only for the "Polypheny-DB" context)
// DO NOT DISTRIBUTE THIS BUNDLE
task standaloneJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar, group: 'shadow', dependsOn: jar) {
description = 'Builds a standalone executable jar which includes all required dependencies.'
archiveClassifier = 'standalone'
manifest {
inheritFrom jar.manifest
attributes 'Main-Class': project.properties['mainClass']
attributes 'Class-Path': '../config/ ../plugins/ ./config/ ./plugins/'
}
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
configurations = [project.configurations.runtime]
configurations.addAll([project.configurations.standaloneImplementation])
exclude 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'application.conf'
}
// Module JAR which bundles all required dependencies to run in the "Polypheny-DB" context
// DO NOT DISTRIBUTE THIS BUNDLE
task pdbModuleJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar, group: 'shadow', dependsOn: jar) {
description = 'Builds a Polypheny-DB Module jar which includes all dependencies required for running it in the Polypheny-DB context.'
archiveClassifier = 'module'
manifest {
inheritFrom jar.manifest
attributes 'Polypheny-Artifact-Name': rootProject.name
attributes 'Polypheny-Module-Name': rootProject.name
attributes 'Polypheny-Module-Main': project.properties['moduleMainClass']
attributes 'Polypheny-Module-Type': 'component'
}
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
configurations = [project.configurations.runtime]
configurations.addAll([project.configurations.pdbModuleImplementation])
exclude 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'application.conf'
}
test {
useJUnitPlatform()
include 'org/polypheny/fram/**'
exclude 'org/polypheny/fram/standalone/StandaloneTest.class'
}
task delombok(type: io.franzbecker.gradle.lombok.task.DelombokTask, group: 'documentation', dependsOn: compileJava) {
ext.outputDir = file("${project.buildDir}/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, '-d', outputDir)
}
}
javadoc {
dependsOn delombok
source = delombok.outputDir
failOnError = false
exclude '**/Parser.jj' // Exclude the generated parser
exclude '**/ParseException.java', '**/SimpleCharStream.java', '**/SqlParserImpl.java', '**/SqlParserImplConstants.java', '**/SqlParserImplTokenManager.java', '**/Token.java', '**/TokenMgrError.java' // Exclude the generated parser
}
// Check https://github.com/AdoptOpenJDK/openjdk8-binaries/releases
// jdk8u${jdk8Update}-b${jdk8Build}
def jdk8Update = '242'
def jdk8Build = '08'
def adoptOpenJdk8FolderVersionString = "jdk8u${jdk8Update}-b${jdk8Build}"
def adoptOpenJdk8FileVersionString = "8u${jdk8Update}b${jdk8Build}"
def standaloneJdk8Linux64 = "${rootProject.name}-${rootProject.version}-standalone-jdk8-linux64"
def standaloneJdk8Windows64 = "${rootProject.name}-${rootProject.version}-standalone-jdk8-windows64"
task jdk8_downloadJdkLinux64tar(type: Download) {
def jdkLinux = file("${buildDir}/jdks/jdk-8-linux64.tar.gz")
outputs.file jdkLinux
src "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/${adoptOpenJdk8FolderVersionString}/OpenJDK8U-jdk_x64_linux_hotspot_${adoptOpenJdk8FileVersionString}.tar.gz"
dest jdkLinux
overwrite false
}
task jdk8_downloadJdkLinux64(type: Zip, dependsOn: jdk8_downloadJdkLinux64tar) {
def jdkLinux = file("${buildDir}/jdks/jdk-8-linux64.zip")
outputs.file jdkLinux
from tarTree(jdk8_downloadJdkLinux64tar.dest)
archiveFile.set jdkLinux
}
task jdk8_downloadJdkWindows64(type: Download) {
def jdkWindows = file("${buildDir}/jdks/jdk-8-windows64.zip")
outputs.file jdkWindows
src "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/${adoptOpenJdk8FolderVersionString}/OpenJDK8U-jdk_x64_windows_hotspot_${adoptOpenJdk8FileVersionString}.zip"
dest jdkWindows
overwrite false
}
// For JDK 8
packr {
outputDirectory "${distributionsDir}"
//classpath "${buildDir}/libs/${standaloneJar.archiveFile.orNull.asFile.name}"
classpath "${buildDir}/libs/${jar.archiveFile.orNull.asFile.name}"
if (file("${resourcesSrcDir}/log4j2.properties").exists())
resources "${resourcesSrcDir}/log4j2.properties" // log4j2.properties is excluded by the jar task, thus we need to include it again
mainClass project.properties['mainClass']
vmArgs 'Xms1g', /*'XX:MaxRAMPercentage=75',*/ 'Djava.net.preferIPv4Stack=true', 'Dcom.sun.management.jmxremote=true', 'Dcom.sun.management.jmxremote.port=7091', 'Dcom.sun.management.jmxremote.authenticate=false', 'Dcom.sun.management.jmxremote.ssl=false'
minimizeJre "${resourcesSrcDir}/minimize/soft"// null = disable
configureLinux64 {
name "${standaloneJdk8Linux64}/bin" // move the stuff into ./bin to make it script compatible with jdk11 packaging
jdk "${buildDir}/jdks/jdk-8-linux64.zip"
vmArgs[]
}
configureWindows64 {
name "${standaloneJdk8Windows64}/bin" // move the stuff into ./bin to make it script compatible with jdk11 packaging
jdk "${buildDir}/jdks/jdk-8-windows64.zip"
vmArgs[]
}
}
packLinux64.dependsOn jar, jdk8_downloadJdkLinux64
packLinux64.doFirst {
// Add all required dependencies to the classpath of this pack task
Set dependencies = []
Set standaloneConfigurations = [project.configurations.runtime, project.configurations.standaloneImplementation]
standaloneConfigurations.stream().each { it.each { dependencies.add(it) } }
dependencies.each { classpath += file(it) }
}
packLinux64.doLast {
// move all jar files from ./bin to ./lib
ant.move(todir: "${distributionsDir}/${standaloneJdk8Linux64}/lib") {
fileset(dir: "${distributionsDir}/${standaloneJdk8Linux64}/bin") {
include(name: '*.jar')
}
}
copy {
from 'src/dist/conf'
into "${distributionsDir}/${standaloneJdk8Linux64}/conf"
}
// fix the entries for classPath in config.json
def configFile = file("${distributionsDir}/${standaloneJdk8Linux64}/bin/config.json")
def config = new groovy.json.JsonSlurper().parse(configFile)
config.classPath = config.classPath.collect { it.endsWith('.jar') ? (it.startsWith('../lib/') ? it : "../lib/${it}") : it }
config.classPath += '../conf' // add the folder containing the application.conf and log4j2.properties file to the classPath
configFile.write(groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(config)))
}
packWindows64.dependsOn jar, jdk8_downloadJdkWindows64
packWindows64.doFirst {
// Add all required dependencies to the classpath of this pack task
Set dependencies = []
Set standaloneConfigurations = [project.configurations.runtime, project.configurations.standaloneImplementation]
standaloneConfigurations.stream().each { it.each { dependencies.add(it) } }
dependencies.each { classpath += file(it) }
}
packWindows64.doLast {
// move all jar files from ./bin to ./lib
ant.move(todir: "${distributionsDir}/${standaloneJdk8Windows64}/lib") {
fileset(dir: "${distributionsDir}/${standaloneJdk8Windows64}/bin") {
include(name: '*.jar')
}
}
copy {
from 'src/dist/conf'
into "${distributionsDir}/${standaloneJdk8Windows64}/conf"
}
// fix the entries for classPath in config.json
def configFile = file("${distributionsDir}/${standaloneJdk8Windows64}/bin/config.json")
def config = new groovy.json.JsonSlurper().parse(configFile)
config.classPath = config.classPath.collect { it.endsWith('.jar') ? (it.startsWith('../lib/') ? it : "../lib/${it}") : it }
config.classPath += '../conf' // add the folder containing the application.conf and log4j2.properties file to the classPath
configFile.write(groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(config)))
}
task jdk8_zipLinux64Package(type: Zip, group: 'distribution', dependsOn: packLinux64) {
from(distributionsDir) {
include "${standaloneJdk8Linux64}/**"
}
archiveFile.set file("${distributionsDir}/${standaloneJdk8Linux64}.zip")
}
task jdk8_zipWindows64Package(type: Zip, group: 'distribution', dependsOn: packWindows64) {
from(distributionsDir) {
include "${standaloneJdk8Windows64}/**"
}
archiveFile.set file("${distributionsDir}/${standaloneJdk8Windows64}.zip")
}
task jdk8_zipAll(group: 'distribution') {
dependsOn jdk8_zipLinux64Package, jdk8_zipWindows64Package
}
//
// https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/
// jdk-11.${jdk11Minor}.${jdk11Update}+${jdk11Build}
def jdk11Minor = '0'
def jdk11Update = '6'
def jdk11Build = '10'
def adoptOpenJdk11FolderVersionString = "jdk-11.${jdk11Minor}.${jdk11Update}%2B${jdk11Build}"
def adoptOpenJdk11FileVersionString = "11.${jdk11Minor}.${jdk11Update}_${jdk11Build}"
def standaloneJdk11Linux64 = "${rootProject.name}-${rootProject.version}-standalone-jdk11-linux64"
def standaloneJdk11Windows64 = "${rootProject.name}-${rootProject.version}-standalone-jdk11-windows64"
task jdk11_downloadJdkLinux64tar(type: Download) {
def jdkLinux = file("${buildDir}/jdks/jdk-11-linux64.tar.gz")
outputs.file jdkLinux
src "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/${adoptOpenJdk11FolderVersionString}/OpenJDK11U-jdk_x64_linux_hotspot_${adoptOpenJdk11FileVersionString}.tar.gz"
dest jdkLinux
overwrite false
}
task jdk11_downloadJdkLinux64(type: Zip, dependsOn: jdk11_downloadJdkLinux64tar) {
def jdkLinux = file("${buildDir}/jdks/jdk-11-linux64.zip")
outputs.file jdkLinux
from tarTree(jdk11_downloadJdkLinux64tar.dest)
archiveFile.set jdkLinux
}
task jdk11_downloadJdkWindows64(type: Download) {
def jdkWindows = file("${buildDir}/jdks/jdk-11-windows64.zip")
outputs.file jdkWindows
src "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/${adoptOpenJdk11FolderVersionString}/OpenJDK11U-jdk_x64_windows_hotspot_${adoptOpenJdk11FileVersionString}.zip"
dest jdkWindows
overwrite false
}
task jdk11_unzipJdkLinux64(type: Copy, dependsOn: jdk11_downloadJdkLinux64) {
def zipFile = file("${buildDir}/jdks/jdk-11-linux64.zip")
def outputDir = file("${buildDir}/jdks/jdk-11-linux64")
from zipTree(zipFile)
into outputDir
}
task jdk11_unzipJdkWindows64(type: Copy, dependsOn: jdk11_downloadJdkWindows64) {
def zipFile = file("${buildDir}/jdks/jdk-11-windows64.zip")
def outputDir = file("${buildDir}/jdks/jdk-11-windows64")
from zipTree(zipFile)
into outputDir
}
application {
mainClassName = project.properties['mainClass']
}
startScripts {
defaultJvmOpts = ['-Xms1g', /*'-XX:MaxRAMPercentage=75',*/ '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.management.jmxremote=true', '-Dcom.sun.management.jmxremote.port=7091', '-Dcom.sun.management.jmxremote.authenticate=false', '-Dcom.sun.management.jmxremote.ssl=false', '-XX:+FlightRecorder']
// The default script content is generated and
// with the doLast method we can still alter
// the contents before the complete task ends.
doLast {
// https://mrhaki.blogspot.ch/2015/04/gradle-goodness-alter-start-scripts.html
// Support closures to add an additional element to
// CLASSPATH definition in the start script files.
def configureClasspathVar = { findClasspath, pathSeparator, fileSeparator, appHome, line ->
// Looking for the line that starts with either CLASSPATH=
// or set CLASSPATH=, defined by the findClasspath closure argument.
line = line.replaceAll(~/^${findClasspath}=.*$/) { original ->
// Get original line and append it
// with the configuration directory.
// Use specified path separator, which is different
// for Windows or Unix systems.
original += "${pathSeparator}\"${appHome}${fileSeparator}conf\""
}
}
// Alter the start script for Unix systems.
unixScript.text = unixScript.readLines()
.collect(configureClasspathVar.curry('CLASSPATH', ':', '/', '$APP_HOME'))
.join('\n')
// Alter the start script for Windows systems.
windowsScript.text = windowsScript.readLines()
.collect(configureClasspathVar.curry('set CLASSPATH', ';', '/', '%APP_HOME:"=%'))
.join('\r\n')
}
}
// For JDK 11
runtime {
imageDir = file(distributionsDir)
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
javaHome = org.gradle.internal.os.OperatingSystem.current().isWindows() ? "${buildDir}/jdks/jdk-11-windows64/jdk-11.${jdk11Minor}.${jdk11Update}+${jdk11Build}" : "${buildDir}/jdks/jdk-11-linux64/jdk-11.${jdk11Minor}.${jdk11Update}+${jdk11Build}"
modules = [
'java.base',
'java.compiler',
'java.desktop',
'java.logging',
'java.management',
'java.naming',
'java.rmi',
'java.scripting',
'java.security.jgss',
'java.sql',
'java.transaction.xa',
'java.xml',
'jdk.httpserver',
'jdk.jfr',
'jdk.management.agent',
'jdk.unsupported',
]
targetPlatform("${standaloneJdk11Linux64.replaceFirst("${rootProject.name}-", '')}", "${buildDir}/jdks/jdk-11-linux64/jdk-11.${jdk11Minor}.${jdk11Update}+${jdk11Build}")
targetPlatform("${standaloneJdk11Windows64.replaceFirst("${rootProject.name}-", '')}", "${buildDir}/jdks/jdk-11-windows64/jdk-11.${jdk11Minor}.${jdk11Update}+${jdk11Build}")
}
tasks.runtime.dependsOn jdk11_unzipJdkWindows64, jdk11_unzipJdkLinux64
task jdk11_zipLinux64Package(type: Zip, group: 'distribution', dependsOn: tasks.runtime) {
from(distributionsDir) {
include "${standaloneJdk11Linux64}/**"
}
archiveFile.set file("${distributionsDir}/${standaloneJdk11Linux64}.zip")
}
task jdk11_zipWindows64Package(type: Zip, group: 'distribution', dependsOn: tasks.runtime) {
from(distributionsDir) {
include "${standaloneJdk11Windows64}/**"
}
archiveFile.set file("${distributionsDir}/${standaloneJdk11Windows64}.zip")
}
task jdk11_zipAll(group: 'distribution') {
dependsOn jdk11_zipLinux64Package, jdk11_zipWindows64Package
}
task zipAll(group: 'distribution') {
dependsOn jdk8_zipAll, jdk11_zipAll
}
publishing {
publications {
"${project.name}"(MavenPublication) {
from components.java
pom {
inceptionYear = '2016'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
scm {
url = 'https://github.com/polypheny/Polypheny-FRAM.git'
}
withXml {
asNode().getAt('dependencies').each /*safe, since there is only one*/ { dependenciesNode ->
configurations.standaloneImplementation.allDependencies.stream()
.filter { !configurations.implementation.dependencies.contains(it) }
.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'runtime')
}
}
}
}
}
}
}
task generatePom(group: 'publishing', dependsOn: "generatePomFileFor${project.name.capitalize()}Publication")
sonarqube {
properties {
// Exclude the generead classes (see "sourceSets.main.java")
properties['sonar.sources'] -= [file("${generatedDir}/main/javacc")]
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
inheritOutputDirs = false
outputDir = file("${classesDir}/main")
testOutputDir = file("${classesDir}/test")
generatedSourceDirs += file("${generatedDir}/main/javacc")
// Add the custom implementation dependencies. This allows the usage of the "Run"-Button and having the two different fat jars. Basically, we somehow undo the "compileOnly" effect which we exploit for the two fat jars...
scopes.RUNTIME.plus += [configurations.pdbModuleImplementation]
scopes.RUNTIME.plus += [configurations.standaloneImplementation]
}
}