-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
283 lines (242 loc) · 9.97 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
plugins {
id 'com.moowork.node' version '1.2.0'
id 'net.researchgate.release' version '2.4.0'
}
node {
version = '6.11.2'
npmVersion = '3.10.10'
workDir file("rcp/org.testeditor.web.testexecutionlogview/node")
download = true
}
def targetPlatform = "$projectDir/target-platform"
task npmInstallDep(type: NpmTask, dependsOn: npmSetup){
group 'Node'
workingDir file("rcp/org.testeditor.web.testexecutionlogview")
description 'Installs the NodeJS packages'
args = [ 'install' ]
}
task npmInstallTeLogView(type: NpmTask, dependsOn: npmInstallDep) {
group 'Node'
workingDir file("rcp/org.testeditor.web.testexecutionlogview")
description 'Typescript compile'
args = [ 'run-script', 'tsc' ]
}
task copyTeLogViewToRcp(type: Copy, dependsOn: npmInstallTeLogView) {
from 'rcp/org.testeditor.web.testexecutionlogview'
into 'rcp/org.testeditor.rcp4.views.tcltestrun/web-app'
exclude 'node'
exclude 'typings'
exclude 'pom.xml'
exclude 'package.json'
}
task preBuildWeb(dependsOn: [copyTeLogViewToRcp]) {
}
task buildTarget(type: MavenExec) {
inputs.files fileTree(dir: targetPlatform, exclude: '**/target/**')
outputs.dir file("$targetPlatform/org.testeditor.releng.target.updatesite/target/site")
workingDir targetPlatform
args 'clean', 'verify'
}
task cleanTarget(type: MavenExec) {
workingDir targetPlatform
args 'clean'
}
task assemble() {
}
// TODO define inputs and outputs
task build(type: MavenExec, dependsOn: buildTarget) {
def branch = getBranchName();
def profileParameter = '';
if (branch.startsWith('develop') || branch.startsWith('master')) {
profileParameter = '-Prcp,product'
}
workingDir projectDir
args 'clean', 'install', '-Dsurefire.useFile=false', '-Dtycho.localArtifacts=ignore', profileParameter
}
task deploy(type: MavenExec) {
workingDir projectDir
args 'deploy', '-DskipTests', '-Dtycho.localArtifacts=ignore'
}
// TODO should be dependent on build (but build needs to be incremental for that)
task buildProduct(type: MavenExec) {
workingDir projectDir
args 'package' , '-Pproduct,rcp', '-DskipTests', '-Dtycho.localArtifacts=ignore'
}
task updateTargetVersion(type: MavenExec) {
workingDir targetPlatform
args 'org.eclipse.tycho:tycho-versions-plugin:set-version',
'-Dtycho.mode=maven', '-Dartifacts=org.testeditor.releng.target.parent',
"-DnewVersion=$project.version"
}
task updateMvnVersion(type: MavenExec) {
workingDir projectDir
args 'org.eclipse.tycho:tycho-versions-plugin:set-version',
'-Dtycho.mode=maven', '-Dartifacts=org.testeditor.releng.parent',
"-DnewVersion=$project.version"
}
task updateTargetVersionAfterVersionUpdate(type: MavenExec) {
workingDir targetPlatform
doFirst {
args 'org.eclipse.tycho:tycho-versions-plugin:set-version',
'-Dtycho.mode=maven', '-Dartifacts=org.testeditor.releng.target.parent',
"-DnewVersion=$project.version"
}
}
task updateMvnVersionAfterVersionUpdate(type: MavenExec) {
workingDir projectDir
doFirst {
args 'org.eclipse.tycho:tycho-versions-plugin:set-version',
'-Dtycho.mode=maven', '-Dartifacts=org.testeditor.releng.parent',
"-DnewVersion=$project.version"
}
}
task readProjectVersion {
doLast {
def props = new Properties()
new File("gradle.properties").withInputStream {
stream -> props.load(stream)
}
println("got new project version ${props.get('version')}")
project.version = props.get('version')
println("project.version=$project.version")
}
}
readProjectVersion.shouldRunAfter(updateVersion)
updateMvnVersionAfterVersionUpdate.dependsOn(readProjectVersion)
updateTargetVersionAfterVersionUpdate.dependsOn(readProjectVersion)
beforeReleaseBuild.dependsOn(updateTargetVersion, updateMvnVersion)
commitNewVersion.dependsOn(updateTargetVersionAfterVersionUpdate, updateMvnVersionAfterVersionUpdate)
release {
preTagCommitMessage = '[release]'
tagCommitMessage = '[release]'
newVersionCommitMessage = '[release] new version'
tagTemplate = 'v${version}'
buildTasks = []
}
/**
* Rail-road diagram stuff below.
*/
def rrdAntlr4 = "rrd-antlr4-0.1.2.jar"
def String buildNestedParenthesisRegex(int level) {
def preParen = "(?<!')\\(" // opening braces ( must not be preceeded by a ' to avoid string constant matching
def postParen = "\\)" // closing braces
def anyNonParenthesis = "[^()]*(('\\(')[^()]*)?" // may hold '(' as an exception to that rule, since this constant appears once in a while in the grammar
def result = preParen + anyNonParenthesis + postParen
for(int i; i<level; i++) {
result = preParen+"("+anyNonParenthesis+result+")*"+anyNonParenthesis+postParen
}
return result
}
def String convertToAntlr4(String antlr3) {
def newContent = antlr3
.replaceAll("(?<!')\\{[^{}]*\\}\\??(?<!')=>","") // replace all code prefix expression
.replaceAll(buildNestedParenthesisRegex(7)+"[^()]*\\??(?<!')=>","") // remove all grammar prefix expressions
def index=newContent.indexOf('entryRule')
def codeRemoved = newContent.substring(0,index)+
newContent.substring(index)
.replaceAll("finally[ \t\n\r]*\\{[^{}]*\\}","") // finally code block after rule
.replaceAll("@init","") // init code block
.replaceAll("@after","") // after code block
.replaceAll("(?<!')\\([ \t\r\n]*\\)","") // empty block of parenthesis
.replaceAll("(?<!')\\{(?!')[^{}]*\\}","") // code block
.replaceAll("(?<!')\\{(?!')[^{}]*\\}","") // code block (get the outer ones, too)
.replaceAll("~\\((\\([^()]+\\))\\)",'~$1') // negation with double parenthesis (antlr4 wants one)
.replaceAll("entryRule[^;]*;", "") // remove all entry rules up to next rule definition
.replaceAll("(?<!')\\([ \t\r\n]*\\)","") // remove empty block of parenthesis
// --- the following two rules reduce the length of each rule name but will result in different graphics
// the rrd-antlr4 converter seems to detect rules by having the prefix 'rule'
.replaceAll("rule(?=[A-Z])", '') // remove preceeding rule before every syntax rule name
.replaceAll("returns[ ]*\\[[^\\]]*\\]", "") // remove returning commands of each rule (
return codeRemoved
}
// TODO should be dependent on build (but build needs to be incremental for that)
task buildAntlr4Grammars {
description = "convert grammars of all language from antlr3 to (a reduced) antlr4 format"
group = "Documentation"
doFirst {
println "generate reduced grammar"
}
doLast {
println "Aml grammar"
def amlFileContents = new File("${projectDir}/aml/org.testeditor.aml.dsl/src-gen/org/testeditor/aml/dsl/parser/antlr/internal/InternalAml.g").getText('UTF-8')
println "Lines read " + amlFileContents.count('\n').toString()
new File("${projectDir}/docs/application-modelling-language.g4").write(convertToAntlr4(amlFileContents))
println "Tsl Grammar"
def tslFileContents = new File("${projectDir}/tsl/org.testeditor.tsl.dsl/src-gen/org/testeditor/tsl/dsl/parser/antlr/internal/InternalTsl.g").getText('UTF-8')
println "Lines read: " + tslFileContents.count('\n').toString()
new File("${projectDir}/docs/test-specification-language.g4").write(convertToAntlr4(tslFileContents))
println "Tcl grammar"
def tclFileContents = new File("${projectDir}/tcl/org.testeditor.tcl.dsl/src-gen/org/testeditor/tcl/dsl/parser/antlr/internal/InternalTcl.g").getText('UTF-8')
println "Lines read: " + tclFileContents.count('\n').toString()
new File("${projectDir}/docs/test-case-language.g4").write(convertToAntlr4(tclFileContents))
}
doLast {
println "generation finished."
def tclg4textLines = new File("${projectDir}/docs/test-case-language.g4").getText('UTF-8').count('\n')
println "Tcl grammar contains: ${tclg4textLines} lines"
def tslg4textLines = new File("${projectDir}/docs/test-specification-language.g4").getText('UTF-8').count('\n')
println "Tsl grammar contains: ${tslg4textLines} lines"
def amlg4textLines = new File("${projectDir}/docs/application-modelling-language.g4").getText('UTF-8').count('\n')
println "Aml grammar contains: ${amlg4textLines} lines"
}
}
task createAmlRRD(type: JavaExec) {
dependsOn(buildAntlr4Grammars)
description = "create rail road syntax diagrams for application modelling language"
group = "Documentation"
main = "-jar"
workingDir = "${projectDir}/docs"
args (
rrdAntlr4,
"application-modelling-language.g4"
)
}
task createTslRRD(type: JavaExec) {
dependsOn(buildAntlr4Grammars)
description = "create rail road syntax diagrams for test specification language"
group = "Documentation"
main = "-jar"
workingDir = "${projectDir}/docs"
args (
rrdAntlr4,
"test-specification-language.g4"
)
}
task createTclRRD(type: JavaExec) {
dependsOn(buildAntlr4Grammars)
description = "create rail road syntax diagrams for test case language"
group = "Documentation"
main = "-jar"
workingDir = "${projectDir}/docs"
args (
rrdAntlr4,
"test-case-language.g4"
)
}
task createAllRRDs {
dependsOn(createAmlRRD,createTslRRD,createTclRRD)
description = "create rail road syntax diagrams for all languages (Aml, Tsl, Tcl)"
group = "Documentation"
}
def String getBranchName() {
def branch = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
return branch
}
/**
* Prefills the commandLine with the Maven executable.
*/
class MavenExec extends Exec {
MavenExec() {
super()
def isWindows = org.gradle.internal.os.OperatingSystem.current().windows
if (isWindows) {
commandLine 'cmd', '/c', 'mvn'
} else {
commandLine 'mvn'
}
}
}