-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
775 lines (658 loc) · 30 KB
/
build.gradle.kts
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/*
* Copyright (c) 2013-2021 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2021 kopiRight Managed Solutions GmbH, Wien AT
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import java.io.ByteArrayOutputStream
import org.kopi.gradle.common._project
import org.kopi.gradle.common.clean
import org.kopi.gradle.common.withExtension
import org.kopi.gradle.dsl.modules
import org.kopi.gradle.dsl.topDir
import org.kopi.gradle.tasks.copyProperties
import org.kopi.gradle.tasks.javac
import org.kopi.gradle.tasks.jcc
import org.kopi.gradle.tasks.jflex
import org.kopi.gradle.tasks.lexinc
import org.kopi.gradle.tasks.messageGen
import org.kopi.gradle.tasks.optionGen
import org.kopi.gradle.tasks.resources
import org.kopi.gradle.tasks.scriptExecutor
import org.kopi.gradle.tasks.tokenGen
import org.kopi.gradle.tasks.xkjc
// Passing project variable to buildSrc
_project = project
/** ------------ Importing Variables declarations ------------ */
apply(from = "declarations.gradle.kts")
/** ------------------ Global Definitions and gradle tasks ------------------ */
plugins {
kotlin("jvm") version "1.5.30"
id("io.spring.dependency-management") version "1.0.10.RELEASE"
}
sourceSets.main {
java.srcDirs("src")
}
// KOPI VERSION
val kopiVersion = "2.3B"
// ENVIRONMENT VARIABLES
val extdirs: String? = System.getenv("EXTDIRS")
val classRoot: String? = System.getenv("CLASSROOT")
val jdk7Home: String? = System.getenv("JDK_7")
val javadocRoot: String? = System.getenv("JAVADOCROOT")
// Dependencies versions
val vaadinVersion = "21.0.9"
val enhancedDialogVersion = "21.0.0"
val apexChartVersion = "2.0.0.beta10"
val ironIconsVersion = "2.0.1"
val WYSIWYG_EJAVA = "2.0.1"
// ----------------------------------------------------------------------
// CHECK IF PATH TO JAVA 7 INSTALLATION IS SET AND VALID
fun javaExecutable(executableName: String): String {
val executable = file("$jdk7Home/bin/$executableName")
require(executable.exists()) { "There is no $executableName executable in ${"$jdk7Home/bin"}" }
return executable.toString()
}
// ----------------------------------------------------------------------
// CHECK THAT CLASSROOT IS SET
//require(classRoot != null) { "No CLASSROOT defined" }
// ----------------------------------------------------------------------
// DEPENDENCIES
repositories {
mavenCentral()
maven {
url = uri("https://maven.vaadin.com/vaadin-addons")
}
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// Jars present in extdirs folder
extdirs?.split(":")
?.forEach { extdir ->
"implementation"(fileTree(mapOf("dir" to extdir, "include" to listOf("*.jar"))))
}
"implementation"(files(classRoot))
// Vaadin dependencies
implementation("com.vaadin", "vaadin-core") {
listOf("com.vaadin.webjar", "org.webjars.bowergithub.insites",
"org.webjars.bowergithub.polymer", "org.webjars.bowergithub.polymerelements",
"org.webjars.bowergithub.vaadin", "org.webjars.bowergithub.webcomponents")
.forEach { group -> exclude(group = group) }
}
// Vaadin addons
// Wysiwyg-e Rich Text Editor component for Java
implementation("org.vaadin.pekka", "wysiwyg_e-java", WYSIWYG_EJAVA)
// EnhancedDialog
implementation("com.vaadin.componentfactory", "enhanced-dialog", enhancedDialogVersion)
// Apex charts
implementation("com.github.appreciated", "apexcharts", apexChartVersion)
// Iron Icons
implementation("com.flowingcode.addons", "iron-icons", ironIconsVersion)
}
// ----------------------------------------------------------------------
// READ GRADLE ARGUMENTS
val `package`: String? by project // Command line argument specifying which module to build based on package name.
val folder: String? by project // Command line argument specifying which module to build based on folder.
// ----------------------------------------------------------------------
// SELECT MODULES TO BUILD
val modulesToBuild = modules.filter(`package`, project.hasProperty("package"), folder, project.hasProperty("folder"))
modules.init()
/** ------------------ Registering main gradle tasks ------------------ */
tasks {
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileKotlin {
destinationDir = file(classRoot!!)
if(jdk7Home != null) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
}
register("grammar.jcc")
register("grm1voc.tokenGen")
register("grm1voc.lexinc")
register("grm1voc.jflex")
register("grm1voc.jcc")
register("grm2voc.tokenGen")
register("grm2voc.lexinc")
register("grm2voc.jflex")
register("grm2voc.jcc")
register("messageGen")
register("optionGen")
register("javac")
register("xkjc")
register("copyProperties")
register("resources")
register("script")
register("run") {
dependsOn("optionGen")
dependsOn("messageGen")
dependsOn("javac")
dependsOn("compileKotlin")
dependsOn("grm1voc.tokenGen")
dependsOn("grm2voc.tokenGen")
dependsOn("grm1voc.jflex")
dependsOn("grm2voc.jflex")
dependsOn("grammar.jcc")
dependsOn("grm1voc.jcc")
dependsOn("grm2voc.jcc")
dependsOn("grm1voc.lexinc")
dependsOn("grm2voc.lexinc")
dependsOn("copyProperties")
dependsOn("xkjc")
dependsOn("resources")
dependsOn("script")
doLast {
copy {
from("./src/org/kopi/vkopi/lib/ui/vaadin/addons/KopiAddonsWidgetset.gwt.xml")
into("$classRoot/org/kopi/vkopi/lib/ui/vaadin/addons")
}
}
}
jar {
dependsOn("run")
mustRunAfter("run")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
named("build") { dependsOn("run") }
register("clean-all") { dependsOn("clean") }
register("clean-classes") { dependsOn("clean") }
register("galiteflow") {
doLast {
val out = ByteArrayOutputStream()
val existValue = exec {
executable = "git"
args = listOf("status")
standardOutput = out
}
val clean = out.toString().let { it.contains("la copie de travail est propre") || it.contains("nothing to commit working tree clean") }
if(!clean) {
error("Check your local changes before updating. Execute 'git status'")
} else {
val galiteBuildDir = "${buildDir}/galite"
val galiteBuildDirVaadin = "$galiteBuildDir/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin"
val vaadinDir = file("./src/org/kopi/vkopi/lib/ui/vaadinflow")
val frontendDir = "./src/resources/META-INF/resources/frontend"
file(galiteBuildDir).deleteRecursively()
vaadinDir.deleteRecursively()
exec {
executable = "git"
args = listOf("clone", "https://github.com/kopiLeft/Galite.git", "-b", "master", "--single-branch", galiteBuildDir)
}
// Copy sources
copy {
from(galiteBuildDirVaadin) {
include("**/*.kt")
exclude("**/DAbstractFullCalendar.kt",
"**/DFullCalendarBlock.kt",
"**/DTimeGridCalendar.kt",
"**/pivottable/*.kt")
}
into(vaadinDir)
filter { line ->
line
.replace("org.kopi.galite.visual.ui.vaadin", "org.kopi.vkopi.lib.ui.vaadinflow")
// org.kopi.galite.visual package
.replace("org.kopi.galite.visual.Action", "org.kopi.vkopi.lib.visual.Action")
.replace("org.kopi.galite.visual.ActionHandler", "org.kopi.vkopi.lib.visual.ActionHandler")
.replace("org.kopi.galite.visual.Application", "org.kopi.vkopi.lib.visual.Application")
.replace("org.kopi.galite.visual.ApplicationConfiguration", "org.kopi.vkopi.lib.visual.ApplicationConfiguration")
.replace("org.kopi.galite.visual.ApplicationContext", "org.kopi.vkopi.lib.visual.ApplicationContext")
.replace("org.kopi.galite.visual.Color", "org.kopi.vkopi.lib.visual.Color")
.replace("org.kopi.galite.visual.Constants", "org.kopi.vkopi.lib.visual.Constants")
.replace("org.kopi.galite.visual.DefaultActor", "org.kopi.vkopi.lib.visual.DefaultActor")
.replace("org.kopi.galite.visual.DPositionPanelListener", "org.kopi.vkopi.lib.visual.DPositionPanelListener")
.replace("org.kopi.galite.visual.Executable", "org.kopi.vkopi.lib.visual.Executable")
.replace("org.kopi.galite.visual.FileHandler", "org.kopi.vkopi.lib.visual.FileHandler")
.replace("org.kopi.galite.visual.FileProductionListener", "org.kopi.vkopi.lib.visual.FileProductionListener")
.replace("org.kopi.galite.visual.ImageHandler", "org.kopi.vkopi.lib.visual.ImageHandler")
.replace("org.kopi.galite.visual.Item", "org.kopi.vkopi.lib.visual.Item")
.replace("org.kopi.galite.visual.ItemTreeManager", "org.kopi.vkopi.lib.visual.ItemTreeManager")
.replace("org.kopi.galite.visual.LogoutModule", "org.kopi.vkopi.lib.visual.LogoutModule")
.replace("org.kopi.galite.visual.Message", "org.kopi.vkopi.lib.visual.Message")
.replace("org.kopi.galite.visual.MessageCode", "org.kopi.vkopi.lib.visual.MessageCode")
.replace("org.kopi.galite.visual.MessageListener", "org.kopi.vkopi.lib.visual.MessageListener")
.replace("org.kopi.galite.visual.ModelCloseListener", "org.kopi.vkopi.lib.visual.ModelCloseListener")
.replace("org.kopi.galite.visual.Module", "org.kopi.vkopi.lib.visual.Module")
.replace("org.kopi.galite.visual.PreviewRunner", "org.kopi.vkopi.lib.visual.PreviewRunner")
.replace("org.kopi.galite.visual.PrinterManager", "org.kopi.vkopi.lib.visual.PrinterManager")
.replace("org.kopi.galite.visual.ProgressDialogListener", "org.kopi.vkopi.lib.visual.ProgressDialogListener")
.replace("org.kopi.galite.visual.PropertyException", "org.kopi.vkopi.lib.visual.PropertyException")
.replace("org.kopi.galite.visual.Registry", "org.kopi.vkopi.lib.visual.Registry")
.replace("org.kopi.galite.visual.RootItem", "org.kopi.vkopi.lib.visual.RootItem")
.replace("org.kopi.galite.visual.RootMenu", "org.kopi.vkopi.lib.visual.RootMenu")
.replace("org.kopi.galite.visual.UActor", "org.kopi.vkopi.lib.visual.UActor")
.replace("org.kopi.galite.visual.UIFactory", "org.kopi.vkopi.lib.visual.UIFactory")
.replace("org.kopi.galite.visual.UItemTree", "org.kopi.vkopi.lib.visual.UItemTree")
.replace("org.kopi.galite.visual.UMenuTree", "org.kopi.vkopi.lib.visual.UMenuTree")
.replace("org.kopi.galite.visual.UserConfiguration", "org.kopi.vkopi.lib.visual.UserConfiguration")
.replace("org.kopi.galite.visual.UWindow", "org.kopi.vkopi.lib.visual.UWindow")
.replace("org.kopi.galite.visual.VActionListener", "org.kopi.vkopi.lib.visual.VActionListener")
.replace("org.kopi.galite.visual.VActor", "org.kopi.vkopi.lib.visual.VActor")
.replace("org.kopi.galite.visual.VColor", "org.kopi.vkopi.lib.visual.VColor")
.replace("org.kopi.galite.visual.VCommand", "org.kopi.vkopi.lib.visual.VCommand")
.replace("org.kopi.galite.visual.VDatabaseUtils", "org.kopi.vkopi.lib.visual.VDatabaseUtils")
.replace("org.kopi.galite.visual.VerifyConfiguration", "org.kopi.vkopi.lib.visual.VerifyConfiguration")
.replace("org.kopi.galite.visual.VException", "org.kopi.vkopi.lib.visual.VException")
.replace("org.kopi.galite.visual.VExecFailedException", "org.kopi.vkopi.lib.visual.VExecFailedException")
.replace("org.kopi.galite.visual.VHelpGenerator", "org.kopi.vkopi.lib.visual.VHelpGenerator")
.replace("org.kopi.galite.visual.VHelpViewer", "org.kopi.vkopi.lib.visual.VHelpViewer")
.replace("org.kopi.galite.visual.VInterruptException", "org.kopi.vkopi.lib.visual.VInterruptException")
.replace("org.kopi.galite.visual.VItemTree", "org.kopi.vkopi.lib.visual.VItemTree")
.replace("org.kopi.galite.visual.VlibProperties", "org.kopi.vkopi.lib.visual.VlibProperties")
.replace("org.kopi.galite.visual.VMenuTree", "org.kopi.vkopi.lib.visual.VMenuTree")
.replace("org.kopi.galite.visual.VModel", "org.kopi.vkopi.lib.visual.VModel")
.replace("org.kopi.galite.visual.VRuntimeException", "org.kopi.vkopi.lib.visual.VRuntimeException")
.replace("org.kopi.galite.visual.VTrigger", "org.kopi.vkopi.lib.visual.VTrigger")
.replace("org.kopi.galite.visual.VWindow", "org.kopi.vkopi.lib.visual.VWindow")
.replace("org.kopi.galite.visual.WaitDialogListener", "org.kopi.vkopi.lib.visual.WaitDialogListener")
.replace("org.kopi.galite.visual.WaitInfoListener", "org.kopi.vkopi.lib.visual.WaitInfoListener")
.replace("org.kopi.galite.visual.WindowBuilder", "org.kopi.vkopi.lib.visual.WindowBuilder")
.replace("org.kopi.galite.visual.WindowController", "org.kopi.vkopi.lib.visual.WindowController")
.replace("org.kopi.galite.visual", "org.kopi.vkopi.lib")
.replace("org.kopi.galite.type", "org.kopi.vkopi.lib.type")
.replace("org.kopi.galite.util", "org.kopi.vkopi.lib.util")
.replace("ApplicationContext.applicationContext.getApplication()", "ApplicationContext.getApplicationContext().getApplication()")
.replace("block.currentRecord = rec + 1", "block.setCurrentRecord(rec + 1)")
.replace("block.currentRecord = rec", "block.setCurrentRecord(rec)")
.replace("fun hasDisplays(): Boolean = isDisplayInitialized", "fun hasDisplays(): Boolean = displays != null")
.replace("dBConnection", "dbContext")
.replace("objectName", "`object`")
.replace("override fun dispose()", "private fun dispose()")
.replace("isDisplayInitialized", "displays != null")
.replace("item.isDefaultItem = true", "item.setDefault(true)")
.replace("item.isDefaultItem = false", "item.setDefault(false)")
}
}
file(frontendDir).deleteRecursively()
// Copy resources
copy {
from("$galiteBuildDir/galite-core/src/main/resources/META-INF/resources/frontend")
into(frontendDir)
}
// cleanup build dir
file(galiteBuildDir).deleteRecursively()
}
}
}
}
defaultTasks("run")
/** ------------------ Configuring gradle tasks ------------------ */
if(jdk7Home != null) {
println("JAVA 7 is used to compile this project.")
// Compatibility with java 7
tasks.withType<JavaExec>().configureEach {
executable = javaExecutable("java")
}
tasks.withType<Javadoc>().configureEach {
executable = javaExecutable("javadoc")
}
}
tasks.withType<JavaCompile>().configureEach {
options.apply {
// Compatibility with java 7
if(jdk7Home != null) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
forkOptions.javaHome = file(jdk7Home)
}
isFork = true
isFailOnError = true
isDeprecation = true
isListFiles = true
encoding = "utf-8"
}
}
// Adding generated files
modulesToBuild.forEach { module ->
module.apply {
val allJavaFiles = javaFiles.orEmpty().toMutableList()
val allGenFiles= genFiles.orEmpty().toMutableList()
val grammar = grammar.orEmpty()
val grm1voc = grm1voc.orEmpty()
val grm2voc = grm2voc.orEmpty()
val grm1dep = grm1dep.orEmpty()
val grm2dep = grm2dep.orEmpty()
val scanner1 = scanner1.orEmpty()
val scanner2 = scanner2.orEmpty()
if (!grammar.isNullOrEmpty()) {
allJavaFiles.addAll(grammar.map { "${it}Parser" })
allJavaFiles.addAll(grammar.map { "${it}TokenTypes" })
allJavaFiles.addAll(grammar.map { "${it}Lexer" })
allJavaFiles.addAll(grammar.map { "${it}LexerTokenTypes" })
allGenFiles.addAll(grammar.map { "${it}Parser.java" })
allGenFiles.addAll(grammar.map { "${it}TokenTypes.java" })
allGenFiles.addAll(grammar.map { "${it}Lexer.java" })
allGenFiles.addAll(grammar.map { "${it}LexerTokenTypes.java" })
allGenFiles.addAll(grammar.map { "${it}TokenTypes.txt" })
allGenFiles.addAll(grammar.map { "${it}LexerTokenTypes.txt" })
}
if (!grm1voc.isNullOrEmpty()) {
allJavaFiles.addAll(grm1voc.map { "${it}TokenTypes" })
allGenFiles.addAll(grm1voc.map { "${it}TokenTypes.java" })
allGenFiles.addAll(grm1voc.map { "${it}TokenTypes.txt" })
if (!scanner1.isNullOrEmpty()) {
allJavaFiles.addAll(scanner1.map { "${it}Scanner" })
allGenFiles.addAll(grm1voc.map { "${it}FlexRules.txt" })
allGenFiles.addAll(scanner1.withExtension("flex"))
allGenFiles.addAll(scanner1.map { "${it}Scanner.java" })
} else {
allJavaFiles.addAll(grm1voc.map { "${it}Keywords" })
allJavaFiles.addAll(grm1voc.map { "${it}Parser" })
allGenFiles.addAll(grm1voc.map { "${it}Keywords.java" })
allGenFiles.addAll(grm1voc.map { "${it}Parser.java" })
}
if (!grm1dep.isNullOrEmpty()) {
allGenFiles.addAll(grm1voc.map { file(it).parentFile.path + "/expanded${file(it).name}.g" })
}
}
if (!grm2voc.isNullOrEmpty()) {
allJavaFiles.addAll(grm2voc.map { "${it}TokenTypes" })
allGenFiles.addAll(grm2voc.map { "${it}TokenTypes.java" })
allGenFiles.addAll(grm2voc.map { "${it}TokenTypes.txt" })
if (!scanner2.isNullOrEmpty()) {
allJavaFiles.addAll(scanner2.map { "${it}Scanner" })
allGenFiles.addAll(grm2voc.map { "${it}FlexRules.txt" })
allGenFiles.addAll(scanner2.withExtension("flex"))
allGenFiles.addAll(scanner2.map { "${it}Scanner.java" })
} else {
allJavaFiles.addAll(grm2voc.map { "${it}Keywords" })
allJavaFiles.addAll(grm2voc.map { "${it}Parser" })
allGenFiles.addAll(grm2voc.map { "${it}Keywords.java" })
allGenFiles.addAll(grm2voc.map { "${it}Parser.java" })
}
if (!grm2dep.isNullOrEmpty()) {
allGenFiles.addAll(grm2voc.map { file(it).parentFile.path + "/expanded${file(it).name}.g" })
}
}
allJavaFiles.addAll(messageFiles.orEmpty())
allGenFiles.addAll(messageFiles.withExtension("java"))
allJavaFiles.addAll(optionFiles.orEmpty())
allGenFiles.addAll(optionFiles.withExtension("java"))
javaFiles = allJavaFiles
genFiles = allGenFiles
}
}
// Configuring gradle tasks to each module to build
tasks {
// JAVADOC GENERATION
named<Javadoc>("javadoc") {
val allJavaFiles = modulesToBuild.map { it.javaFiles.withExtension("java") }.flatten()
options.source = "1.4"
options.jFlags = listOf("-Xmx128m")
options.memberLevel = JavadocMemberLevel.PACKAGE
val javadocDocletOptions = options.windowTitle("Kopi Suite Version $kopiVersion")
javadocDocletOptions.isUse = true
javadocDocletOptions.isNoTimestamp = false
setDestinationDir(file("$javadocRoot/html/"))
this.source = fileTree(topDir)
include(allJavaFiles.map { file(it).relativeTo(file(topDir)).toString() })
doFirst {
require(javadocRoot != null) { "No JAVADOCROOT defined" }
}
}
modulesToBuild.forEach { module ->
module.apply {
val classRoot = classRoot ?: project.buildDir.absolutePath
val javaFiles: List<String> = javaFiles.withExtension("java")
val grammar: List<String>? = grammar
val grm1voc: List<String>? = grm1voc
val grm2voc: List<String>? = grm2voc
val grm1dep: List<String>? = grm1dep
val grm2dep: List<String>? = grm2dep
val scanner1: List<String>? = scanner1
val scanner2: List<String>? = scanner2
val xFiles: List<String> = xFiles.withExtension("x")
val jFiles: List<String> = jFiles.withExtension("java")
val nonStandardCompiler: Boolean = nonStandardCompiler
val nonStandardBuild: Boolean = nonStandardBuild
val properties: List<String>? = this@apply.properties?.withExtension("properties")
val resources: List<String>? = resources
val gifFiles: List<String>? = gifFiles.withExtension("gif")
val optionFiles: List<String>? = optionFiles
val messageFiles: List<String>? = messageFiles
// ----------------------------------------------------------------------
// STANDARD BUILD TASKS
if(!nonStandardBuild) {
// ----------------------------------------------------------------------
// GRAMMAR HANDLING (GRAMMARS WITH ANTLR TOKENIZER)
if (!grammar.isNullOrEmpty()) {
jcc("grm1voc.jcc", taskNamePrefix) {
this.grammarFiles = files(grammar.withExtension("g"))
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
// GRAMMAR HANDLING (GRAMMARS WITH SEPARATE TOKENIZER)
if (!grm1voc.isNullOrEmpty()) {
tokenGen("grm1voc.tokenGen", taskNamePrefix) {
val grm1vocT = grm1voc.withExtension("t")
val grm1depT = grm1dep.withExtension("t")
this.grmvocFiles = files(grm1depT + grm1vocT)
this.currentDir = folder
this.withScanner = scanner1.isNullOrEmpty()
}
if (!scanner1.isNullOrEmpty()) {
/** -------- JFlex based scanner -------- */
lexinc("grm1voc.lexinc", taskNamePrefix) {
this.scannerFlexInFiles = files(scanner1.withExtension("flex.in"))
this.grmvocFiles = grm1voc
this.currentDir = folder
}
jflex("grm1voc.jflex", taskNamePrefix) {
this.scannerFiles = files(scanner1.withExtension("flex"))
this.jflexSkeleton = "$classRoot/org/kopi/compiler/skeleton.shared"
this.currentDir = folder
}
}
jcc("grm1voc.jcc", taskNamePrefix) {
val grm1vocG = grm1voc.withExtension("g")
val grm1depG = grm1dep.withExtension("g")
this.grammarFiles = files(grm1depG + grm1vocG)
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
if (!grm2voc.isNullOrEmpty()) {
tokenGen("grm2voc.tokenGen", taskNamePrefix) {
val grm2vocT = grm2voc.withExtension("t")
val grm2depT = grm2dep.withExtension("t")
this.grmvocFiles = files(grm2depT + grm2vocT)
this.currentDir = folder
this.withScanner = scanner2.isNullOrEmpty()
}
if (!scanner2.isNullOrEmpty()) {
/** -------- JFlex based scanner -------- */
lexinc("grm2voc.lexinc", taskNamePrefix) {
this.scannerFlexInFiles = files(scanner2.withExtension("flex.in"))
this.grmvocFiles = grm2voc
this.currentDir = folder
}
jflex("grm2voc.jflex", taskNamePrefix) {
this.scannerFiles = files(scanner2.withExtension("flex"))
this.jflexSkeleton = "$classRoot/org/kopi/compiler/skeleton.shared"
this.currentDir = folder
}
}
jcc("grm2voc.jcc", taskNamePrefix) {
val grm2vocG = grm2voc.withExtension("g")
val grm2depG = grm2dep.withExtension("g")
this.grammarFiles = files(grm2depG + grm2vocG)
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
// MESSAGES
if (!messageFiles.isNullOrEmpty()) {
messageGen(taskNamePrefix) {
this.messageFiles = files(messageFiles.withExtension("xml"))
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
// OPTIONS
if (!optionFiles.isNullOrEmpty()) {
optionGen(taskNamePrefix) {
this.release = release.orEmpty()
this.optionFiles = files(optionFiles.withExtension("xml"))
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
// BUILD CLASSFILES
if (!nonStandardCompiler && javaFiles.isNotEmpty()) {
javac(taskNamePrefix) {
destinationDir = file(classRoot)
source = files(".").asFileTree
options.sourcepath = files(topDir)
include(javaFiles.map { file(it).relativeTo(file(".")).path })
doLast {
val copyFiles = copyFiles.orEmpty()
// Copy files into classroot/package
if (copyFiles.isNotEmpty()) {
val packagePath = packageName.replace(".", "/")
println("Files to be copied : $copyFiles Into : $classRoot/$packagePath")
copy {
from(copyFiles)
into("$classRoot/$packagePath")
}
}
// Copy sources into classroot/package
if (copySources) {
val packagePath = packageName.replace(".", "/")
println("Files to be copied : $javaFiles Into : $classRoot/$packagePath")
copy {
from(javaFiles)
into("$classRoot/$packagePath")
}
}
}
}
}
// ----------------------------------------------------------------------
// NON STANDARD COMPILATION FOR package org.kopi.xkopi.lib.oper
val xkjcFiles = xFiles + jFiles
if (nonStandardCompiler && xkjcFiles.isNotEmpty() && packageName == "org.kopi.xkopi.lib.oper") {
xkjc(taskNamePrefix) {
this.classRoot = classRoot
this.verbose = true
this.noo = true
this.xkjcPath = "/dev/null"
this.xkjcFiles = files(xkjcFiles)
this.currentDir = folder
}
}
// ----------------------------------------------------------------------
// INSTALL PROPERTIES FILES
if (properties != null) {
copyProperties(taskNamePrefix) {
this.properties = files(properties)
this.propertiesDest = classRoot
}
}
}
// ----------------------------------------------------------------------
// NON STANDARD BUILD TASKS
if(nonStandardBuild) {
val packagePath = packageName.replace(".", "/")
// ----------------------------------------------------------------------
// NON STANDARD BUILD FOR PACKAGE org.kopi.vkopi.lib.ui.vaadin.resource
if (packageName == "org.kopi.vkopi.lib.ui.vaadin.resource") {
if (resources != null) {
resources(taskNamePrefix) {
this.resources = files(resources)
if(targetDir == null) {
this.resourceDestDir = classRoot + File.separator + packagePath
} else {
this.resourceDestDir = classRoot + File.separator + targetDir
}
}
}
}
// ----------------------------------------------------------------------
// NON STANDARD BUILD FOR PACKAGE org.kopi.compiler.resource
if (packageName == "org.kopi.compiler.resource") {
if (resources != null) {
resources(taskNamePrefix) {
this.resources = files(resources)
if(targetDir == null) {
this.resourceDestDir = classRoot + File.separator + packagePath
} else {
this.resourceDestDir = classRoot + File.separator + targetDir
}
}
}
}
// ----------------------------------------------------------------------
// NON STANDARD BUILD FOR PACKAGE org.kopi.vkopi.lib.resource
if (packageName == "org.kopi.vkopi.lib.resource") {
if (resources != null) {
resources(taskNamePrefix) {
this.resources = files(resources)
if(targetDir == null) {
this.resourceDestDir = classRoot + File.separator + packagePath
} else {
this.resourceDestDir = classRoot + File.separator + targetDir
}
}
}
if (gifFiles != null) {
scriptExecutor(taskNamePrefix) {
this.inputFiles = gifFiles
this.currentDir = folder
this.script = "makegallery.sh"
this.outputFile = "gallery.html"
}
}
}
}
// ----------------------------------------------------------------------
// CLEAN AND REMOVE GENERATED FILES
named("clean-all") {
doLast {
if (!genFiles.isNullOrEmpty()) {
genFiles!!.forEach {
clean(it, null)
}
}
}
}
// ----------------------------------------------------------------------
// CLEAN CLASSFILES
named("clean-classes") {
doLast {
val packageInClassRoot = file("$classRoot/${packageName.replace(".", "/")}")
packageInClassRoot.listFiles { it -> it.extension == "class" }.orEmpty().forEach {
clean(it.name, packageInClassRoot.path)
}
}
}
// ----------------------------------------------------------------------
}
}
}
/** ------ Global error handling message ------ */
project.gradle.buildFinished {
if (this.failure != null) {
println("An error has occured. See the error output logs or try with > gradle --rerun-tasks")
}
}
dependencyManagement {
imports {
mavenBom("com.vaadin:vaadin-bom:${vaadinVersion}")
}
}