-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
127 lines (104 loc) · 3.04 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
plugins {
id 'application'
id 'antlr'
id 'checkstyle'
id 'idea'
id 'jacoco'
}
repositories {
mavenCentral()
}
dependencies {
antlr 'org.antlr:antlr4:4.9.2'
implementation 'org.antlr:antlr4-runtime:4.9.1'
implementation 'com.google.code.gson:gson:2.8.6'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
compileJava {
options.release = 11
}
application {
// Define the main class for the application.
mainClass = 'com.tiobe.gherkin.App'
}
task generateInfo(type: GenerateInfoTask) {
javaVersion = compileJava.options.release.get()
checkerVersion = project.hasProperty('CHECKERVERSION') ? CHECKERVERSION : '?'
jsonFile = file "${project.buildDir}/generated/info.json"
}
def generatedResources = "${project.buildDir}/generatedResources"
task createBuildProperties(type: GenerateBuildPropertiesTask) {
checkerVersion = project.hasProperty('CHECKERVERSION') ? CHECKERVERSION : '?'
propertyFile = file "$generatedResources/build.properties"
}
distributions {
main {
distributionBaseName = 'DutchPickle'
contents {
from "${project.buildDir}/generated/info.json"
}
}
}
[distZip, distTar, installDist]*.dependsOn generateInfo
tasks.named('test') {
// Use junit platform for unit tests.
useJUnitPlatform()
testLogging.showStandardStreams = true // display stdout/stderr during tests
}
jacocoTestReport {
reports {
xml.required.set(true)
}
}
/**
* Without the next section Gradle will add a 'compile' dependency on Antlr3:
* https://github.com/gradle/gradle/issues/820
*/
configurations {
compile {
extendsFrom = extendsFrom.findAll { it != configurations.antlr }
}
}
generateGrammarSource {
outputDirectory = file("${project.buildDir}/generated-src/antlr/main/com/tiobe/antlr")
}
checkstyleMain.exclude '**/com/tiobe/antlr/**'
class GenerateBuildPropertiesTask extends DefaultTask {
@Input
String checkerVersion
@OutputFile
File propertyFile
@TaskAction
def generateBuildProperties() {
def props = new java.util.Properties()
def comment = 'Generated by TIOBE Gradle build'
props.setProperty('version', checkerVersion)
propertyFile.withWriter { props.store(it, comment) }
}
}
class GenerateInfoTask extends DefaultTask {
@Input
String javaVersion
@Input
String checkerVersion
@OutputFile
File jsonFile
@TaskAction
def generateInfo() {
def info = [
revision: checkerVersion,
requirements: [
[ id: "java", version: javaVersion ],
],
version: checkerVersion,
]
def json = groovy.json.JsonOutput.toJson(info)
def pretty = groovy.json.JsonOutput.prettyPrint(json) + System.lineSeparator()
jsonFile.text = pretty
}
}
sourceSets {
main.output.dir(generatedResources, builtBy: 'createBuildProperties')
}