-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
656 lines (595 loc) · 19.5 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
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.text.SimpleDateFormat
// https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_packaging
plugins {
id "java"
// Apply the application plugin to add support for building a CLI application in Java.
// This produces the distributions and scripts for any OS
id "application"
id 'antlr'
// For source code formatting
id "com.diffplug.spotless" version "6.25.0"
// For building shadow jars with jdk 17 ONLY
//id 'com.github.johnrengelman.shadow' version '8.1.1'
// For building shadow jars using JDK 21 +, they had to fork
id "io.github.goooler.shadow" version "8.1.8"
// For dependency updates
id 'com.github.ben-manes.versions' version '0.51.0'
// For building service loader files
id "com.github.harbby.gradle.serviceloader" version "1.1.8"
// Maven Publisher
id 'maven-publish'
id 'signing'
id 'com.gradleup.nmcp' version "0.0.9"
}
/**
* Project Properties
*/
group = 'ortus.boxlang'
sourceCompatibility = jdkVersion
targetCompatibility = jdkVersion
ext {
buildID = System.getenv( 'BUILD_ID' ) ?: '0'
branch = System.getenv( 'BRANCH' ) ?: 'development'
}
if (branch == 'development') {
// If the branch is 'development', ensure the version ends with '-snapshot'
// This replaces any existing prerelease identifier with '-snapshot'
version = version.contains('-') ? version.replaceAll(/-.*/, '-snapshot') : "${version}-snapshot"
}
/**
* ANTLR Properties
*/
def antlrGeneratedParserPackage = "ortus.boxlang.parser.antlr"
def generatedSrcDir = "build/generated-src"
def antlrGeneratedParserBaseDir = "$generatedSrcDir/antlr/main"
def antlrGeneratedParserPackageDir = antlrGeneratedParserPackage.replaceAll("\\.", "/")
def antlrGrammarDir = "src/main/antlr"
java {
withJavadocJar()
withSourcesJar()
}
sourceSets {
main {
java {
// Normal java sources + Antlr generated sources
srcDirs += [ "$antlrGeneratedParserBaseDir" ]
}
resources {
srcDirs = [ 'src/main/resources' ]
include '**/*.properties'
include '**/*.class'
include '**/*.jar'
include '**/*.json'
include '**/*.bx*'
include '**/*.css'
include '**/*.js'
include '**/*.cf*'
include '**/META-INF/services/*'
}
}
}
/**
* Repositories for dependencies in order
*/
repositories {
mavenLocal()
mavenCentral()
}
/**
* Project Dependencies
*/
dependencies {
// Testing Dependencies
testImplementation "org.junit.jupiter:junit-jupiter:5.+"
testImplementation "org.mockito:mockito-core:5.+"
testImplementation "com.google.truth:truth:1.+"
testImplementation "commons-cli:commons-cli:1.9.0"
// https://wiremock.org/
testImplementation "org.wiremock:wiremock:3.9.2"
// https://mvnrepository.com/artifact/org.apache.derby/derby
testImplementation 'org.apache.derby:derby:10.17.1.0'
testImplementation 'io.undertow:undertow-core:2.3.18.Final'
// Antlr
antlr "org.antlr:antlr4:$antlrVersion"
// Implementation Dependencies
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation "commons-io:commons-io:2.17.0"
// https://mvnrepository.com/artifact/com.github.javaparser/javaparser-symbol-solver-core
implementation 'com.github.javaparser:javaparser-symbol-solver-core:3.26.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation 'org.apache.commons:commons-lang3:3.17.0'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
// Many of these classes ( e.g. StringEscapeUtils ) are currently deprecated in commons-lang and others will be moved in the future
implementation 'org.apache.commons:commons-text:1.12.0'
// https://mvnrepository.com/artifact/org.apache.commons/commons-cli
implementation "commons-cli:commons-cli:1.9.0"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-objects
implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.18.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-extension-javatime
implementation 'com.fasterxml.jackson.jr:jackson-jr-extension-javatime:2.18.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-stree
implementation 'com.fasterxml.jackson.jr:jackson-jr-stree:2.18.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.jr/jackson-jr-annotation-support
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.18.1'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:2.0.16'
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
implementation 'ch.qos.logback:logback-classic:1.5.12'
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
implementation 'com.zaxxer:HikariCP:6.1.0'
// https://mvnrepository.com/artifact/org.ow2.asm/asm-tree
implementation 'org.ow2.asm:asm-tree:9.7.1'
// https://mvnrepository.com/artifact/org.ow2.asm/asm-util
implementation 'org.ow2.asm:asm-util:9.7.1'
}
/**
* Project Wide Helper function
* This is not a task, but a reusable UDF
*/
project.ext.bumpVersion = {
boolean major = false,
boolean minor = false,
boolean patch = false,
boolean beta = false ->
def propertiesFile = file( './gradle.properties' );
def properties = new Properties();
properties.load( propertiesFile.newDataInputStream() )
def versionTarget = major ? 0 : minor ? 1 : 2
def currentVersion = properties.getProperty( 'version' )
def versionParts = currentVersion.split( '\\.' )
if( !beta ){
def newPathVersion = versionParts[ versionTarget ].toInteger() + 1
}
def newVersion = '';
if( patch ){
newVersion = "${versionParts[ 0 ]}.${versionParts[ 1 ]}.${newPathVersion}"
} else if( minor ){
newVersion = "${versionParts[ 0 ]}.${newPathVersion}.${versionParts[ 2 ]}"
} else if( major ){
newVersion = "${newPathVersion}.${versionParts[ 1 ]}.${versionParts[ 2 ]}"
} else if( beta ){
// Get's the -betaX version.
def betaString = currentVersion.split( '-' )[ 1 ]
// Now we get the beta number
def betaNumber = betaString.split( 'beta' )[ 1 ].toInteger() + 1
newVersion = currentVersion.split( '-' )[ 0 ] + "-beta${betaNumber}"
}
properties.setProperty( 'version', newVersion )
properties.store( propertiesFile.newWriter(), null )
println "Bumped version from ${currentVersion} to ${newVersion}"
}
/**
* Application Build
* https://docs.gradle.org/current/userguide/application_plugin.html
*/
application {
// We use full because it's not shadowed. It can be used for debugging or other packaging purposes
applicationName = "boxlang"
mainClass = "ortus.boxlang.runtime.BoxRunner"
}
processResources {
// Replace @build.date@ with the current date in META-INF/version.properties file
filter( ReplaceTokens, tokens: [ 'build.date': new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( new Date() ) ] )
// Replace @build.version@ with the current version in META-INF/version.properties file
filter( ReplaceTokens, tokens: [ 'build.version': version + "+" + buildID ] )
}
/**
* Jar and Shadow Jar config
* https://imperceptiblethoughts.com/shadow/configuration/
*/
jar {
archiveBaseName = 'boxlang'
archiveVersion = "${version}"
/**
* The manifest for the shadowJar task is configured to inherit from the manifest of the standard jar task.
*/
manifest {
attributes 'Main-Class': 'ortus.boxlang.runtime.BoxRunner'
attributes 'Description': 'This is the Ortus BoxLang OS Distribution'
attributes 'Implementation-Version': "${version}+${buildID}"
attributes 'Created-On': new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( new Date() )
attributes 'Created-By': "Ortus Solutions, Corp"
}
// Exclude the following directories from the final built JAR
exclude '**/ortus/boxlang/tools/**'
}
shadowJar {
archiveBaseName = "boxlang"
mergeServiceFiles()
exclude "com/ibm/icu/**"
minimize{
exclude 'ortus/boxlang/tools/**'
exclude 'ortus/boxlang/runtime/testing/**'
exclude( dependency( "org.slf4j:.*:.*" ) )
exclude( dependency( "ch.qos.logback:.*:.*" ) )
exclude( dependency( "com.zaxxer:.*:.*" ) )
exclude( dependency( "com.fasterxml.jackson.jr:.*:.*" ) )
}
}
test {
testLogging {
events "FAILED", "STANDARD_ERROR"
}
}
/**
* Cleanup final artifacts, we only want the shadow artifacts
*/
tasks.distZip.setEnabled( false )
tasks.distTar.setEnabled( false )
tasks.shadowDistTar.setEnabled( false )
tasks.shadowDistZip.setEnabled( false )
/**
* This is necessary to create a single level instead of what shadow does
*/
task createDistributionFile( type: Zip ){
dependsOn startShadowScripts
// Copy the custom /src/main/scripts into the /bin folder but replace all the @version@ to ${version}
from( 'src/main/scripts' ) {
into 'bin'
filter( ReplaceTokens, tokens: [ 'version' : version ] )
}
from( 'build/scriptsShadow' ) {
into 'bin'
}
from( 'build/libs' ) {
include 'boxlang-' + version + '-all.jar'
into 'lib'
}
archiveFileName = "boxlang-${version}.zip"
doLast {
println "+ Distribution file has been created"
}
}
/**
* Task moves the contents of the `libs` folder to the `distributions` folder
and must run after build
*/
task libsToDistro( type: Copy ) {
dependsOn build, createDistributionFile
from( 'build/libs' ) {
include 'boxlang-' + version + '-all.jar'
include 'boxlang-' + version + '-javadoc.jar'
}
from( 'build/resources/main/META-INF/boxlang/version.properties' ){
}
destinationDir = file( "build/distributions" )
doLast {
file( "build/evergreen" ).mkdirs()
if( branch == 'development' ){
Files.copy( file( "build/distributions/boxlang-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-snapshot.zip" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
Files.copy( file( "build/distributions/boxlang-${version}-all.jar" ).toPath(), file( "build/evergreen/boxlang-snapshot-all.jar" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
} else {
Files.copy( file( "build/distributions/boxlang-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-latest.zip" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
Files.copy( file( "build/distributions/boxlang-${version}-all.jar" ).toPath(), file( "build/evergreen/boxlang-latest-all.jar" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
}
println "+ Libs have been moved to the distribution and evergreen folders"
}
}
build.finalizedBy( libsToDistro )
/**
* Publish the artifacts to the local maven repository
*/
publishing {
publications {
shadow( MavenPublication ) { publication ->
artifact shadowJar
artifact javadocJar
artifact sourcesJar
// This is the only one sonatype accepts, not ortus.boxlang
// https://central.sonatype.com/
groupId = 'io.boxlang'
artifactId = 'boxlang'
pom {
name = "BoxLang"
description = "BoxLang is a dynamic multi-runtime JVM Language based on fluency and functional constructs. It can be deployed as a standalone language, embedded in your Java applications, web applications, serverless, android, etc."
url = "https://boxlang.io"
issueManagement {
system = "Jira"
url = "https://ortussolutions.atlassian.net/jira/software/c/projects/BL/issues"
}
mailingLists {
mailingList {
name = "BoxLang Community"
subscribe = "https://community.ortussolutions.com/c/boxlang/42"
unsubscribe = "https://community.ortussolutions.com/c/boxlang/42"
}
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:https://github.com/ortus-boxlang/boxlang.git'
developerConnection = 'scm:git:ssh://github.com/ortus-boxlang/boxlang.git'
url = 'https://github.com/ortus-boxlang/boxlang'
}
developers{
developer {
id = "lmajano"
name = "Luis Majano"
email = "lmajano@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "bdw429s"
name = "Brad Wood"
email = "brad@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "jclausen"
name = "Jon Clausen"
email = "jclausen@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "michaelborn"
name = "Michael Born"
email = "michael@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "garciadev"
name = "Daniel Garcia"
email = "dgarcia@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "jbeers"
name = "Jacob Beers"
email = "jbeers@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "gpickin"
name = "Gavin Pickin"
email = "gavin@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
developer {
id = "ericpeterson"
name = "Eric Peterson"
email = "eric@ortussolutions.com"
organization = "Ortus Solutions, Corp"
organizationUrl = "https://www.ortussolutions.com"
}
}
}
}
}
repositories {
maven {
name = 'local-repo'
url = layout.buildDirectory.dir( "repo" )
}
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/ortus-boxlang/boxlang"
credentials {
username = System.getenv( "GITHUB_ACTOR" )
password = System.getenv( "GITHUB_TOKEN" )
}
}
}
}
nmcp {
publishAllProjectsProbablyBreakingProjectIsolation {
username = System.getenv( "MAVEN_USERNAME" ) ?: project.findProperty( "maven_username" )
password = System.getenv( "MAVEN_PASSWORD" ) ?: project.findProperty( "maven_password" )
// publish manually from the portal
//publicationType = "USER_MANAGED"
// or if you want to publish automatically
publicationType = "AUTOMATIC"
}
}
/**
* Digital Signing of assets
*/
signing {
def signingKey = System.getenv("GPG_KEY") ?: project.findProperty("signing.keyId")
def signingPassword = System.getenv("GPG_PASSWORD") ?: project.findProperty("signing.password")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.shadow
}
/**
* Docs are here:
* - https://github.com/harbby/gradle-serviceloader,
* - https://plugins.gradle.org/plugin/com.github.harbby.gradle.serviceloader
* This generates the META-INF/services files for the ServiceLoader as part of the `build` task
*/
serviceLoader {
serviceInterface 'ortus.boxlang.runtime.bifs.BIF'
serviceInterface 'ortus.boxlang.runtime.components.Component'
serviceInterface 'ortus.boxlang.runtime.async.tasks.IScheduler'
serviceInterface 'ortus.boxlang.runtime.cache.providers.ICacheProvider'
serviceInterface 'ortus.boxlang.runtime.events.IInterceptor'
}
/**
* Builds out the BoxLang Docs
*/
javadoc {
options.addBooleanOption( "Xdoclint:none", true )
exclude '**/boxlang/parser/**'
options.addBooleanOption( 'html5', true )
}
task zipJavadocs( type: Zip ) {
group "documentation"
from javadoc.destinationDir
archiveFileName = "boxlang-javadocs-${version}.zip"
destinationDirectory = file( "$buildDir/distributions" )
// Output that the docs have been zippped
doLast {
println "+ Javadocs have been zipped to the distribution folder"
}
}
javadoc.finalizedBy( zipJavadocs )
/**
* Sources jar is required by maven central
*/
sourcesJar{
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn generateTestGrammarSource, generateGrammarSource
}
/**
* Compile Java Customizations
*/
compileJava {
source sourceSets.main.java
// Compiler Options
options.incremental = true
options.encoding = 'UTF-8'
options.debug()
// Generate the ANTLR parser before compiling
dependsOn generateGrammarSource, generateTestGrammarSource
}
/**
* Compile Test Java Customizations
* To generate the ANTLR parser before compiling
*/
compileTestJava {
source sourceSets.test.java
dependsOn compileJava, generateTestGrammarSource, serviceLoaderBuild, ":src:modules:test:build"
options.encoding = 'UTF-8'
}
/**
* ANTLR Generated Source
*/
generateGrammarSource {
inputs.files fileTree( antlrGrammarDir ).include( '*.g4' )
maxHeapSize = "256m"
arguments += [ '-package', antlrGeneratedParserPackage ]
arguments += [ '-listener', '-visitor' ]
outputDirectory = file( "$projectDir/$antlrGeneratedParserBaseDir/$antlrGeneratedParserPackageDir" )
}
/**
* ANTLR Generated Test Sources
*/
generateTestGrammarSource {
inputs.files fileTree( antlrGrammarDir ).include( '*.g4' )
maxHeapSize = "256m"
arguments += [ '-package', antlrGeneratedParserPackage ]
arguments += [ '-listener', '-visitor' ]
outputDirectory = file( "$projectDir/$antlrGeneratedParserBaseDir/$antlrGeneratedParserPackageDir" )
}
/**
* Custom task: clean the ANTLR generated sources
*/
clean {
// Clean the ANTLR generated sources
delete generatedSrcDir
doLast{
var userDir = file( "${System.getProperty('user.home')}/.boxlang/classes" )
if ( userDir.exists() ) {
userDir.deleteDir()
println "+ Cleared user home classes " + userDir.toString()
}
println "+ Cleaned ANTLR generated sources"
}
}
/**
* Source Code Formatting
*/
spotless {
java {
target fileTree( "." ) {
include "**/*.java"
exclude "**/build/**", "bin/**", "examples/**", "src/main/java/ortus/boxlang/runtime/testing/**", "src/main/gen/**", "src/main/antlr/gen"
}
eclipse().configFile( "workbench/ortus-java-style.xml" )
toggleOffOn()
}
}
/**
* Generate/Scaffold technical documentation
*/
task generateTechnicalDocumentation( type: Javadoc ) {
source = sourceSets.main.java
dependsOn compileJava, serviceLoaderBuild
def classPaths = new ArrayList<File>( sourceSets.main.runtimeClasspath.getFiles() )
classPaths.addAll( sourceSets.main.java.getFiles() )
options.classpath( classPaths )
classpath = sourceSets.main.allJava
options.addBooleanOption( "Xdoclint:none", true )
exclude '**/boxlang/parser/**'
options.addBooleanOption( 'html5', true )
options.doclet = "ortus.boxlang.tools.doclets.BoxLangDoclet"
options.docletpath = classPaths
}
/**
* Generate/Scaffold technical documentation
*/
task parseBifDocs( type: Javadoc, dependsOn: compileJava ) {
options.addBooleanOption( "Xdoclint:none", true )
exclude '**/boxlang/parser/**'
options.addBooleanOption( 'html5', true )
options.doclet = "ortus.boxlang.tools.doclets.BIFDoclet"
options.docletpath = rootProject.files( 'bin/main' ).asList()
}
/**
* Test Task Customizations
*/
test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
dependsOn compileJava, compileTestJava
//exclude '**/resources/**'
}
/**
* Bump the major version number
*/
task bumpMajorVersion {
doLast{
bumpVersion( true )
}
}
/**
* Bump the minor version number
*/
task bumpMinorVersion {
doLast{
bumpVersion( false, true )
}
}
/**
* Bump the patch version number
*/
task bumpPatchVersion {
doLast{
bumpVersion( false, false, true )
}
}
/**
* Bump the beta version number
*/
task bumpBetaVersion {
doLast{
bumpVersion( false, false, false, true )
}
}
/**
* Utility to copy dependencies to build/dependencies
* Useful for testing and deebugging
*/
task getDependencies( type: Copy ) {
from sourceSets.main.runtimeClasspath
into 'build/dependencies/'
}
spotless{
java{
targetExclude 'modules/**'
}
}