Project

Profile

Help

How to connect?
Download (38.6 KB) Statistics
| Branch: | Revision:

he / build.gradle @ a8341bd5

1
plugins {
2
  id "java"
3
  id "maven-publish"
4
  id "signing"
5
//  id "com.cdsap.talaiot" version "1.3.5"
6
}
7

    
8
import org.gradle.internal.os.OperatingSystem;
9

    
10
apply plugin: 'java'
11

    
12
repositories {
13
  mavenLocal()
14
  mavenCentral()
15
  maven { url = "https://org.apache.maven" }
16
  maven { url "https://dev.saxonica.com/maven" }
17
}
18

    
19
configurations.all {
20
  resolutionStrategy {
21
    force 'xml-apis:xml-apis:1.4.01'
22
  }
23
}
24

    
25
configurations {
26
  preprocessor.extendsFrom(runtimeOnly)
27
  jarjarAsm.extendsFrom(implementation)
28
  testDrivers.extendsFrom(testImplementation)
29
  ikvm.extendsFrom(implementation)
30
  compileDotNet.extendsFrom(implementation)
31
  asmDotNet.extendsFrom(implementation)
32
}
33

    
34
// Set saxonLicenseDir in gradle.properties, or from the
35
// command line if you have a license in some other place.
36
if (!hasProperty("saxonLicenseDir")) {
37
  if (System.getenv("SAXON_LICENSE_DIR") != null) {
38
    ext.saxonLicenseDir=System.getenv('SAXON_LICENSE_DIR')
39
  } else {
40
    ext.saxonLicenseDir=System.getenv('HOME') + "/java"
41
  }
42
}
43

    
44
// Set the locations of the W3C test suites
45
if (!hasProperty("w3cQT3TestSuiteDir")) {
46
  ext.w3cQT3TestSuiteDir = System.getenv("W3C_QT3_TEST_SUITE_DIR")
47
}
48
if (!hasProperty("w3cXslt30TestSuiteDir")) {
49
  ext.w3cXslt30TestSuiteDir = System.getenv("W3C_XSLT30_TEST_SUITE_DIR")
50
}
51
if (!hasProperty("w3cXsdTestSuiteDir")) {
52
  ext.w3cXsdTestSuiteDir = System.getenv("W3C_XSD_TEST_SUITE_DIR")
53
}
54

    
55
dependencies {
56
  preprocessor (
57
    [group: 'com.igormaznitsa', name: 'jcp', version: '7.0.4'],
58
    [group: 'com.tonicsystems', name: 'jarjar', version: '0.6' ],
59
    [group: 'net.sf.saxon', name: 'Saxon-HE', version: '10.3' ],
60
    files(saxonLicenseDir)
61
  )
62
  implementation (
63
    [group: 'org.apache.ws.commons.axiom', name: 'axiom-dom', version: '1.2.15'],
64
    [group: 'xom', name: 'xom', version: '1.3.5'],
65
    [group: 'org.jdom', name: 'jdom', version: '1.1.3'],
66
    [group: 'org.jdom', name: 'jdom2', version: '2.0.6'],
67
    [group: 'org.lucee', name: 'dom4j', version: '1.6.1'],
68
    [group: 'xml-resolver', name: 'xml-resolver', version: '1.2' ],
69
    [group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion ],
70
    [group: 'jline', name: 'jline', version: '2.14.6' ],
71
    [group: 'org.jetbrains', name: 'annotations', version: '20.1.0' ],
72
    // PE and EE
73
    [group: 'javax.mail', name: 'javax.mail-api', version: mailVersion ],
74
    [group: 'com.sun.mail', name: 'javax.mail', version: mailVersion ],
75
    [group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: tagsoupVersion],
76
    fileTree(dir: "extra/MyDotNet/classpath"),
77
    fileTree(dir: "extra/MyDotNet/stubs"),
78
    fileTree(dir: "lib/asm-${asmVersion}"),
79
    files("lib/Tidy.jar"),
80
  )
81
  jarjarAsm (
82
    fileTree(dir: "${buildDir}/lib/asm")
83
  )
84
  ikvm (
85
    fileTree(dir: "${ikvmDir}/stubs")
86
  )
87
  compileDotNet (
88
    fileTree(dir: "${ikvmDir}/stubs"),
89
    fileTree(dir: "${ikvmDir}/classpath")
90
  )
91
  asmDotNet (
92
    fileTree(dir: "${ikvmDir}/stubs"),
93
    fileTree(dir: "${ikvmDir}/classpath"),
94
    fileTree(dir: "lib/asm-${asmVersion}")
95
  )
96
  testImplementation (
97
    [group: 'junit', name: 'junit', version: '4.12'],
98
    [group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.2'],
99
    [group: 'org.apache.ant', name: 'ant', version: '1.10.9' ],
100
    files("${buildDir}/classes/${saxonEdition}j"),
101
    files("src/main/resources"),
102
    files("lib/Tidy.jar"),
103
    files(saxonLicenseDir),
104
    fileTree("${buildDir}/lib/asm")
105
  )
106
  testRuntimeOnly (
107
    [group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.2'],
108
    [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.4.2'],
109
    [group: 'org.apache.ant', name: 'ant', version: '1.10.9' ],
110
    files("${buildDir}/classes/${saxonEdition}j")
111
  )
112
}
113

    
114
test {
115
  useJUnitPlatform {
116
    excludeTags 'bytecode'
117
  }
118
}
119

    
120
/*
121
talaiot {
122
  metrics {
123
    performanceMetrics = false
124
  }
125
  publishers {
126
    taskDependencyGraphPublisher {
127
      gexf = false
128
      dot = true
129
      html = false
130
    }
131
  }
132
}
133
*/
134

    
135
ext {
136
  systemOs = OperatingSystem.current()
137
  icu4jJar = null
138
  tagsoupJar = null
139
  mailJar = null
140
  resolverJar = null
141
  version_h = saxonVersion.replace(".", "-")
142
  pathSeparator = System.getProperty("file.separator")
143
}
144

    
145
public class DeleteFilesRecursively {
146
  static void delete(File file){
147
    for (File fspec : file.listFiles()) {
148
      if (fspec.isDirectory()) {
149
        delete(fspec);
150
      } else {
151
        fspec.delete();
152
      }
153
    }
154
    file.delete();
155
  }
156
}
157

    
158
// ============================================================
159
// Have you switched branches?
160
def branch = new ByteArrayOutputStream()
161
def result = exec {
162
  commandLine "git", "branch", "--show-current"
163
  standardOutput = branch;
164
}
165
def currentBranch = branch.toString().trim()
166

    
167
def builtBranch = "none";
168
try {
169
  def xbranch = new BufferedReader(new FileReader(new File("build/built-branch")))
170
  builtBranch = "${xbranch.readLine().trim()}"
171
} catch (FileNotFoundException foe) {
172
  // nop
173
}
174

    
175
if (currentBranch != builtBranch
176
    && (file("${buildDir}/src").exists()
177
        || file("${buildDir}/preprocess").exists()
178
        || file("${buildDir}/filtered").exists()
179
        || file("${buildDir}/classes").exists())) {
180
  println("You appear to have switched to the '${currentBranch}' branch.")
181
  println("Deleting stale build sources...")
182
  DeleteFilesRecursively.delete(new File("${buildDir}/src"))
183
  DeleteFilesRecursively.delete(new File("${buildDir}/preprocess"))
184
  DeleteFilesRecursively.delete(new File("${buildDir}/filtered"))
185
  DeleteFilesRecursively.delete(new File("${buildDir}/classes"))
186
}
187

    
188
// ============================================================
189
// Find jar files that need to be part of the build or release
190
//
191
def filesep = System.getProperty("file.separator")
192
icu4jJar = "${filesep}icu4j-${icu4jVersion}.jar"
193
tagsoupJar = "${filesep}tagsoup-${tagsoupVersion}.jar"
194
mailJar = "${filesep}javax.mail-${mailVersion}.jar"
195
resolverJar = "${filesep}xml-resolver-1.2.jar"
196
configurations.compileClasspath.each { cp ->
197
  if (cp.toString().endsWith(icu4jJar)) {
198
    icu4jJar = cp.toString()
199
  }
200
  if (cp.toString().endsWith(tagsoupJar)) {
201
    tagsoupJar = cp.toString()
202
  }
203
  if (cp.toString().endsWith(mailJar)) {
204
    mailJar = cp.toString()
205
  }
206
  if (cp.toString().endsWith(resolverJar)) {
207
    resolverJar = cp.toString()
208
  }
209
}
210

    
211
apply from: "build-n.gradle"
212
apply from: "build-c.gradle"
213
apply from: "build-doc.gradle"
214

    
215
def pathExists(pathname) {
216
  // Returns true iff pathame is an existing file or directory
217
  try {
218
    // This may throw an error for a Windows pathname, c:/path/to/thing
219
    if (file(pathname).exists()) {
220
      return true;
221
    }
222
  } catch (GradleException e) {
223
    // I don't care
224
  }
225

    
226
  if (OperatingSystem.current().isWindows()) {
227
    try {
228
      // If we're on Windows, try to make c:/path/to/thing work
229
      if (file("file:///${pathname}").exists()) {
230
        return true;
231
      }
232
    } catch (GradleException e) {
233
      // I don't care
234
    }
235
  }
236

    
237
  return false
238
}
239

    
240
// ============================================================
241
// One of the features of Gradle is that you can construct tasks
242
// dynamically during the "configure" phase. This is a feature because
243
// it avoids a lot of tedious repetition of nearly identical tasks. It
244
// has the unfortunate consequence that understanding the tasks
245
// involved becomes harder. I've tried to use this feature sparingly.
246

    
247
["h", "p", "e"].each { initial ->
248
  def release = initial + "e"
249
  def Release = initial.toUpperCase() + "e"
250
  def RELEASE = release.toUpperCase()
251

    
252
  if (release != "he") {
253
    Task libs = task "${release}j_libs"(
254
      description: "Dependency to make sure library files are copie for ${RELEASE}"
255
    ) {
256
      // Just a container to hang dependencies on
257
    }
258

    
259
    Task icu4j = task "${release}j_icu4j"(
260
      type: Copy,
261
      description: "Copy the ICU4J jar into the ${RELEASE} release directory"
262
    ) {
263
      from "${icu4jJar}"
264
      into "${buildDir}/releases/${release}j"
265
    }
266
    libs.dependsOn icu4j
267
  }
268

    
269
  task "${release}j_notices"(
270
    type: Copy,
271
    description: "Copy the notices into the ${RELEASE} release directory"
272
  ) {
273
    into "${buildDir}/releases/${release}j"
274
    from ("src/docs") {
275
      exclude "saxon9"
276
      exclude "tools"
277
      exclude "saxonc-doc"
278
      exclude "welcome"
279
      exclude "notices/APACHE-ANT.txt"
280
      exclude "notices/APACHE-RESOLVER.txt"
281
      exclude "notices/APACHE-TAGSOUP.txt"
282
      exclude "notices/APACHE-XERCES.txt"
283
      exclude "notices/ASM.txt"
284
      exclude "notices/FRIJTERS.txt"
285
      exclude "notices/GPL+CLASSPATH.txt"
286
      exclude "notices/ICU-J.txt"
287
      exclude "notices/LEGAL.txt"
288
    }
289
  }
290

    
291
  task "${release}j_copyTestDrivers"(
292
    dependsOn: ["${release}j_copyTestDriverSources",
293
                "${release}j_copyTestDriverResources"],
294
    description: "Copy test driver sources and resources for ${RELEASE}"
295
  ) {
296
    // Just a container to hang dependencies on
297
  }
298
}
299

    
300
// ============================================================
301
// In an ideal world, I'd make the build process more standalone
302
// by automatically cloning the repositories if they weren't
303
// available. But the QT3 test suite in particular is huge and
304
// takes a long time to clone. So for now, just force users to
305
// tell us where they've cloned them.
306

    
307
task cloneQT3TestSuite() {
308
  doLast {
309
    if (w3cQT3TestSuiteDir == null) {
310
      throw new GradleException("The location of the QT3 test suite is unknown.")
311
    }
312
  }
313
}
314

    
315
task cloneXslt30TestSuite() {
316
  doLast {
317
    if (w3cXslt30TestSuiteDir == null) {
318
      throw new GradleException("The location of the XSLT 3.0 test suite is unknown.")
319
    }
320
  }
321
}
322

    
323
task cloneXsdTestSuite() {
324
  doLast {
325
    if (w3cXsdTestSuiteDir == null) {
326
      throw new GradleException("The location of the XSD test suite is unknown.")
327
    }
328
  }
329
}
330

    
331
// ============================================================
332

    
333
task compileTestDrivers() {
334
  // Just a container to hang dependencies on
335
}
336

    
337
task runQT3TestDriver() {
338
  // Just a container to hang dependencies on
339
}
340

    
341
task runXslt30TestSuiteDriver() {
342
  // Just a container to hang dependencies on
343
}
344

    
345
["h", "p", "e"].each { initial ->
346
  def release = initial + "e"
347
  def RELEASE = release.toUpperCase()
348
  def jpackage = "com.saxonica.testdriver"
349
  if (release == "he") {
350
    jpackage = "net.sf.saxon.testdriver"
351
  }
352

    
353
  task "${release}j_compileTestDrivers"(
354
    type: JavaCompile,
355
    dependsOn: ["${release}j_copyTestDrivers", "${release}jCompile"],
356
    description: "Compile the test classes for ${RELEASE}"
357
  ) {
358
    classpath = configurations.testDrivers + files("${buildDir}/classes/${release}j")
359
    source = "${buildDir}/src/testdrivers/${release}j"
360
    destinationDirectory = new File("${buildDir}/testdriver_classes/${release}j")
361
  }
362

    
363
  fileTree(dir: "src/test/exceptions").each { fn ->
364
    def pos = fn.toString().lastIndexOf(pathSeparator)
365
    def base = fn.toString().substring(pos+1)
366
    base = base.substring(0, base.length() - 4)
367
    task "${release}j_setup_${base}_TestResults"(
368
      type: Copy,
369
      description: "Sets up the test results directory the ${base} tests for ${RELEASE}"
370
    ) {
371
      into "${buildDir}/test-results/${release}j/${base}"
372
      from "src/test/exceptions/${base}.xml"
373
      rename { "exceptions.xml" }
374
    }
375
  }
376

    
377
  task "${release}j_runQT3TestDriver"(
378
    type: JavaExec,
379
    dependsOn: ["${release}j_compileTestDrivers", "${release}j_setup_qt3_TestResults",
380
                "cloneQT3TestSuite"],
381
    description: "Run the QT3 test suite driver for ${RELEASE}"
382
  ) {
383
    classpath = configurations.testDrivers \
384
                + files("${buildDir}/classes/${release}j") \
385
                + files("${buildDir}/testdriver_classes/${release}j")
386
    main = "${jpackage}.QT3TestDriver${RELEASE}"
387
    //args "-?"
388
    args "${w3cQT3TestSuiteDir}",
389
      "catalog.xml",
390
      "-o:${buildDir}/test-results/${release}j/qt3",
391
      "-lang:XQ31",
392
      "-qt30:on",
393
      "-bytecode:off"
394
  }
395

    
396
  task "${release}j_runXslt30TestSuiteDriver"(
397
    type: JavaExec,
398
    dependsOn: ["${release}j_compileTestDrivers", "${release}j_setup_xslt30_TestResults",
399
                "cloneXslt30TestSuite"],
400
    description: "Run the XSLT 3.0 test suite driver for ${RELEASE}"
401
  ) {
402
    classpath = configurations.testDrivers \
403
                + files("${buildDir}/classes/${release}j") \
404
                + files("${buildDir}/testdriver_classes/${release}j")
405
    main = "${jpackage}.Xslt30TestSuiteDriver${RELEASE}"
406
    //args "-?"
407
    args "/Volumes/Saxonica/src/w3c/xslt30-test",
408
      "catalog.xml",
409
      "-o:${buildDir}/test-results/${release}j/xslt30",
410
      "-lang:XT30",
411
      "-qt30:on",
412
      "-bytecode:off"
413
  }
414
}
415

    
416
// ============================================================
417

    
418
task hejJarTests(
419
  type: Jar,
420
  dependsOn: ["hejCompile", "hej_compileTestDrivers"],
421
  description: "Create the tests jar file for HE"
422
) {
423
  archiveBaseName = "saxon-he-test-${saxonVersion}"
424
  manifest {
425
    attributes "Project-Name": "Saxon-HE-TestDriver"
426
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
427
  }
428
  from ("${buildDir}/testdriver_classes/hej") {
429
    include "net/sf/saxon/testdriver/**"
430
  }
431
}
432

    
433
task pejJarTests(
434
  type: Jar,
435
  dependsOn: ["pejCompile", "pej_compileTestDrivers"],
436
  description: "Create the tests jar file for PE"
437
) {
438
  archiveBaseName = "saxon-pe-test-${saxonVersion}"
439
  manifest {
440
    attributes "Project-Name": "Saxon-PE-TestDriver"
441
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
442
  }
443
  from ("${buildDir}/testdriver_classes/pej") {
444
    include "net/sf/saxon/testdriver/**"
445
    include "com/saxonica/testdriver/**"
446
    exclude "com/saxonica/testdriver/ee/**"
447
  }
448
}
449

    
450
task eejJarTests(
451
  type: Jar,
452
  dependsOn: ["eejCompile", "eej_compileTestDrivers"],
453
  description: "Create the tests jar file for EE"
454
) {
455
  archiveBaseName = "saxon-ee-test-${saxonVersion}"
456
  manifest {
457
    attributes "Project-Name": "Saxon-EE-TestDriver"
458
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
459
  }
460
  from ("${buildDir}/testdriver_classes/eej") {
461
    include "net/sf/saxon/testdriver/**"
462
    include "com/saxonica/testdriver/**"
463
  }
464
}
465

    
466
// ============================================================
467

    
468
task hej_sampleConfig(
469
  type: JavaExec,
470
  description: "Construct the configuration file XSD"
471
) {
472
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
473
  inputs.files "${projectDir}/src/samples/config/config-raw.xsd"
474
  outputs.file "${projectDir}/src/samples/config/config.xsd"
475
  classpath = configurations.preprocessor
476
  main = "net.sf.saxon.Transform"
477
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
478
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToSchema.xsl",
479
    "-o:${projectDir}/src/samples/config/config.xsd",
480
    "FeatureKeys=FeatureKeys.xml",
481
    "AdditionalFeatures=AdditionalFeatures.xml",
482
    "ConfigSchema=${projectDir}/src/samples/config/config-raw.xsd"
483
}
484

    
485
// There's no real dependency here, but I'm not sure how the
486
// samples directory should be integrated into the build.
487
task hej_featureKeys(
488
  type: JavaExec,
489
  dependsOn: ["hej_sampleConfig"],
490
  description: "Construct the feature keys for HE"
491
) {
492
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
493
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/Feature.java"
494
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureCode.java"
495
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureKeys.java"
496
  classpath = configurations.preprocessor
497
  main = "net.sf.saxon.Transform"
498
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
499
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToJava.xsl",
500
    "-o:${projectDir}/src/main/java/net/sf/saxon/lib/establish-an-output-base-uri"
501
}
502

    
503
task hej_setupPreprocess(
504
  type: Copy,
505
  dependsOn: ["hej_featureKeys", "record_branch"],
506
  description: "Copy HE sources for preprocessing HE"
507
) {
508
  from "${projectDir}/src/main/java"
509
  into "${buildDir}/filtered/hej"
510
  include "net/sf/saxon/**/*.java"
511
  include "net/sf/saxon/**/package.html"
512
  //include "net/sf/saxon/data/**"
513
  exclude "javax/xml/xquery/*.java"
514
  exclude "**/dotnet/**"
515
  exclude "net/sf/saxon/testdriver/**"
516
  exclude "net/sf/saxon/option/sql/**"
517
  exclude "net/sf/saxon/option/cpp/**"
518
  exclude "net/sf/saxon/jetonnet/**"
519
}
520

    
521
task hej_setupPreprocessForPej(
522
  type: Copy,
523
  dependsOn: ["hej_featureKeys"],
524
  description: "Copy HE sources for preprocessing PE"
525
) {
526
  from "${projectDir}/src/main/java"
527
  into "${buildDir}/filtered/pej"
528
  include "net/sf/saxon/**/*.java"
529
  include "javax/xml/xquery/*.java"
530
  exclude "**/dotnet/**"
531
  include "net/sf/saxon/**/package.html"
532
  exclude "net/sf/saxon/testdriver/**"
533
  exclude "net/sf/saxon/option/cpp/**"
534
  exclude "net/sf/saxon/jetonnet/**"
535
  //include "net/sf/saxon/data/**"
536
}
537

    
538
task eej_setupPreprocessForPej(
539
  type: Copy,
540
  description: "Copy EE sources for preprocessing PE"
541
) {
542
  from "${projectDir}/src/main/java"
543
  into "${buildDir}/filtered/pej"
544
  include "com/saxonica/**/*.java"
545
  exclude "com/saxonica/functions/extfn/cpp/*.java"
546
  exclude "com/saxonica/testdriver/**"
547
  exclude "com/saxonica/testdriver/ee/**/*.java"
548
  exclude "com/saxonica/testdriver/old/**/*.java"
549
  exclude "com/saxonica/ee/**"
550
  exclude "com/saxonica/config/EnterpriseConfiguration.java"
551
  exclude "com/saxonica/expr/CastToUnion.java"
552
  exclude "com/saxonica/expr/CastableToUnion.java"
553
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
554
  exclude "com/saxonica/config/ee/**"
555
  exclude "com/saxonica/js/**"
556
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
557
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
558
  exclude "com/saxonica/config/DotNetPlatformPE.java"
559
  exclude "com/saxonica/config/JavaPlatformEE.java"
560
  exclude "com/saxonica/config/NativePlatformPE.java"
561
  exclude "com/saxonica/Validate.java"
562
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
563
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
564
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
565
  exclude "com/saxonica/config/DynamicLoaderEE.java"
566
  exclude "com/saxonica/config/StandardSchemaResolver.java"
567
  exclude "com/saxonica/jaxp/SchemaFactoryImpl11.java"
568
  exclude "com/saxonica/functions/extfn/NativeCall.java"
569
}
570

    
571
task pej_setupPreprocess(
572
  dependsOn: ["hej_setupPreprocessForPej", "eej_setupPreprocessForPej", "record_branch"],
573
  description: "Copy sources for preprocessing PE"
574
) {
575
  // Just a container to hang dependencies on
576
}
577

    
578
task hej_setupPreprocessForEej(
579
  type: Copy,
580
  dependsOn: ["hej_featureKeys", "record_branch"],
581
  description: "Copy HE sources for EE build"
582
) {
583
  from "${projectDir}/src/main/java"
584
  into "${buildDir}/filtered/eej"
585
  include "net/sf/saxon/**/*.java"
586
  include "javax/xml/xquery/*.java"
587
  exclude "**/dotnet/**"
588
  include "net/sf/saxon/**/package.html"
589
  exclude "net/sf/saxon/testdriver/**"
590
  exclude "net/sf/saxon/option/cpp/**"
591
  exclude "net/sf/saxon/jetonnet/**"
592
  exclude "net/sf/saxon/jetonnet/**"
593
  //include "net/sf/saxon/data/**"
594
}
595

    
596
// Rename org.objectweb to com.saxonica.objectweb in the bytecode sources
597
task eej_setupPreprocessBytecode(
598
  type: Copy,
599
  description: "Copy bytecode sources and fix imports"
600
) {
601
  from "${projectDir}/src/main/java"
602
  into "${buildDir}/filtered/eej"
603
  include "com/saxonica/ee/bytecode/**/*.java"
604
  filter { line ->
605
    line.contains("org.objectweb")
606
      ? line.replaceAll("org.objectweb", "com.saxonica.objectweb")
607
      : line
608
  }
609
}
610

    
611
// N.B. bytecode is explicitly excluded, see eej_setupPreprocessBytecode
612
task eej_setupPreprocess(
613
  type: Copy,
614
  dependsOn: ["hej_setupPreprocessForEej", "eej_setupPreprocessBytecode", "record_branch"],
615
  description: "Copy sources for preprocessing EE"
616
) {
617
  from "${projectDir}/src/main/java"
618
  into "${buildDir}/filtered/eej"
619
  include "com/saxonica/**/*.java"
620
  exclude "com/saxonica/ee/bytecode/**/*.java"
621
  exclude "com/saxonica/functions/extfn/cpp/*.java"
622
  exclude "com/saxonica/testdriver/**/*.java"
623
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
624
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
625
  exclude "com/saxonica/config/DotNetPlatformPE.java"
626
  exclude "com/saxonica/config/NativePlatformPE.java"
627
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
628
  exclude "com/saxonica/functions/extfn/NativeCall.java"
629
  include "com/saxonica/**/package.html"
630
  exclude "com/saxonica/js/**"
631
}
632

    
633
// ============================================================
634

    
635
task hej_preprocess(
636
  type: JavaExec,
637
  dependsOn: ["hej_setupPreprocess"],
638
  description: "Preprocess HE sources"
639
) {
640
  inputs.files fileTree(dir: "${buildDir}/filtered/hej")
641
  outputs.files fileTree(dir: "${buildDir}/preprocess/hej")
642
  classpath = configurations.preprocessor
643
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
644
  args "/c",
645
    "/i:${buildDir}/filtered/hej", "/o:${buildDir}/preprocess/hej",
646
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=false",
647
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
648
  doFirst {
649
    mkdir "${buildDir}/preprocess/hej"
650
  }
651
}
652

    
653
task pej_preprocess(
654
  type: JavaExec,
655
  dependsOn: ["pej_setupPreprocess"],
656
  description: "Preprocess HE sources"
657
) {
658
  inputs.files fileTree(dir: "${buildDir}/filtered/pej")
659
  outputs.files fileTree(dir: "${buildDir}/preprocess/pej")
660
  classpath = configurations.preprocessor
661
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
662
  args "/c",
663
    "/i:${buildDir}/filtered/pej", "/o:${buildDir}/preprocess/pej",
664
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=false", "/p:HOF=true",
665
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
666
  doFirst {
667
    mkdir "${buildDir}/preprocess/pej"
668
  }
669
}
670

    
671
task eej_preprocess(
672
  type: JavaExec,
673
  dependsOn: ["eej_setupPreprocess", "asm_jarjar"],
674
  description: "Preprocess EE sources"
675
) {
676
  inputs.files fileTree(dir: "${buildDir}/filtered/eej")
677
  outputs.files fileTree(dir: "${buildDir}/preprocess/eej")
678
  classpath = configurations.preprocessor
679
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
680
  args "/c",
681
    "/i:${buildDir}/filtered/eej", "/o:${buildDir}/preprocess/eej",
682
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=false", "/p:HOF=true",
683
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=true",
684
    "/p:STREAM=true", "/p:PACKAGES=true", "/p:SCHEMA=true"
685
  doFirst {
686
    mkdir "${buildDir}/preprocess/eej"
687
  }
688
}
689

    
690
// ============================================================
691

    
692
task hej_sources(
693
  type: Copy,
694
  dependsOn: ["hej_preprocess"],
695
  description: "Collect the preprocessed HE sources for compilation"
696
) {
697
  from "${buildDir}/preprocess/hej"
698
  into "${buildDir}/src/hej"
699
  filter { line ->
700
    line.contains("import com.saxonica") ? null : line.replaceFirst("\\s++\$", "")
701
  }
702
}
703

    
704
task pej_sources(
705
  type: Copy,
706
  dependsOn: ["pej_preprocess"],
707
  description: "Collect the preprocessed PE sources for compilation"
708
) {
709
  from "${buildDir}/preprocess/pej"
710
  into "${buildDir}/src/pej"
711
  filter { line ->
712
    if (line.contains("import com.saxonica.ee")
713
        || line.contains("import com.saxonica.config.ee")) {
714
      null
715
    } else {
716
      line.replaceFirst("\\s++\$", "")
717
    }
718
  }
719
}
720

    
721
task eej_sources(
722
  type: Copy,
723
  dependsOn: ["eej_preprocess"],
724
  description: "Collect the preprocessed EE sources for compilation"
725
) {
726
  from "${buildDir}/preprocess/eej"
727
  into "${buildDir}/src/eej"
728
}
729

    
730
// ============================================================
731

    
732
task record_branch(
733
  type: Exec,
734
  description: "Records the branch so we can detect switches."
735
) {
736
  def recordBranch = new ByteArrayOutputStream();
737
  commandLine "git", "branch", "--show-current"
738
  standardOutput = recordBranch
739
  doLast {
740
    def output = new FileWriter(new File("build/built-branch"))
741
    output.write(recordBranch.toString("utf-8"))
742
    output.close()
743
  }
744
}
745

    
746
task hejCompile(
747
  type: JavaCompile,
748
  dependsOn: ["hej_sources"],
749
  description: "Compile HE for Saxon/Java"
750
) {
751
  classpath = configurations.compileClasspath
752
  source "${buildDir}/src/hej"
753
  destinationDirectory = new File("${buildDir}/classes/hej")
754
}
755

    
756
task pejCompile(
757
  type: JavaCompile,
758
  dependsOn: ["pej_sources"],
759
  description: "Compile PE for Saxon/Java"
760
) {
761
  classpath = configurations.compileClasspath
762
  source "${buildDir}/src/pej"
763
  destinationDirectory = new File("${buildDir}/classes/pej")
764
}
765

    
766
task eejCompile(
767
  type: JavaCompile,
768
  dependsOn: ["eej_sources"],
769
  description: "Compile EE for Saxon/Java"
770
) {
771
  classpath = configurations.compileClasspath + configurations.jarjarAsm
772
  source "${buildDir}/src/eej"
773
  destinationDirectory = new File("${buildDir}/classes/eej")
774
}
775

    
776
// ============================================================
777

    
778
task hej_copyTestDriverSources(
779
  type: Copy,
780
  description: "Copy test drivers sources for HE"
781
) {
782
  from "src/main/java"
783
  into "${buildDir}/src/testdrivers/hej"
784
  include "net/sf/saxon/testdriver/*.java"
785
}
786

    
787
task pej_copyTestDriverSources(
788
  type: Copy,
789
  description: "Copy test drivers sources for PE"
790
) {
791
  from "src/main/java"
792
  into "${buildDir}/src/testdrivers/pej"
793
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
794
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
795
  include "com/saxonica/testdriver/Licensor.java"
796
  include "net/sf/saxon/testdriver/*.java"
797
}
798

    
799
task eej_copyTestDriverSources(
800
  type: Copy,
801
  description: "Copy test drivers sources for EE"
802
) {
803
  from "src/main/java"
804
  into "${buildDir}/src/testdrivers/eej"
805
  include "com/saxonica/testdriver/**/*.java"
806
  include "net/sf/saxon/testdriver/*.java"
807
}
808

    
809
task hej_copyTestDriverResources(
810
  type: Copy,
811
  description: "Copy test drivers resources for HE"
812
) {
813
  from "src/main/java"
814
  into "${buildDir}/testdriver_classes/hej"
815
  include "net/sf/saxon/testdriver/**"
816
  exclude "net/sf/saxon/testdriver/**/*.java"
817
}
818

    
819
task pej_copyTestDriverResources(
820
  type: Copy,
821
  description: "Copy test drivers resources for PE"
822
) {
823
  from "src/main/java"
824
  into "${buildDir}/testdriver_classes/pej"
825
  include "net/sf/saxon/testdriver/**"
826
  include "com/saxonica/testdriver/**"
827
  exclude "net/sf/saxon/testdriver/**/*.java"
828
  exclude "com/saxonica/testdriver/**/*.java"
829
  exclude "com/saxonica/testdriver/old/**"
830
  exclude "com/saxonica/testdriver/gui/cache.xml"
831
}
832

    
833
task eej_copyTestDriverResources(
834
  type: Copy,
835
  description: "Copy test drivers resources for EE"
836
) {
837
  from "src/main/java"
838
  into "${buildDir}/testdriver_classes/eej"
839
  include "net/sf/saxon/testdriver/**"
840
  include "com/saxonica/testdriver/**"
841
  exclude "net/sf/saxon/testdriver/**/*.java"
842
  exclude "com/saxonica/testdriver/**/*.java"
843
  exclude "com/saxonica/testdriver/old/**"
844
  exclude "com/saxonica/testdriver/gui/cache.xml"
845
}
846

    
847
// ============================================================
848
// These tasks all relate to renaming (re-jarring) the ASM jar files
849
// for EE so that the class names begin com.saxonica. This avoids a
850
// problem where a different version of the ASM libraries is used in
851
// the application that is using Saxon.
852

    
853
task asm_createRules(
854
  description: "Create the jarjar rules file for the ASM libraries"
855
) {
856
  outputs.file("${buildDir}/jarjar-asm.rules")
857
  doLast {
858
    new File("${buildDir}/jarjar-asm.rules")
859
      .withWriter("utf-8") { writer ->
860
        writer.writeLine("rule org.objectweb.** com.saxonica.objectweb.@1")
861
      }
862
  }
863
  doFirst {
864
    mkdir "${buildDir}"
865
  }
866
}
867

    
868
task asm_jarjar(
869
  description: "Placeholder for the ASM jarjar dependencies"
870
) {
871
  // just a task to hang dependencies on
872
}
873

    
874
task asm_unzip(
875
  type: Copy,
876
  description: "Extract classes from the asm-xml-${asmVersion} jar"
877
) {
878
  // This one is from the original ASM
879
  def zipFile = file("lib/asm-${asmVersion}/asm-xml-${asmVersion}.jar")
880
  def outputDir = "${buildDir}/classes/eej"
881
  from zipTree(zipFile)
882
  into outputDir
883
}
884

    
885
["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"].each { asm ->
886
  Task t = task "asm_${asm}"(
887
    type: JavaExec,
888
    dependsOn: ["asm_createRules"],
889
    description: "Run jarjar on ${asm}-${asmVersion} classes"
890
) {
891
    inputs.file "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar"
892
    outputs.file "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
893
    classpath = configurations.preprocessor
894
    main = "com.tonicsystems.jarjar.Main"
895
    args "--rules", "${buildDir}/jarjar-asm.rules",
896
      "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar",
897
      "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
898
    doFirst {
899
      mkdir "${buildDir}/lib/asm"
900
    }
901
  }
902
  asm_jarjar.dependsOn t
903

    
904
  t = task "asm_unzip${asm}"(
905
    type: Copy,
906
    dependsOn: ["asm_jarjar"],
907
    description: "Extract the classes from the ${asm}-${asmVersion} jar"
908
  ) {
909
    def zipFile = file("${buildDir}/lib/asm/${asm}-${asmVersion}.jar")
910
    def outputDir = "${buildDir}/classes/eej"
911
    from zipTree(zipFile)
912
    into outputDir
913
  }
914
  asm_unzip.dependsOn t
915
}
916

    
917
// ============================================================
918

    
919
task hej_MetaInf(
920
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for HE"
921
) {
922
  outputs.file("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
923
  doFirst {
924
    mkdir "${buildDir}/services/saxon-he/META-INF/services"
925
  }
926
  doLast {
927
    new File("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
928
      .withWriter("utf-8") { writer ->
929
        writer.writeLine("net.sf.saxon.TransformerFactoryImpl")
930
      }
931
  }
932
}
933

    
934
task pej_MetaInf(
935
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for PE"
936
) {
937
  outputs.file("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
938
  doFirst {
939
    mkdir "${buildDir}/services/saxon-pe/META-INF/services"
940
  }
941
  doLast {
942
    new File("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
943
      .withWriter("utf-8") { writer ->
944
        writer.writeLine("com.saxonica.config.ProfessionalTransformerFactory")
945
      }
946
  }
947
}
948

    
949
task eej_schemaFactoryMetaInf(
950
  description: "Create META-INF/services/javax.xml.validation.SchemaFactory for EE"
951
) {
952
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
953
  doFirst {
954
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
955
  }
956
  doLast {
957
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
958
      .withWriter("utf-8") { writer ->
959
        writer.writeLine("com.saxonica.ee.jaxp.SchemaFactoryImpl")
960
      }
961
  }
962
}
963

    
964
task eej_MetaInf(
965
  dependsOn: ["eej_schemaFactoryMetaInf"],
966
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for EE"
967
) {
968
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
969
  doFirst {
970
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
971
  }
972
  doLast {
973
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
974
      .withWriter("utf-8") { writer ->
975
        writer.writeLine("com.saxonica.config.EnterpriseTransformerFactory")
976
      }
977
  }
978
}
979

    
980
// ============================================================
981

    
982
task hejJar(
983
  type: Jar,
984
  dependsOn: ["hej_MetaInf", "hejCompile"],
985
  description: "Build the HE jar file"
986
) {
987
  archiveBaseName = "saxon-he-${saxonVersion}"
988
  manifest {
989
    attributes "Project-Name": "Saxon-HE"
990
    attributes "Main-Class": "net.sf.saxon.Transform"
991
  }
992
  from ("${buildDir}/services/saxon-he") {
993
    include "META-INF/**"
994
  }
995
  from ("${buildDir}/classes/hej") {
996
    include "net/**/*.class"
997
    exclude "net/sf/saxon/option/**"
998
  }
999
  from ("src/main/resources") {
1000
    include "net/sf/saxon/data/**"
1001
  }
1002
}
1003

    
1004
// Because the XQJ files are not open source, don't attempt to build
1005
// the jar unless the EE sources are available.
1006
if (file("${projectDir}/src/main/java/com/saxonica/xqj").exists()) {
1007
  task hejJarXqj(
1008
    type: Jar,
1009
    dependsOn: ["eejCompile"],
1010
    description: "Build the XQJ jar file for HE"
1011
  ) {
1012
    archiveBaseName = "saxon-he-xqj-${saxonVersion}"
1013
    from ("${buildDir}/classes/eej") {
1014
      include "com/saxonica/xqj/**/*.class"
1015
      include "javax/xml/xquery/**/*.class"
1016
    }
1017
  }
1018
} else {
1019
  task hejJarXqj(
1020
    description: "Ignore the XQJ file; the sources are unavailable"
1021
  ) {
1022
    doLast {
1023
      println("Ignoring XQJ jar file task; the sources are unavailable")
1024
    }
1025
  }
1026
}
1027

    
1028
task pejJar(
1029
  type: Jar,
1030
  dependsOn: ["pej_MetaInf", "pejCompile"],
1031
  description: "Build the PE jar file"
1032
) {
1033
  archiveBaseName = "saxon-pe-${saxonVersion}"
1034
  manifest {
1035
    attributes "Project-Name": "Saxon-PE"
1036
    attributes "Main-Class": "net.sf.saxon.Transform"
1037
  }
1038
  from ("${buildDir}/services/saxon-pe") {
1039
    include "META-INF/**"
1040
  }
1041
  from ("${buildDir}/classes/pej") {
1042
    include "net/**/*.class"
1043
    include "com/saxonica/**/*.class"
1044
    include "javax/xml/xquery/*.class"
1045
    exclude "**/sql/**/*.class"
1046
    exclude "com/saxonica/CompileStylesheet.class"
1047
    exclude "com/saxonica/CompileStylesheet\$TracingObjectOutputStream.class"
1048
    exclude "com/saxonica/Validate.class"
1049
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
1050
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
1051
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
1052
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
1053
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
1054
    exclude "com/saxonica/ee/**/*.class"
1055
    exclude "com/saxonica/expr/CastToList.class"
1056
    exclude "com/saxonica/expr/CastToUnion.class"
1057
    exclude "com/saxonica/expr/CastableToList.class"
1058
    exclude "com/saxonica/expr/CastableToUnion.class"
1059
    exclude "com/saxonica/functions/sql/**"
1060
    exclude "net/sf/saxon/option/sql/**"
1061
  }
1062
  from ("src/main/resources") {
1063
    include "net/sf/saxon/data/**"
1064
  }
1065
}
1066

    
1067
task pejJarSql(
1068
  type: Jar,
1069
  dependsOn: ["pejCompile"],
1070
  description: "Build the SQL jar file for PE"
1071
) {
1072
  archiveBaseName = "saxon-pe-sql-${saxonVersion}"
1073
  from ("${buildDir}/classes/pej") {
1074
    include "net/sf/saxon/option/sql/*.class"
1075
    include "com/saxonica/functions/sql/*.class"
1076
  }
1077
}
1078

    
1079
task eejJar(
1080
  type: Jar,
1081
  dependsOn: ["eej_MetaInf", "eejCompile", "asm_unzip"],
1082
  description: "Build the EE jar file"
1083
) {
1084
  archiveBaseName = "saxon-ee-${saxonVersion}"
1085
  manifest {
1086
    attributes "Project-Name": "Saxon-EE"
1087
    attributes "Main-Class": "net.sf.saxon.Transform"
1088
  }
1089
  from ("${buildDir}/services/saxon-ee") {
1090
    include "META-INF/**"
1091
  }
1092
  from ("${buildDir}/classes/eej") {
1093
    include "net/**/*.class"
1094
    include "com/saxonica/**/*.class"
1095
    include "javax/xml/xquery/*.class"
1096
    exclude "org/objectweb/**/*.class"
1097
    exclude "**/sql/**/*.class"
1098
    exclude "com/saxonica/StatsTransform*.class"
1099
    exclude "com/saxonica/functions/sql/**"
1100
    exclude "net/sf/saxon/option/sql/**"
1101
  }
1102
  from ("src/main/resources") {
1103
    include "net/sf/saxon/data/**"
1104
  }
1105
}
1106

    
1107
task eejJarSql(
1108
  type: Jar,
1109
  dependsOn: ["eejCompile"],
1110
  description: "Build the SQL jar file for EE"
1111
) {
1112
  archiveBaseName = "saxon-ee-sql-${saxonVersion}"
1113
  from ("${buildDir}/classes/eej") {
1114
    include "net/sf/saxon/option/sql/*.class"
1115
    include "com/saxonica/functions/sql/*.class"
1116
  }
1117
}
1118

    
1119
// ============================================================
1120

    
1121
task hej_releaseSetup(
1122
  type: Copy,
1123
  dependsOn: ["hejJar", "hejJarXqj", "hejJarTests", "hej_notices"],
1124
  description: "Build the HE release for Java"
1125
) {
1126
  from "${buildDir}/libs"
1127
  into "${buildDir}/releases/hej"
1128
  include "saxon-he-${saxonVersion}.jar"
1129
  include "saxon-he-xqj-${saxonVersion}.jar"
1130
  include "saxon-he-test-${saxonVersion}.jar"
1131
  rename { filename ->
1132
    if (filename.startsWith("saxon-he-xqj")) {
1133
      filename = "saxon9-xqj.jar"
1134
    } else if (filename.startsWith("saxon-he-test")) {
1135
      filename = "saxon9-test.jar"
1136
    } else {
1137
      filename = "saxon9he.jar"
1138
    }
1139
  }
1140
}
1141

    
1142
task hejRelease(
1143
  type: Zip,
1144
  dependsOn: ["hej_releaseSetup"],
1145
  description: "Make the HE release ZIP file for Java"
1146
) {
1147
  from("${buildDir}/releases/hej")
1148
  archiveFileName = "SaxonHE${version_h}J.zip"
1149
}
1150

    
1151
task pejRelease(
1152
  type: Copy,
1153
  dependsOn: ["pejJar", "pejJarSql", "pejJarTests", "pej_libs", "pej_notices"],
1154
  description: "Build the PE release for Java"
1155
) {
1156
  from "${buildDir}/libs"
1157
  into "${buildDir}/releases/pej"
1158
  include "saxon-pe-${saxonVersion}.jar"
1159
  include "saxon-pe-sql-${saxonVersion}.jar"
1160
  include "saxon-pe-test-${saxonVersion}.jar"
1161
  rename { filename ->
1162
    if (filename.startsWith("saxon-pe-sql")) {
1163
      filename.replace("saxon-pe-sql", "saxon-sql")
1164
    } else {
1165
      filename
1166
    }
1167
  }
1168
}
1169

    
1170
task eejRelease(
1171
  type: Copy,
1172
  dependsOn: ["eejJar", "eejJarSql", "eejJarTests", "eej_libs", "eej_notices"],
1173
  description: "Build the EE release for Java"
1174
) {
1175
  from "${buildDir}/libs"
1176
  into "${buildDir}/releases/eej"
1177
  include "saxon-ee-${saxonVersion}.jar"
1178
  include "saxon-ee-sql-${saxonVersion}.jar"
1179
  include "saxon-ee-test-${saxonVersion}.jar"
1180
  rename { filename ->
1181
    if (filename.startsWith("saxon-ee-sql")) {
1182
      filename.replace("saxon-ee-sql", "saxon-sql")
1183
    } else {
1184
      filename
1185
    }
1186
  }
1187
}
1188

    
1189
task javaReleases(
1190
  dependsOn: ["hejRelease", "pejRelease", "eejRelease"],
1191
  description: "Build all of the Java releases"
1192
) {
1193
  // Just a container to hang dependencies on
1194
}
1195

    
1196
// ============================================================
1197

    
1198
task dockerCoreContainer(
1199
  type: Exec,
1200
  description: "Build the CentOS 8 core container"
1201
) {
1202
  inputs.files("${projectDir}/src/docker/centos8-core")
1203
  commandLine "docker", "build",
1204
    "-t", "${dockerCentos8Core}",
1205
    "${projectDir}/src/docker/centos8-core"
1206
}
1207

    
1208
// In order to build this container, you must specify the location
1209
// of the JDK and the Jet software archive. Use
1210
// -PdockerJdk= to specify the location of the JDK RPM. Use
1211
// -PdockerJet= to specify the location of the Jet archive.
1212
task dockerBuilderContainer(
1213
  type: Exec,
1214
  dependsOn: ["docker_setupBuilder", "dockerCoreContainer"],
1215
  description: "Build the Saxonica builder container"
1216
) {
1217
  inputs.files("${buildDir}/docker/builder")
1218
  commandLine "docker", "build",
1219
    "-t", "${dockerBuildContainer}",
1220
    "${buildDir}/docker/builder"
1221
}
1222

    
1223
task docker_setupBuilder(
1224
  type: Copy,
1225
  dependsOn: ["docker_setupJdk", "docker_setupJet"],
1226
  description: "Setup to build the builder container"
1227
) {
1228
  from "src/docker/builder"
1229
  into "${buildDir}/docker/builder"
1230
}
1231

    
1232
task docker_testJdk(
1233
  description: "Test that the dockerJdk property has been specified"
1234
) {
1235
  doLast {
1236
    if (dockerJdk == "none") {
1237
      throw new GradleException("You must specify the JDK with -PdockerJdk=...")
1238
    }
1239
  }
1240
}
1241

    
1242
task docker_setupJdk(
1243
  type: Copy,
1244
  dependsOn: ["docker_testJdk"],
1245
  description: "Setup the JDK for the builder container"
1246
) {
1247
  from dockerJdk
1248
  into "${buildDir}/docker/builder"
1249
}
1250

    
1251
task docker_testJet(
1252
  description: "Test that the dockerJet property has been specified"
1253
) {
1254
  doLast {
1255
    if (dockerJet == "none") {
1256
      throw new GradleException("You must specify Jet archive with -PdockerJet=...")
1257
    }
1258
  }
1259
}
1260

    
1261
task docker_setupJet(
1262
  type: Copy,
1263
  dependsOn: ["docker_testJet"],
1264
  description: "Setup the Jet archive for the builder container"
1265
) {
1266
  from dockerJet
1267
  into "${buildDir}/docker/builder"
1268
}
1269

    
1270
// ============================================================
1271

    
1272
compileTestDrivers.dependsOn "${saxonEdition}j_compileTestDrivers"
1273
runQT3TestDriver.dependsOn "${saxonEdition}j_runQT3TestDriver"
1274
runXslt30TestSuiteDriver.dependsOn "${saxonEdition}j_runXslt30TestSuiteDriver"
1275

    
1276
// ============================================================
1277

    
1278
// Testing task for various Gradle debugging efforts
1279
task helloWorld() {
1280
  doLast {
1281
    println("Hello, world.")
1282
  }
1283
}
(7-7/12)