Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
311 lines (262 loc) · 10.3 KB
/
Copy pathbuild.gradle
File metadata and controls
311 lines (262 loc) · 10.3 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*
* This project requires ablunit to 'test', along with corelib for runtime and compile-time
*/
import com.progress.gradle.abl.tasks.*
import com.progress.gradle.abl.*
import java.time.*
import groovy.io.*
import groovy.json.*
plugins {
id 'progress.openedge.abl-base' version '2.3.0'
id "base"
}
group = 'com.openedge.injectabl'
/**
* Please makes sure you set this in your environment before beginning this build
*/
String dlc = System.getenv('DLC')
if (dlc == null ) {dlc = (project.hasProperty('dlc') ? project.property('dlc') : null)}
// Determine the compiler options
// one or more of req-ret-val, req-full-kw, req-full-name, req-fld-qual can be used, in a comma-delimited value
String[] ablCompOpts = (project.hasProperty('ablCompilerOpts') ? project.property('ablCompilerOpts') : '').split(',')
// Global debug flag
Boolean dbgProp = (project.hasProperty('dbg') ? project.property('dbg') : 'false').toBoolean()
def libSrcPaths = []
// Should be in abl.pctTaskArgs but it has to be created first, otherwise we get a 'null' error
// the dir is created in ResolveOpenEdgeDependancies.doFirst
File avmTempDir = file("${buildDir}/temp")
// Doc at https://docs.progress.com/bundle/openedge-devops-framework/page/ABLExtension.html
abl {
rcodeDir = file("${buildDir}/rcode") // is the default; may not be needed
avmOptions {
tty.enabled='true'
startupParameters='-cpinternal UTF-8'
tmpDir=avmTempDir.path
}
compileOptions {
multiCompile.enabled=true
xref.enabled = true
xrefXml.enabled=true
strictOptions.requireReturnValues = '' //ablCompOpts.contains('req-ret-val')
strictOptions.requireFullKeywords = '' //ablCompOpts.contains('req-full-kw')
strictOptions.requireFullNames = '' //ablCompOpts.contains('req-full-names')
strictOptions.requireFieldQualifiers = '' //ablCompOpts.contains('req-fld-qual')
}
}
// dependency repo setup
repositories {
mavenCentral()
}
task initBuildDir (){
delete("${buildDir}/resources")
}
task extractCorelibPl(type: ExtractPL){
from("${abl.dlcHome}/src/OpenEdge.Core.pl")
into("${buildDir}/dlc-src/")
arguments = [ dirmode:"0777", encoding : 'undefined' ]
}
task extractSources() {
dependsOn extractCorelibPl
libSrcPaths << "${buildDir}/dlc-src/"
}
task ResolveOpenEdgeDependancies(){
dependsOn extractSources
doFirst() {
avmTempDir.mkdirs()
}
}
task createManifest(type: ABLRun){
dependsOn ResolveOpenEdgeDependancies
outputs.file("${buildDir}/MANIFEST.MF")
procedure = 'bitness.p'
wrkDir = "${buildDir}"
propath = files('src/main/resources')
arguments = [noErrorOnQuit: 'true',
resultProperty: 'bitness',
debugPCT: dbgProp,
failOnError: 'false' ]
// Need to doLast so that we have the OE version
doLast {
// resolving this here means that the Ant manifest task behaves
def oeVer = "${abl.openedgeVersion}"
ant.manifest(file: file("${buildDir}/MANIFEST.MF")) {
ant.attribute( name: "Build-Date", value: OffsetDateTime.now( ZoneOffset.UTC ).format("yyyy-MM-dd'T'HH:mm:ss.SSSX"))
ant.attribute( name: "Build-OS", value: System.getProperty('os.name') + " " + System.getProperty('os.arch') + " " + System.getProperty('os.version'))
ant.section(name: "InjectABL") {
ant.attribute( name:"InjectABL-Version", value:"${version}")
ant.attribute( name:"InjectABL-Description", value:'OpenEdge InjectABL Library')
ant.attribute( name:"Package-Type", value:"\${packageType}")
}
ant.section(name: "OpenEdge") {
ant.attribute( name:"DLC-Version", value:"${abl.openedgeVersion}")
ant.attribute( name:"DLC-Bitness", value:"${ant.bitness}")
}
}
}
}
// this task creates the source pl file
task packageSourceCode(type: Zip){
dependsOn createManifest
destinationDirectory = file("${buildDir}/dist/")
archiveBaseName = "${rootProject.name}"
archiveClassifier = "sources"
archiveVersion = "${version}"
archiveExtension = "zip"
from('src/main/abl', "${buildDir}/MANIFEST.MF")
expand(packageType: "sources")
include("**/*")
exclude("**/*.r")
}
task createPF(type: Copy) {
outputs.file("${buildDir}/resources/main/build.pf")
outputs.file("${buildDir}/resources/test/build.pf")
outputs.file("${buildDir}/resources/test/run.pf")
// in case there are any params passed in and also in the PF
String params = project.hasProperty('ablStartupParams') ? project.property('ablStartupParams') : '#none'
// this "into"'s are relative to the main "into" below
from("src/main/resources") { into "main" }
from("src/test/resources") { into "test" }
include "*.pf"
into "${buildDir}/resources"
expand(startupParams: params,
projectDir: project.projectDir,
buildDir: "${buildDir}" )
filePermissions {
unix('rwxrwxr--')
}
dirPermissions {
unix('rwxrwxr--')
}
}
// this task compiles the TEST code to verify there are no compiler errors
task compileTest(type: ABLCompile) {
dependsOn ResolveOpenEdgeDependancies
dependsOn createPF
outputs.dir("${buildDir}/tests")
//outputs.file("${buildDir}/temp/compileTest-result.json")
avmOptions {
parameterFile = file("${buildDir}/resources/test/build.pf").absolutePath
tmpDir = avmTempDir.path
}
compileOptions {
outputType = 'json'
multiCompile.enabled=true
xrefDir = "${buildDir}/tests"
}
rcodeDir = file("${buildDir}/tests").path
include('**/*.cls')
include('**/*.p')
source('src/test/abl')
arguments = [debugPCT: dbgProp]
doFirst {
// set propath here since we only know the source paths at runtime, not evaluation time
propath = files('src/test/abl',
'src/main/abl',
libSrcPaths)
}
doLast() {
logWarnings(file("$buildDir/tests/.pct/"), "compileTest")
}
}
// write compiler warning to the build log
def logWarnings(File pctDir, String logGrp) {
pctDir.traverse(type: FileType.FILES, nameFilter: ~/.*\.warnings/ )
{ logger.warn("[:$logGrp] " + it.text.trim()) }
}
// This task compiles all the source code
task compileCode(type: ABLCompile) {
dependsOn ResolveOpenEdgeDependancies
dependsOn createPF
outputs.dir("${abl.rcodeDir}/OpenEdge/InjectABL")
outputs.file("${buildDir}/temp/compileCode-result.json")
avmOptions {
parameterFile = file("${buildDir}/resources/main/build.pf").absolutePath
tmpDir = avmTempDir.path
}
// we use preprocessed files for doc
compileOptions {
preprocess.enabled = true
preprocessDir = "${buildDir}/preprocess"
outputType = 'json'
strictOptions.requireFullNames = 'error'
strictOptions.requireFieldQualifiers ='error'
strictOptions.requireFullKeywords ='error'
strictOptions.requireReturnValues ='error'
}
rcodeDir = abl.rcodeDir // in theory, can leave this to the default; in practice, not
source('src/main/abl')
include('**/*.cls')
include('**/*.p')
doFirst {
// set the propath here, not in the evaluation phase, because the
// source PLs are only unzipped now
propath = files('src/main/abl',
libSrcPaths)
}
doLast {
logWarnings(file("$buildDir/rcode/.pct/"), "compileCode")
}
}
// This task creates the rcode procedure library along with the manifest file
task packageCode(type: PL){
dependsOn compileCode
dependsOn createManifest
inputs.file("${buildDir}/MANIFEST.MF")
inputs.dir("${abl.rcodeDir}/OpenEdge/InjectABL")
outputs.file("${buildDir}/dist/${rootProject.name}-${version}-tty.pl")
plFile = "${buildDir}/dist/${rootProject.name}-${version}-tty.pl"
// the compiler adds r-code for classes that aren't part of this package, so we
// need to be explicit about what we include
from("${buildDir}/rcode" , 'MANIFEST.MF')
include('**/*.r', 'MANIFEST.MF')
codepage = 'undefined'
arguments = [encoding: 'undefined' ]
doFirst {
copy {
from "${buildDir}/MANIFEST.MF"
into abl.rcodeDir
expand(packageType: 'tty')
}
}
}
task ablTest(type: ABLUnit) {
dependsOn createPF
dependsOn packageCode
dependsOn compileTest
source('src/test/abl')
inputs.file("${buildDir}/dist/${rootProject.name}-${version}-tty.pl")
outputs.file('results.xml')
//outputDir does not work on Linux, per https://docs.progress.com/bundle/openedge-devops-framework/page/ABLUnit.html
profiler {
enabled = true
coverage = true
outputDir = "${buildDir}/profiler"
}
arguments = [noErrorOnQuit: true,
failOnError: false,
debugPCT: dbgProp,
cpInternal: 'UTF-8',
cpStream:'UTF-8',
writeLog: 'false']
avmOptions {
tmpDir = avmTempDir.path
parameterFile = "${buildDir}/resources/test/run.pf"
}
doFirst() {
// set propath here since we only know the source paths at runtime, not evaluation time
propath = files("src/test/abl", // for other non-code artifacts needed by the tests
libSrcPaths, // other dependencies
"${buildDir}/dist/${rootProject.name}-${version}-tty.pl" // project rcode being tested
)
}
doLast() {
// No native Gradle move-file task exists
ant.move(file:'results.xml', todir: "${buildDir}/tests/")
if (!file("${buildDir}/tests/results.xml").exists() ) {
throw new GradleException("ABLUnit results file ${buildDir}/tests/results.xml not found")
}
def results = new XmlSlurper().parse( file("${buildDir}/tests/results.xml"))
logger.info("***** TEST RESULTS: ${buildDir}/tests/results.xml: tests=${results.@tests}; errors=${results.@errors}; failures=${results.@failures}; skipped=${results.@skipped}")
}
}
defaultTasks 'packageSourceCode', 'packageCode', 'ablTest'