Skip to content

Commit 6933d86

Browse files
Implement Gradle Buildsystem (#1271)
* Gradle build * implement SpotBugs, PMD and JaCoCo * implement RR diagrams * Move Special Oracle Test resources into the correct package Implement a basic Gradle/Maven compatibility workaround for the Special Oracle Test * Fix the Gradle Wrapper and add the folder to git
1 parent d662484 commit 6933d86

285 files changed

Lines changed: 483 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated by maven
22
/target
3+
/build
34

45
# Generated by javacc-maven-plugin
56
/bin
@@ -17,4 +18,6 @@
1718
*.jj~
1819
*.java~
1920
*.yml~
20-
/nbproject/
21+
/nbproject/
22+
23+
/.gradle

build.gradle

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
plugins {
2+
id 'java'
3+
id 'maven-publish'
4+
id "ca.coglinc2.javacc" version "3.0.0"
5+
id 'jacoco'
6+
id "com.github.spotbugs" version "4.7.2"
7+
id 'pmd'
8+
9+
// download the RR tools which have no Maven Repository
10+
id "de.undercouch.download" version "4.1.2"
11+
}
12+
13+
group = 'com.github.jsqlparser'
14+
version = '4.2-SNAPSHOT'
15+
description = 'JSQLParser library'
16+
java.sourceCompatibility = JavaVersion.VERSION_1_8
17+
18+
repositories {
19+
gradlePluginPortal()
20+
mavenLocal()
21+
maven {
22+
url = uri('https://repo.maven.apache.org/maven2/')
23+
}
24+
}
25+
26+
dependencies {
27+
testImplementation 'commons-io:commons-io:2.6'
28+
testImplementation 'junit:junit:4.13.1'
29+
testImplementation 'org.mockito:mockito-core:2.28.2'
30+
testImplementation 'org.assertj:assertj-core:3.16.1'
31+
testImplementation 'org.apache.commons:commons-lang3:3.10'
32+
testImplementation 'com.h2database:h2:1.4.200'
33+
34+
// for JaCoCo Reports
35+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
36+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
37+
38+
}
39+
40+
compileJavacc {
41+
arguments = [grammar_encoding: 'UTF-8', static: 'false', java_template_type: 'modern']
42+
}
43+
44+
java {
45+
withSourcesJar()
46+
withJavadocJar()
47+
}
48+
49+
jacoco {
50+
toolVersion = "0.8.7"
51+
}
52+
53+
test {
54+
finalizedBy jacocoTestReport // report is always generated after tests run
55+
finalizedBy jacocoTestCoverageVerification
56+
}
57+
58+
jacocoTestReport {
59+
dependsOn test // tests are required to run before generating the report
60+
reports {
61+
xml.required = false
62+
csv.required = false
63+
html.outputLocation = layout.buildDirectory.dir('reports/jacoco')
64+
}
65+
}
66+
67+
jacocoTestCoverageVerification {
68+
violationRules {
69+
rule {
70+
limit {
71+
minimum = 0.842
72+
}
73+
}
74+
}
75+
}
76+
77+
spotbugsMain {
78+
reports {
79+
html {
80+
enabled = true
81+
destination = file("build/reports/spotbugs/main/spotbugs.html")
82+
stylesheet = 'fancy-hist.xsl'
83+
}
84+
}
85+
}
86+
87+
spotbugs {
88+
// fail only on P1 and without the net.sf.jsqlparser.parser.*
89+
excludeFilter = file("spotBugsExcludeFilter.xml")
90+
91+
// do not run over the test, although we should do that eventually
92+
spotbugsTest.enabled = false
93+
}
94+
95+
pmd {
96+
consoleOutput = false
97+
toolVersion = "6.36.0"
98+
99+
sourceSets = [sourceSets.main]
100+
101+
// clear the ruleset in order to use configured rules only, although we should apply the Prio 1 rules eventually
102+
ruleSets = []
103+
rulesMinimumPriority = 1
104+
105+
ruleSetFiles = files("ruleset.xml")
106+
107+
pmdMain {
108+
excludes = [
109+
"build/generated/*"
110+
]
111+
}
112+
}
113+
114+
task renderRR() {
115+
doLast {
116+
// these WAR files have been provided as a courtesy by Gunther Rademacher
117+
// and belong to the RR - Railroad Diagram Generator Project
118+
// https://github.com/GuntherRademacher/rr
119+
//
120+
// Hosting at manticore-projects.com is temporary until a better solution is found
121+
// Please do not use these files without Gunther's permission
122+
download {
123+
src 'http://manticore-projects.com/download/convert.war'
124+
dest "$buildDir/rr/convert.war"
125+
overwrite false
126+
}
127+
128+
download {
129+
src 'http://manticore-projects.com/download/rr.war'
130+
dest "$buildDir/rr/rr.war"
131+
overwrite false
132+
}
133+
134+
javaexec {
135+
standardOutput = new FileOutputStream("${buildDir}/rr/JSqlParserCC.ebnf")
136+
main="-jar";
137+
args = [
138+
"$buildDir/rr/convert.war",
139+
"$buildDir/generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj"
140+
]
141+
}
142+
143+
javaexec {
144+
main="-jar";
145+
args = [
146+
"$buildDir/rr/rr.war",
147+
"-noepsilon",
148+
"-color:#4D88FF",
149+
"-offset:0",
150+
"-width:800",
151+
//"-png",
152+
//"-out:${buildDir}/rr/JSqlParserCC.zip",
153+
"-out:${buildDir}/rr/JSqlParserCC.xhtml",
154+
"${buildDir}/rr/JSqlParserCC.ebnf"
155+
]
156+
}
157+
}
158+
}
159+
160+
161+
publishing {
162+
publications {
163+
maven(MavenPublication) {
164+
from(components.java)
165+
}
166+
}
167+
}
168+
169+
tasks.withType(JavaCompile) {
170+
options.encoding = 'UTF-8'
171+
}

gradle/wrapper/gradle-wrapper.jar

58.1 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

gradlew

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)