@@ -27,48 +27,41 @@ def getVersion = { boolean considerSnapshot ->
27
27
Integer minor = 0
28
28
Integer patch = null
29
29
Integer build = null
30
- def commit = null
31
- def snapshot = " "
32
- new ByteArrayOutputStream (). withStream { os ->
33
- exec {
34
- args = [
35
- " --no-pager"
36
- , " describe"
37
- , " --tags"
38
- , " --always"
39
- , " --dirty=-SNAPSHOT"
40
- ]
41
- executable " git"
42
- standardOutput = os
43
- }
44
- def versionStr = os. toString(). trim()
45
- def pattern = / (?<major>\d *)\. (?<minor>\d *)(\. (?<patch>\d *))?(-(?<build>\d *)-(?<commit>[a-zA-Z\d ]*))?/
46
- def matcher = versionStr =~ pattern
47
- if (matcher. find()) {
48
- major = matcher. group(' major' ) as Integer
49
- minor = matcher. group(' minor' ) as Integer
50
- patch = matcher. group(' patch' ) as Integer
51
- build = matcher. group(' build' ) as Integer
52
- commit = matcher. group(' commit' )
53
- }
30
+ String commit = null
31
+ String snapshot = " "
32
+
33
+ def versionStr = providers. exec {
34
+ commandLine " git" , " --no-pager" , " describe" , " --tags" , " --always" , " --dirty=-SNAPSHOT"
35
+ }. standardOutput. asText. get(). trim()
36
+
37
+ def pattern = / (?<major>\d *)\. (?<minor>\d *)(\. (?<patch>\d *))?(-(?<build>\d *)-(?<commit>[a-zA-Z\d ]*))?/
38
+ def matcher = versionStr =~ pattern
39
+
40
+ if (matcher. find()) {
41
+ major = matcher. group(' major' ) as Integer ?: 0
42
+ minor = matcher. group(' minor' ) as Integer ?: 0
43
+ patch = matcher. group(' patch' ) as Integer ?: null
44
+ build = matcher. group(' build' ) as Integer ?: null
45
+ commit = matcher. group(' commit' ) ?: null
46
+ }
54
47
55
- if (considerSnapshot && ( versionStr. endsWith(' SNAPSHOT' ) || build!= null ) ) {
56
- minor++
57
- if (patch!= null ) patch = 0
58
- snapshot = " -SNAPSHOT"
59
- }
48
+ if (considerSnapshot && (versionStr. endsWith(' SNAPSHOT' ) || build != null )) {
49
+ minor++
50
+ if (patch != null ) patch = 0
51
+ snapshot = " -SNAPSHOT"
60
52
}
61
- return patch!= null
53
+
54
+ return patch != null
62
55
? " ${ major} .${ minor} .${ patch}${ snapshot} "
63
- : " ${ major} .${ minor}${ snapshot} "
56
+ : " ${ major} .${ minor}${ snapshot} "
64
57
}
65
58
59
+
66
60
// for publishing a release, call Gradle with Environment Variable RELEASE:
67
61
// RELEASE=true gradle JSQLParser:publish
68
62
version = getVersion( ! System . getenv(" RELEASE" ) )
69
63
group = ' com.github.jsqlparser'
70
64
description = ' JSQLParser library'
71
- archivesBaseName = " JSQLParser"
72
65
73
66
repositories {
74
67
gradlePluginPortal()
@@ -262,14 +255,13 @@ jacocoTestCoverageVerification {
262
255
263
256
spotbugsMain {
264
257
reports {
265
- html {
266
- enabled = true
267
- destination = file(" build/reports/spotbugs/main/spotbugs.html" )
268
- stylesheet = ' fancy-hist.xsl'
269
- }
258
+ html. required. set(true )
259
+ html. outputLocation. set( layout. buildDirectory. file(" reports/spotbugs/main/spotbugs.html" ). get(). asFile )
260
+ html. stylesheet= " fancy-hist.xsl"
270
261
}
271
262
}
272
263
264
+
273
265
spotbugs {
274
266
// fail only on P1 and without the net.sf.jsqlparser.parser.*
275
267
excludeFilter = file(" config/spotbugs/spotBugsExcludeFilter.xml" )
@@ -329,58 +321,58 @@ tasks.withType(Checkstyle).configureEach {
329
321
330
322
tasks. register(' renderRR' ) {
331
323
dependsOn(compileJavacc)
324
+
332
325
doLast {
333
- // these WAR files have been provided as a courtesy by Gunther Rademacher
334
- // and belong to the RR - Railroad Diagram Generator Project
335
- // https://github.com/GuntherRademacher/rr
336
- //
337
- // Hosting at manticore-projects.com is temporary until a better solution is found
338
- // Please do not use these files without Gunther's permission
326
+ def rrDir = layout. buildDirectory. dir(" rr" ). get(). asFile
327
+
328
+ // Download convert.war
339
329
download. run {
340
330
src ' http://manticore-projects.com/download/convert.war'
341
- dest " $b uildDir /rr/ convert.war"
331
+ dest new File (rrDir, " convert.war" )
342
332
overwrite false
343
333
onlyIfModified true
344
334
}
345
335
336
+ // Download rr.war
346
337
download. run {
347
338
src ' http://manticore-projects.com/download/rr.war'
348
- dest " $b uildDir /rr/rr .war"
339
+ dest new File (rrDir, " rr .war" )
349
340
overwrite false
350
341
onlyIfModified true
351
342
tempAndMove true
352
343
}
353
344
354
- javaexec {
355
- standardOutput = new FileOutputStream (" ${ buildDir} /rr/JSqlParserCC.ebnf" )
356
- main = " -jar"
345
+ // Convert JJ file to EBNF
346
+ tasks. register(" convertJJ" , JavaExec ) {
347
+ standardOutput = new FileOutputStream (new File (rrDir, " JSqlParserCC.ebnf" ))
348
+ mainClass = " -jar"
357
349
args = [
358
- " $b uildDir /rr/ convert.war" ,
359
- " $b uildDir / generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj"
350
+ new File (rrDir, " convert.war" ) . absolutePath ,
351
+ layout . buildDirectory . dir( " generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj" ) . get() . asFile . absolutePath
360
352
]
361
- }
353
+ }. get() . exec()
362
354
363
- javaexec {
364
- main = " -jar"
355
+ // Generate RR diagrams
356
+ tasks. register(" generateRR" , JavaExec ) {
357
+ mainClass = " -jar"
365
358
args = [
366
- " $b uildDir /rr/rr .war" ,
359
+ new File (rrDir, " rr .war" ) . absolutePath ,
367
360
" -noepsilon" ,
368
361
" -color:#4D88FF" ,
369
362
" -offset:0" ,
370
363
" -width:800" ,
371
- // "-png",
372
- // "-out:${buildDir}/rr/JSqlParserCC.zip",
373
- " -out:${ buildDir} /rr/JSqlParserCC.xhtml" ,
374
- " ${ buildDir} /rr/JSqlParserCC.ebnf"
364
+ " -out:${ new File(rrDir, "JSqlParserCC.xhtml")} " ,
365
+ new File (rrDir, " JSqlParserCC.ebnf" ). absolutePath
375
366
]
376
- }
367
+ }. get() . exec()
377
368
}
378
369
}
379
370
371
+
380
372
tasks. register(' gitChangelogTask' , GitChangelogTask ) {
381
373
fromRepo = file(" $projectDir " )
382
374
file = new File (" ${ projectDir} /src/site/sphinx/changelog.rst" )
383
- fromRef = " 4.0"
375
+ fromRevision = " 4.0"
384
376
// toRef = "1.1";
385
377
386
378
// switch off the formatter since the indentation matters for Mark-down
@@ -443,7 +435,7 @@ xslt {
443
435
)
444
436
445
437
// Transform every .xml file in the "input" directory.
446
- input " $b uildDir / rr/JSqlParserCC.xhtml"
438
+ input layout . buildDirectory . file( " rr/JSqlParserCC.xhtml" )
447
439
output outFile
448
440
}
449
441
@@ -459,11 +451,11 @@ tasks.register('sphinx', Exec) {
459
451
.. |JSQLPARSER_SNAPSHOT_VERSION| replace:: ${ getVersion(true)}
460
452
.. |JSQLPARSER_STABLE_VERSION_LINK| raw:: html
461
453
462
- <a href='http://manticore-projects.com/download/JSQLParser -${ getVersion(false)} /JSQLParser -${ getVersion(false)} .jar'>JSQLParser -${ getVersion(false)} .jar</a>
454
+ <a href='http://manticore-projects.com/download/${ project.name } -${ getVersion(false)} /${ project.name } -${ getVersion(false)} .jar'>${ project.name } -${ getVersion(false)} .jar</a>
463
455
464
456
.. |JSQLPARSER_SNAPSHOT_VERSION_LINK| raw:: html
465
457
466
- <a href='http://manticore-projects.com/download/JSQLParser -${ getVersion(false)} /JSQLParser -${ getVersion(true)} .jar'>JSQLParser -${ getVersion(true)} .jar</a>
458
+ <a href='http://manticore-projects.com/download/${ project.name } -${ getVersion(false)} /${ project.name } -${ getVersion(true)} .jar'>${ project.name } -${ getVersion(true)} .jar</a>
467
459
468
460
"""
469
461
@@ -474,7 +466,7 @@ tasks.register('sphinx', Exec) {
474
466
, " -Drelease=${ getVersion(false)} "
475
467
, " -Drst_prolog=$PROLOG "
476
468
, " ${ projectDir} /src/site/sphinx"
477
- , " ${ project.buildDir } / sphinx"
469
+ , layout . buildDirectory . file( " sphinx" ) . get() . asFile
478
470
]
479
471
480
472
executable " sphinx-build"
@@ -494,10 +486,11 @@ publish {
494
486
495
487
publishing {
496
488
publications {
497
- mavenJava( MavenPublication ) {
489
+ create( " mavenJava " , MavenPublication ) {
498
490
artifactId = ' jsqlparser'
499
491
500
492
from components. java
493
+
501
494
versionMapping {
502
495
usage(' java-api' ) {
503
496
fromResolutionOf(' runtimeClasspath' )
@@ -506,54 +499,61 @@ publishing {
506
499
fromResolutionResult()
507
500
}
508
501
}
502
+
509
503
pom {
510
- name = ' JSQLParser library'
511
- description = ' Parse SQL Statements into Abstract Syntax Trees (AST)'
512
- url = ' https://github.com/JSQLParser/JSqlParser'
504
+ name. set(' JSQLParser library' )
505
+ description. set(' Parse SQL Statements into Abstract Syntax Trees (AST)' )
506
+ url. set(' https://github.com/JSQLParser/JSqlParser' )
507
+
513
508
licenses {
514
509
license {
515
- name = ' GNU Library or Lesser General Public License (LGPL) V2.1'
516
- url = ' http://www.gnu.org/licenses/lgpl-2.1.html'
510
+ name. set( ' GNU Library or Lesser General Public License (LGPL) V2.1' )
511
+ url. set( ' http://www.gnu.org/licenses/lgpl-2.1.html' )
517
512
}
518
513
license {
519
- name = ' The Apache Software License, Version 2.0'
520
- url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
514
+ name. set( ' The Apache Software License, Version 2.0' )
515
+ url. set( ' http://www.apache.org/licenses/LICENSE-2.0.txt' )
521
516
}
522
517
}
518
+
523
519
developers {
524
520
developer {
525
- id = ' twa'
526
- name = ' Tobias Warneke'
527
-
521
+ id. set( ' twa' )
522
+ name. set( ' Tobias Warneke' )
523
+
528
524
}
529
525
developer {
530
- id = ' are'
531
- name = ' Andreas Reichel'
532
-
526
+ id. set( ' are' )
527
+ name. set( ' Andreas Reichel' )
528
+
533
529
}
534
530
}
531
+
535
532
scm {
536
- connection = ' scm:git:https://github.com/JSQLParser/JSqlParser.git'
537
- developerConnection
= ' scm:git:ssh://[email protected] :JSQLParser/JSqlParser.git'
538
- url = ' https://github.com/JSQLParser/JSqlParser.git'
533
+ connection. set( ' scm:git:https://github.com/JSQLParser/JSqlParser.git' )
534
+ developerConnection
. set( ' scm:git:ssh://[email protected] :JSQLParser/JSqlParser.git' )
535
+ url. set( ' https://github.com/JSQLParser/JSqlParser.git' )
539
536
}
540
537
}
541
538
}
542
539
}
540
+
543
541
repositories {
544
542
maven {
545
- name " ossrh"
543
+ name = " ossrh"
546
544
def releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
547
- def snapshotsRepoUrl= " https://oss.sonatype.org/content/repositories/snapshots/"
548
- url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
545
+ def snapshotsRepoUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
546
+ url(version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl)
547
+
549
548
credentials {
550
- username = System . getenv (" ossrhUsername" )
551
- password = System . getenv (" ossrhPassword" )
549
+ username = providers . environmentVariable (" ossrhUsername" ). orNull
550
+ password = providers . environmentVariable (" ossrhPassword" ). orNull
552
551
}
553
552
}
554
553
}
555
554
}
556
555
556
+
557
557
signing {
558
558
// def signingKey = findProperty("signingKey")
559
559
// def signingPassword = findProperty("signingPassword")
@@ -571,12 +571,13 @@ tasks.withType(JavaCompile).configureEach {
571
571
572
572
remotes {
573
573
webServer {
574
- host = findProperty(" ${ project.name} .host" )
575
- user = findProperty(" ${ project.name} .username" )
576
- identity = new File (" ${ System.properties[ 'user.home'] } /.ssh/id_rsa" )
574
+ host = findProperty(" ${ project.name} .host" ) ?: " defaultHost " // Provide default if not found
575
+ user = findProperty(" ${ project.name} .username" ) ?: " defaultUsername " // Provide default if not found
576
+ identity = file (" ${ System.getProperty( 'user.home') } /.ssh/id_rsa" )
577
577
}
578
578
}
579
579
580
+
580
581
tasks. register(' upload' ) {
581
582
doFirst {
582
583
if (findProperty(" ${ project.name} .host" ) == null ) {
@@ -593,13 +594,16 @@ tasks.register('upload') {
593
594
session(remotes. webServer) {
594
595
def versionStable = getVersion(false )
595
596
execute " mkdir -p download/${ project.name} -${ versionStable} "
596
- for (File file : fileTree(include :[' *.jar' ], dir :" ${ project.buildDir } / libs" ). collect()) {
597
+ for (File file : fileTree(include :[' *.jar' ], dir : layout . buildDirectory . dir( " libs" ) . get() ). collect()) {
597
598
put from : file, into : " download/${ project.name} -${ versionStable} "
598
599
}
599
600
}
600
601
}
601
602
}
603
+
604
+ dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc)
602
605
}
603
- check. dependsOn jacocoTestCoverageVerification
604
- upload. dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc)
605
606
607
+ check {
608
+ dependsOn jacocoTestCoverageVerification
609
+ }
0 commit comments