Skip to content

Commit 709476c

Browse files
build: update gradle syntax
Signed-off-by: Andreas Reichel <[email protected]>
1 parent 5b64f22 commit 709476c

File tree

2 files changed

+96
-97
lines changed

2 files changed

+96
-97
lines changed

build.gradle

Lines changed: 96 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,41 @@ def getVersion = { boolean considerSnapshot ->
2727
Integer minor = 0
2828
Integer patch = null
2929
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+
}
5447

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"
6052
}
61-
return patch!=null
53+
54+
return patch != null
6255
? "${major}.${minor}.${patch}${snapshot}"
63-
: "${major}.${minor}${snapshot}"
56+
: "${major}.${minor}${snapshot}"
6457
}
6558

59+
6660
// for publishing a release, call Gradle with Environment Variable RELEASE:
6761
// RELEASE=true gradle JSQLParser:publish
6862
version = getVersion( !System.getenv("RELEASE") )
6963
group = 'com.github.jsqlparser'
7064
description = 'JSQLParser library'
71-
archivesBaseName = "JSQLParser"
7265

7366
repositories {
7467
gradlePluginPortal()
@@ -262,14 +255,13 @@ jacocoTestCoverageVerification {
262255

263256
spotbugsMain {
264257
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"
270261
}
271262
}
272263

264+
273265
spotbugs {
274266
// fail only on P1 and without the net.sf.jsqlparser.parser.*
275267
excludeFilter = file("config/spotbugs/spotBugsExcludeFilter.xml")
@@ -329,58 +321,58 @@ tasks.withType(Checkstyle).configureEach {
329321

330322
tasks.register('renderRR') {
331323
dependsOn(compileJavacc)
324+
332325
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
339329
download.run {
340330
src 'http://manticore-projects.com/download/convert.war'
341-
dest "$buildDir/rr/convert.war"
331+
dest new File(rrDir, "convert.war")
342332
overwrite false
343333
onlyIfModified true
344334
}
345335

336+
// Download rr.war
346337
download.run {
347338
src 'http://manticore-projects.com/download/rr.war'
348-
dest "$buildDir/rr/rr.war"
339+
dest new File(rrDir, "rr.war")
349340
overwrite false
350341
onlyIfModified true
351342
tempAndMove true
352343
}
353344

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"
357349
args = [
358-
"$buildDir/rr/convert.war",
359-
"$buildDir/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
360352
]
361-
}
353+
}.get().exec()
362354

363-
javaexec {
364-
main = "-jar"
355+
// Generate RR diagrams
356+
tasks.register("generateRR", JavaExec) {
357+
mainClass = "-jar"
365358
args = [
366-
"$buildDir/rr/rr.war",
359+
new File(rrDir, "rr.war").absolutePath,
367360
"-noepsilon",
368361
"-color:#4D88FF",
369362
"-offset:0",
370363
"-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
375366
]
376-
}
367+
}.get().exec()
377368
}
378369
}
379370

371+
380372
tasks.register('gitChangelogTask', GitChangelogTask) {
381373
fromRepo = file("$projectDir")
382374
file = new File("${projectDir}/src/site/sphinx/changelog.rst")
383-
fromRef = "4.0"
375+
fromRevision = "4.0"
384376
//toRef = "1.1";
385377

386378
// switch off the formatter since the indentation matters for Mark-down
@@ -443,7 +435,7 @@ xslt {
443435
)
444436

445437
// Transform every .xml file in the "input" directory.
446-
input "$buildDir/rr/JSqlParserCC.xhtml"
438+
input layout.buildDirectory.file("rr/JSqlParserCC.xhtml")
447439
output outFile
448440
}
449441

@@ -459,11 +451,11 @@ tasks.register('sphinx', Exec) {
459451
.. |JSQLPARSER_SNAPSHOT_VERSION| replace:: ${getVersion(true)}
460452
.. |JSQLPARSER_STABLE_VERSION_LINK| raw:: html
461453
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>
463455
464456
.. |JSQLPARSER_SNAPSHOT_VERSION_LINK| raw:: html
465457
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>
467459
468460
"""
469461

@@ -474,7 +466,7 @@ tasks.register('sphinx', Exec) {
474466
, "-Drelease=${getVersion(false)}"
475467
, "-Drst_prolog=$PROLOG"
476468
, "${projectDir}/src/site/sphinx"
477-
, "${project.buildDir}/sphinx"
469+
, layout.buildDirectory.file("sphinx").get().asFile
478470
]
479471

480472
executable "sphinx-build"
@@ -494,10 +486,11 @@ publish {
494486

495487
publishing {
496488
publications {
497-
mavenJava(MavenPublication) {
489+
create("mavenJava", MavenPublication) {
498490
artifactId = 'jsqlparser'
499491

500492
from components.java
493+
501494
versionMapping {
502495
usage('java-api') {
503496
fromResolutionOf('runtimeClasspath')
@@ -506,54 +499,61 @@ publishing {
506499
fromResolutionResult()
507500
}
508501
}
502+
509503
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+
513508
licenses {
514509
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')
517512
}
518513
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')
521516
}
522517
}
518+
523519
developers {
524520
developer {
525-
id = 'twa'
526-
name = 'Tobias Warneke'
527-
521+
id.set('twa')
522+
name.set('Tobias Warneke')
523+
email.set('[email protected]')
528524
}
529525
developer {
530-
id = 'are'
531-
name = 'Andreas Reichel'
532-
526+
id.set('are')
527+
name.set('Andreas Reichel')
528+
email.set('[email protected]')
533529
}
534530
}
531+
535532
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')
539536
}
540537
}
541538
}
542539
}
540+
543541
repositories {
544542
maven {
545-
name "ossrh"
543+
name = "ossrh"
546544
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+
549548
credentials {
550-
username = System.getenv("ossrhUsername")
551-
password = System.getenv("ossrhPassword")
549+
username = providers.environmentVariable("ossrhUsername").orNull
550+
password = providers.environmentVariable("ossrhPassword").orNull
552551
}
553552
}
554553
}
555554
}
556555

556+
557557
signing {
558558
//def signingKey = findProperty("signingKey")
559559
//def signingPassword = findProperty("signingPassword")
@@ -571,12 +571,13 @@ tasks.withType(JavaCompile).configureEach {
571571

572572
remotes {
573573
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")
577577
}
578578
}
579579

580+
580581
tasks.register('upload') {
581582
doFirst {
582583
if (findProperty("${project.name}.host") == null) {
@@ -593,13 +594,16 @@ tasks.register('upload') {
593594
session(remotes.webServer) {
594595
def versionStable = getVersion(false)
595596
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()) {
597598
put from: file, into: "download/${project.name}-${versionStable}"
598599
}
599600
}
600601
}
601602
}
603+
604+
dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc)
602605
}
603-
check.dependsOn jacocoTestCoverageVerification
604-
upload.dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc)
605606

607+
check {
608+
dependsOn jacocoTestCoverageVerification
609+
}

settings.gradle

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)