Project

Profile

Help

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

he / build.gradle @ b8574960

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://maven.apache.org" }
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
  documentation.extendsFrom(implementation)
33
  jeldoclet.extendsFrom(implementation)
34
}
35

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

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

    
60
dependencies {
61
  preprocessor (
62
    [group: 'com.igormaznitsa', name: 'jcp', version: '7.0.4'],
63
    [group: 'com.tonicsystems', name: 'jarjar', version: '0.6' ],
64
    [group: 'net.sf.saxon', name: 'Saxon-HE', version: '10.3' ],
65
    files(saxonLicenseDir)
66
  )
67
  implementation (
68
    [group: 'org.apache.ws.commons.axiom', name: 'axiom', version: '1.2.15'],
69
    [group: 'org.apache.ws.commons.axiom', name: 'axiom-dom', version: '1.2.15'],
70
    [group: 'xom', name: 'xom', version: '1.3.5'],
71
    [group: 'org.jdom', name: 'jdom', version: '1.1.3'],
72
    [group: 'org.jdom', name: 'jdom2', version: '2.0.6'],
73
    [group: 'org.lucee', name: 'dom4j', version: '1.6.1'],
74
    [group: 'xml-resolver', name: 'xml-resolver', version: '1.2' ],
75
    [group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion ],
76
    [group: 'jline', name: 'jline', version: '2.14.6' ],
77
    [group: 'org.jetbrains', name: 'annotations', version: '20.1.0' ],
78
    // PE and EE
79
    [group: 'javax.mail', name: 'javax.mail-api', version: mailVersion ],
80
    [group: 'com.sun.mail', name: 'javax.mail', version: mailVersion ],
81
    [group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: tagsoupVersion],
82
    fileTree(dir: "extra/MyDotNet/classpath"),
83
    fileTree(dir: "extra/MyDotNet/stubs"),
84
    fileTree(dir: "lib/asm-${asmVersion}"),
85
    files("lib/Tidy.jar"),
86
  )
87
  jarjarAsm (
88
    fileTree(dir: "${buildDir}/lib/asm")
89
  )
90
  ikvm (
91
    fileTree(dir: "${ikvmDir}/stubs")
92
  )
93
  compileDotNet (
94
    fileTree(dir: "${ikvmDir}/stubs"),
95
    fileTree(dir: "${ikvmDir}/classpath")
96
  )
97
  asmDotNet (
98
    fileTree(dir: "${ikvmDir}/stubs"),
99
    fileTree(dir: "${ikvmDir}/classpath"),
100
    fileTree(dir: "lib/asm-${asmVersion}")
101
  )
102
  testImplementation (
103
    [group: 'junit', name: 'junit', version: '4.12'],
104
    [group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.2'],
105
    [group: 'org.apache.ant', name: 'ant', version: '1.10.9' ],
106
    files("${buildDir}/classes/${saxonEdition}j"),
107
    files("src/main/resources"),
108
    files("lib/Tidy.jar"),
109
    files(saxonLicenseDir),
110
    fileTree("${buildDir}/lib/asm")
111
  )
112
  testRuntimeOnly (
113
    [group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.2'],
114
    [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.4.2'],
115
    [group: 'org.apache.ant', name: 'ant', version: '1.10.9' ],
116
    files("${buildDir}/classes/${saxonEdition}j")
117
  )
118
  documentation (
119
    [group: "com.saxonica", name: "Saxon-EE", version: "10.3"],
120
    files(saxonLicenseDir)
121
  )
122
  jeldoclet (
123
    files("lib/jeldoc.jar"),
124
    // I don't really understand why this has to be done explicitly...
125
    files("${System.getProperty('java.home')}/../lib/tools.jar")
126
  )
127
}
128

    
129
javadoc {
130
  classpath = configurations.implementation
131
}
132

    
133
test {
134
  useJUnitPlatform {
135
    excludeTags 'bytecode'
136
  }
137
}
138

    
139
/*
140
talaiot {
141
  metrics {
142
    performanceMetrics = false
143
  }
144
  publishers {
145
    taskDependencyGraphPublisher {
146
      gexf = false
147
      dot = true
148
      html = false
149
    }
150
  }
151
}
152
*/
153

    
154
ext {
155
  systemOs = OperatingSystem.current()
156
  icu4jJar = null
157
  tagsoupJar = null
158
  mailJar = null
159
  resolverJar = null
160
  version_h = saxonVersion.replace(".", "-")
161
  pathSeparator = System.getProperty("file.separator")
162
  DSTAMP=new Date().format("yyyyMMdd")
163
}
164

    
165
public class DeleteFilesRecursively {
166
  static void delete(File file){
167
    for (File fspec : file.listFiles()) {
168
      if (fspec.isDirectory()) {
169
        delete(fspec);
170
      } else {
171
        fspec.delete();
172
      }
173
    }
174
    file.delete();
175
  }
176
}
177

    
178
// ============================================================
179
// Have you switched branches?
180
def branch = new ByteArrayOutputStream()
181
def result = exec {
182
  commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
183
  standardOutput = branch;
184
}
185
def currentBranch = branch.toString().trim()
186

    
187
def builtBranch = "none";
188
try {
189
  def xbranch = new BufferedReader(new FileReader(new File("build/built-branch")))
190
  builtBranch = "${xbranch.readLine().trim()}"
191
} catch (FileNotFoundException foe) {
192
  // nop
193
}
194

    
195
if (currentBranch != builtBranch
196
    && (file("${buildDir}/src").exists()
197
        || file("${buildDir}/preprocess").exists()
198
        || file("${buildDir}/filtered").exists()
199
        || file("${buildDir}/classes").exists())) {
200
  println("You appear to have switched to the '${currentBranch}' branch.")
201
  println("Deleting stale build sources...")
202
  DeleteFilesRecursively.delete(new File("${buildDir}/src"))
203
  DeleteFilesRecursively.delete(new File("${buildDir}/preprocess"))
204
  DeleteFilesRecursively.delete(new File("${buildDir}/filtered"))
205
  DeleteFilesRecursively.delete(new File("${buildDir}/classes"))
206
}
207

    
208
// ============================================================
209
// Private options required for signing jars. (Can't be
210
// checked into the repository because they're sekrit.)
211
def eToken = "THIS-IS-NOT-THE-ETOKEN"
212
["${System.getenv("SAXON_SIGN_ETOKEN")}",
213
 "${projectDir}/../../private/eToken/macos/eToken.cfg",
214
 "z:/some/other/token/path"].each { path ->
215
  if (eToken == "THIS-IS-NOT-THE-ETOKEN"
216
      && new File(path).exists()) {
217
    eToken = path
218
  }
219
}
220

    
221
def signkeyNewAlias = "THIS-IS-NOT-THE-ALIAS"
222
if (System.getenv("SAXON_SIGN_ALIAS") != null) {
223
  signkeyNewAlias = System.getenv("SAXON_SIGN_ALIAS")
224
}
225

    
226
def signkeyPassword = "THIS-IS-NOT-THE-PASSWORD"
227
if (System.getenv("SAXON_SIGN_PASSWORD") != null) {
228
  signkeyPassword = System.getenv("SAXON_SIGN_PASSWORD")
229
}
230

    
231
def canSignJars = (!eToken.startsWith("THIS-IS-NOT")
232
                   && !signkeyNewAlias.startsWith("THIS-IS-NOT")
233
                   && !signkeyPassword.startsWith("THIS-IS-NOT"))
234

    
235
def signjarArgs = null
236
if (OperatingSystem.current().isWindows()) {
237
  signjarArgs = ["jarsigner",
238
                 "-keystore", "NONE",
239
                 "-storetype", "PKCS11",
240
                 "-tsa", "http://rfc3161timestamp.globalsign.com/advanced",
241
                 "-providerClass", "sun.security.pkcs11.SunPKCS11",
242
                 "-providerArg", eToken]
243
} else {
244
  signjarArgs = ["jarsigner",
245
                 "-tsa", "http://rfc3161timestamp.globalsign.com/advanced",
246
                 "-storetype", "PKCS11",
247
                 "-providerClass", "sun.security.pkcs11.SunPKCS11",
248
                 "-providerArg", eToken]
249
}
250

    
251
// ============================================================
252
// Find jar files that need to be part of the build or release
253
//
254
def filesep = System.getProperty("file.separator")
255
icu4jJar = "${filesep}icu4j-${icu4jVersion}.jar"
256
tagsoupJar = "${filesep}tagsoup-${tagsoupVersion}.jar"
257
mailJar = "${filesep}javax.mail-${mailVersion}.jar"
258
resolverJar = "${filesep}xml-resolver-1.2.jar"
259
configurations.compileClasspath.each { cp ->
260
  if (cp.toString().endsWith(icu4jJar)) {
261
    icu4jJar = cp.toString()
262
  }
263
  if (cp.toString().endsWith(tagsoupJar)) {
264
    tagsoupJar = cp.toString()
265
  }
266
  if (cp.toString().endsWith(mailJar)) {
267
    mailJar = cp.toString()
268
  }
269
  if (cp.toString().endsWith(resolverJar)) {
270
    resolverJar = cp.toString()
271
  }
272
}
273

    
274
apply from: "build-n.gradle"
275
apply from: "build-c.gradle"
276
apply from: "build-doc.gradle"
277

    
278
def pathExists(pathname) {
279
  // Returns true iff pathame is an existing file or directory
280
  try {
281
    // This may throw an error for a Windows pathname, c:/path/to/thing
282
    if (file(pathname).exists()) {
283
      return true;
284
    }
285
  } catch (GradleException e) {
286
    // I don't care
287
  }
288

    
289
  if (OperatingSystem.current().isWindows()) {
290
    try {
291
      // If we're on Windows, try to make c:/path/to/thing work
292
      if (file("file:///${pathname}").exists()) {
293
        return true;
294
      }
295
    } catch (GradleException e) {
296
      // I don't care
297
    }
298
  }
299

    
300
  return false
301
}
302

    
303
// ============================================================
304
// One of the features of Gradle is that you can construct tasks
305
// dynamically during the "configure" phase. This is a feature because
306
// it avoids a lot of tedious repetition of nearly identical tasks. It
307
// has the unfortunate consequence that understanding the tasks
308
// involved becomes harder. I've tried to use this feature sparingly.
309

    
310
["h", "p", "e"].each { initial ->
311
  def release = initial + "e"
312
  def Release = initial.toUpperCase() + "e"
313
  def RELEASE = release.toUpperCase()
314

    
315
  if (release != "he") {
316
    Task libs = task "${release}j_libs"(
317
      description: "Dependency to make sure library files are copie for ${RELEASE}"
318
    ) {
319
      // Just a container to hang dependencies on
320
    }
321

    
322
    Task icu4j = task "${release}j_icu4j"(
323
      type: Copy,
324
      description: "Copy the ICU4J jar into the ${RELEASE} release directory"
325
    ) {
326
      from "${icu4jJar}"
327
      into "${buildDir}/releases/${release}j"
328
    }
329
    libs.dependsOn icu4j
330
  }
331

    
332
  task "${release}j_notices"(
333
    type: Copy,
334
    description: "Copy the notices into the ${RELEASE} release directory"
335
  ) {
336
    into "${buildDir}/releases/${release}j"
337
    from ("src/docs") {
338
      exclude "saxon9"
339
      exclude "tools"
340
      exclude "saxonc-doc"
341
      exclude "welcome"
342
      exclude "notices/APACHE-ANT.txt"
343
      exclude "notices/APACHE-RESOLVER.txt"
344
      exclude "notices/APACHE-TAGSOUP.txt"
345
      exclude "notices/APACHE-XERCES.txt"
346
      exclude "notices/ASM.txt"
347
      exclude "notices/FRIJTERS.txt"
348
      exclude "notices/GPL+CLASSPATH.txt"
349
      exclude "notices/ICU-J.txt"
350
      exclude "notices/LEGAL.txt"
351
    }
352
  }
353

    
354
  task "${release}j_copyTestDrivers"(
355
    dependsOn: ["${release}j_copyTestDriverSources",
356
                "${release}j_copyTestDriverResources"],
357
    description: "Copy test driver sources and resources for ${RELEASE}"
358
  ) {
359
    // Just a container to hang dependencies on
360
  }
361
}
362

    
363
// ============================================================
364
// In an ideal world, I'd make the build process more standalone
365
// by automatically cloning the repositories if they weren't
366
// available. But the QT3 test suite in particular is huge and
367
// takes a long time to clone. So for now, just force users to
368
// tell us where they've cloned them.
369

    
370
task cloneQT3TestSuite() {
371
  doLast {
372
    if (w3cQT3TestSuiteDir == null) {
373
      throw new GradleException("The location of the QT3 test suite is unknown.")
374
    }
375
  }
376
}
377

    
378
task cloneXslt30TestSuite() {
379
  doLast {
380
    if (w3cXslt30TestSuiteDir == null) {
381
      throw new GradleException("The location of the XSLT 3.0 test suite is unknown.")
382
    }
383
  }
384
}
385

    
386
task cloneQT3ExtraTestSuite() {
387
  doLast {
388
    if (saxonQT3ExtraTestSuiteDir == null) {
389
      throw new GradleException("The location of the QT3 extra test suite is unknown.")
390
    }
391
  }
392
}
393

    
394
task cloneXsdTestSuite() {
395
  doLast {
396
    if (w3cXsdTestSuiteDir == null) {
397
      throw new GradleException("The location of the XSD test suite is unknown.")
398
    }
399
  }
400
}
401

    
402
// ============================================================
403

    
404
task compileTestDrivers() {
405
  // Just a container to hang dependencies on
406
}
407

    
408
task runQT3TestDriver() {
409
  // Just a container to hang dependencies on
410
}
411

    
412
task runXslt30TestSuiteDriver() {
413
  // Just a container to hang dependencies on
414
}
415

    
416
["h", "p", "e"].each { initial ->
417
  def release = initial + "e"
418
  def RELEASE = release.toUpperCase()
419
  def jpackage = "com.saxonica.testdriver"
420
  if (release == "he") {
421
    jpackage = "net.sf.saxon.testdriver"
422
  }
423

    
424
  task "${release}j_compileTestDrivers"(
425
    type: JavaCompile,
426
    dependsOn: ["${release}j_copyTestDrivers", "${release}jCompile"],
427
    description: "Compile the test classes for ${RELEASE}"
428
  ) {
429
    classpath = configurations.testDrivers + files("${buildDir}/classes/${release}j")
430
    source = "${buildDir}/src/testdrivers/${release}j"
431
    destinationDirectory = new File("${buildDir}/testdriver_classes/${release}j")
432
  }
433

    
434
  fileTree(dir: "src/test/exceptions").each { fn ->
435
    def pos = fn.toString().lastIndexOf(pathSeparator)
436
    def base = fn.toString().substring(pos+1)
437
    base = base.substring(0, base.length() - 4)
438
    task "${release}j_setup_${base}_TestResults"(
439
      type: Copy,
440
      description: "Sets up the test results directory the ${base} tests for ${RELEASE}"
441
    ) {
442
      into "${buildDir}/test-results/${release}j/${base}"
443
      from "src/test/exceptions/${base}.xml"
444
      rename { "exceptions.xml" }
445
    }
446
  }
447

    
448
  task "${release}j_runQT3TestDriver"(
449
    type: JavaExec,
450
    dependsOn: ["${release}j_compileTestDrivers", "${release}j_setup_qt3_TestResults",
451
                "cloneQT3TestSuite"],
452
    description: "Run the QT3 test suite driver for ${RELEASE}"
453
  ) {
454
    classpath = configurations.testDrivers \
455
                + files("${buildDir}/classes/${release}j") \
456
                + files("${buildDir}/testdriver_classes/${release}j")
457
    main = "${jpackage}.QT3TestDriver${RELEASE}"
458
    def testargs = ["${w3cQT3TestSuiteDir}",
459
                    "catalog.xml",
460
                    "-o:${buildDir}/test-results/${release}j/qt3",
461
                    "-lang:XQ31",
462
                    "-qt30:on",
463
                    testBytecode]
464
    if (testJit != "") {
465
      testargs = testargs + [ testJit ]
466
    }
467
    if (release == "ee" && testUnfolded != "") {
468
      testargs = testargs + [ testUnfolded ]
469
    }
470
    args testargs
471
  }
472

    
473
  task "${release}j_runXslt30TestSuiteDriver"(
474
    type: JavaExec,
475
    dependsOn: ["${release}j_compileTestDrivers", "${release}j_setup_xslt30_TestResults",
476
                "cloneXslt30TestSuite"],
477
    description: "Run the XSLT 3.0 test suite driver for ${RELEASE}"
478
  ) {
479
    classpath = configurations.testDrivers \
480
                + files("${buildDir}/classes/${release}j") \
481
                + files("${buildDir}/testdriver_classes/${release}j")
482
    main = "${jpackage}.Xslt30TestSuiteDriver${RELEASE}"
483
    def testargs = ["${w3cXslt30TestSuiteDir}",
484
                    "catalog.xml",
485
                    "-o:${buildDir}/test-results/${release}j/xslt30",
486
                    "-lang:XT30",
487
                    "-qt30:on",
488
                    testBytecode]
489
    if (testJit != "") {
490
      testargs = testargs + [ testJit ]
491
    }
492
    if (testExport != "") {
493
      testargs = testargs + [ testExport ]
494
    }
495
    args testargs
496
  }
497

    
498
  if (release == "pe" || release == "ee") {
499
    task "${release}j_runQT3ExtraTestDriver"(
500
      type: JavaExec,
501
      dependsOn: ["${release}j_compileTestDrivers", "${release}j_setup_qt3extra_TestResults",
502
                  "cloneQT3ExtraTestSuite"],
503
      description: "Run the QT3 extra test suite driver for ${RELEASE}"
504
    ) {
505
      classpath = configurations.testDrivers \
506
                  + files("${buildDir}/classes/${release}j") \
507
                  + files("${buildDir}/testdriver_classes/${release}j")
508
      main = "${jpackage}.QT3TestDriver${RELEASE}"
509
      def testargs = ["${saxonQT3ExtraTestSuiteDir}",
510
                      "catalog.xml",
511
                      "-o:${buildDir}/test-results/${release}j/qt3extra",
512
                      "-lang:XQ31",
513
                      "-qt30:on",
514
                      testBytecode]
515
      if (testJit != "") {
516
        testargs = testargs + [ testJit ]
517
      }
518
      if (release == "ee" && testUnfolded != "") {
519
        testargs = testargs + [ testUnfolded ]
520
      }
521
      args testargs
522
    }
523
  }
524
}
525

    
526
// ============================================================
527

    
528
task hejJarTests(
529
  type: Jar,
530
  dependsOn: ["hejCompile", "hej_compileTestDrivers"],
531
  description: "Create the tests jar file for HE"
532
) {
533
  archiveBaseName = "saxon-he-test-${saxonVersion}"
534
  manifest {
535
    attributes "Project-Name": "Saxon-HE-TestDriver"
536
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
537
  }
538
  from ("${buildDir}/testdriver_classes/hej") {
539
    include "net/sf/saxon/testdriver/**"
540
  }
541
}
542

    
543
task pejJarTests(
544
  type: Jar,
545
  dependsOn: ["pejCompile", "pej_compileTestDrivers"],
546
  description: "Create the tests jar file for PE"
547
) {
548
  archiveBaseName = "saxon-pe-test-${saxonVersion}"
549
  manifest {
550
    attributes "Project-Name": "Saxon-PE-TestDriver"
551
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
552
  }
553
  from ("${buildDir}/testdriver_classes/pej") {
554
    include "net/sf/saxon/testdriver/**"
555
    include "com/saxonica/testdriver/**"
556
    exclude "com/saxonica/testdriver/ee/**"
557
  }
558
}
559

    
560
task eejJarTests(
561
  type: Jar,
562
  dependsOn: ["eejCompile", "eej_compileTestDrivers"],
563
  description: "Create the tests jar file for EE"
564
) {
565
  archiveBaseName = "saxon-ee-test-${saxonVersion}"
566
  manifest {
567
    attributes "Project-Name": "Saxon-EE-TestDriver"
568
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
569
  }
570
  from ("${buildDir}/testdriver_classes/eej") {
571
    include "net/sf/saxon/testdriver/**"
572
    include "com/saxonica/testdriver/**"
573
    include "com/saxonica/js/**"
574
  }
575
}
576

    
577
// ============================================================
578

    
579
task hej_sampleConfig(
580
  type: JavaExec,
581
  description: "Construct the configuration file XSD"
582
) {
583
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
584
  inputs.files "${projectDir}/src/samples/config/config-raw.xsd"
585
  outputs.file "${projectDir}/src/samples/config/config.xsd"
586
  classpath = configurations.preprocessor
587
  main = "net.sf.saxon.Transform"
588
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
589
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToSchema.xsl",
590
    "-o:${projectDir}/src/samples/config/config.xsd",
591
    "FeatureKeys=FeatureKeys.xml",
592
    "AdditionalFeatures=AdditionalFeatures.xml",
593
    "ConfigSchema=${projectDir}/src/samples/config/config-raw.xsd"
594
}
595

    
596
// There's no real dependency here, but I'm not sure how the
597
// samples directory should be integrated into the build.
598
task hej_featureKeys(
599
  type: JavaExec,
600
  dependsOn: ["hej_sampleConfig"],
601
  description: "Construct the feature keys for HE"
602
) {
603
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
604
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/Feature.java"
605
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureCode.java"
606
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureKeys.java"
607
  classpath = configurations.preprocessor
608
  main = "net.sf.saxon.Transform"
609
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
610
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToJava.xsl",
611
    "-o:${projectDir}/src/main/java/net/sf/saxon/lib/establish-an-output-base-uri"
612
}
613

    
614
// Make sure we create feature keys before compiling Java
615
compileJava.dependsOn hej_featureKeys
616

    
617
task hej_setupPreprocess(
618
  type: Copy,
619
  dependsOn: ["hej_featureKeys", "record_branch"],
620
  description: "Copy HE sources for preprocessing HE"
621
) {
622
  from "${projectDir}/src/main/java"
623
  into "${buildDir}/filtered/hej"
624
  include "net/sf/saxon/**/*.java"
625
  include "net/sf/saxon/**/package.html"
626
  //include "net/sf/saxon/data/**"
627
  exclude "javax/xml/xquery/*.java"
628
  exclude "**/dotnet/**"
629
  exclude "net/sf/saxon/testdriver/**"
630
  exclude "net/sf/saxon/option/sql/**"
631
  exclude "net/sf/saxon/option/cpp/**"
632
  exclude "net/sf/saxon/jetonnet/**"
633
}
634

    
635
task hej_setupPreprocessForPej(
636
  type: Copy,
637
  dependsOn: ["hej_featureKeys"],
638
  description: "Copy HE sources for preprocessing PE"
639
) {
640
  from "${projectDir}/src/main/java"
641
  into "${buildDir}/filtered/pej"
642
  include "net/sf/saxon/**/*.java"
643
  include "javax/xml/xquery/*.java"
644
  exclude "**/dotnet/**"
645
  include "net/sf/saxon/**/package.html"
646
  exclude "net/sf/saxon/testdriver/**"
647
  exclude "net/sf/saxon/option/cpp/**"
648
  exclude "net/sf/saxon/jetonnet/**"
649
  //include "net/sf/saxon/data/**"
650
}
651

    
652
task eej_setupPreprocessForPej(
653
  type: Copy,
654
  description: "Copy EE sources for preprocessing PE"
655
) {
656
  from "${projectDir}/src/main/java"
657
  into "${buildDir}/filtered/pej"
658
  include "com/saxonica/**/*.java"
659
  exclude "com/saxonica/functions/extfn/cpp/*.java"
660
  exclude "com/saxonica/testdriver/**"
661
  exclude "com/saxonica/testdriver/ee/**/*.java"
662
  exclude "com/saxonica/testdriver/old/**/*.java"
663
  exclude "com/saxonica/ee/**"
664
  exclude "com/saxonica/config/EnterpriseConfiguration.java"
665
  exclude "com/saxonica/expr/CastToUnion.java"
666
  exclude "com/saxonica/expr/CastableToUnion.java"
667
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
668
  exclude "com/saxonica/config/ee/**"
669
  exclude "com/saxonica/js/**"
670
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
671
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
672
  exclude "com/saxonica/config/DotNetPlatformPE.java"
673
  exclude "com/saxonica/config/JavaPlatformEE.java"
674
  exclude "com/saxonica/config/NativePlatformPE.java"
675
  exclude "com/saxonica/Validate.java"
676
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
677
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
678
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
679
  exclude "com/saxonica/config/DynamicLoaderEE.java"
680
  exclude "com/saxonica/config/StandardSchemaResolver.java"
681
  exclude "com/saxonica/jaxp/SchemaFactoryImpl11.java"
682
  exclude "com/saxonica/functions/extfn/NativeCall.java"
683
}
684

    
685
task pej_setupPreprocess(
686
  dependsOn: ["hej_setupPreprocessForPej", "eej_setupPreprocessForPej", "record_branch"],
687
  description: "Copy sources for preprocessing PE"
688
) {
689
  // Just a container to hang dependencies on
690
}
691

    
692
task hej_setupPreprocessForEej(
693
  type: Copy,
694
  dependsOn: ["hej_featureKeys", "record_branch"],
695
  description: "Copy HE sources for EE build"
696
) {
697
  from "${projectDir}/src/main/java"
698
  into "${buildDir}/filtered/eej"
699
  include "net/sf/saxon/**/*.java"
700
  include "javax/xml/xquery/*.java"
701
  exclude "**/dotnet/**"
702
  include "net/sf/saxon/**/package.html"
703
  exclude "net/sf/saxon/testdriver/**"
704
  exclude "net/sf/saxon/option/cpp/**"
705
  exclude "net/sf/saxon/jetonnet/**"
706
  exclude "net/sf/saxon/jetonnet/**"
707
  //include "net/sf/saxon/data/**"
708
}
709

    
710
// Rename org.objectweb to com.saxonica.objectweb in the bytecode sources
711
task eej_setupPreprocessBytecode(
712
  type: Copy,
713
  description: "Copy bytecode sources and fix imports"
714
) {
715
  from "${projectDir}/src/main/java"
716
  into "${buildDir}/filtered/eej"
717
  include "com/saxonica/ee/bytecode/**/*.java"
718
  filter { line ->
719
    line.contains("org.objectweb")
720
      ? line.replaceAll("org.objectweb", "com.saxonica.objectweb")
721
      : line
722
  }
723
}
724

    
725
// N.B. bytecode is explicitly excluded, see eej_setupPreprocessBytecode
726
task eej_setupPreprocess(
727
  type: Copy,
728
  dependsOn: ["hej_setupPreprocessForEej", "eej_setupPreprocessBytecode", "record_branch"],
729
  description: "Copy sources for preprocessing EE"
730
) {
731
  from "${projectDir}/src/main/java"
732
  into "${buildDir}/filtered/eej"
733
  include "com/saxonica/**/*.java"
734
  exclude "com/saxonica/ee/bytecode/**/*.java"
735
  exclude "com/saxonica/functions/extfn/cpp/*.java"
736
  exclude "com/saxonica/testdriver/**/*.java"
737
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
738
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
739
  exclude "com/saxonica/config/DotNetPlatformPE.java"
740
  exclude "com/saxonica/config/NativePlatformPE.java"
741
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
742
  exclude "com/saxonica/functions/extfn/NativeCall.java"
743
  include "com/saxonica/**/package.html"
744
  exclude "com/saxonica/js/**"
745
}
746

    
747
// ============================================================
748

    
749
task hej_preprocess(
750
  type: JavaExec,
751
  dependsOn: ["hej_setupPreprocess"],
752
  description: "Preprocess HE sources"
753
) {
754
  inputs.files fileTree(dir: "${buildDir}/filtered/hej")
755
  outputs.files fileTree(dir: "${buildDir}/preprocess/hej")
756
  classpath = configurations.preprocessor
757
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
758
  args "/c",
759
    "/i:${buildDir}/filtered/hej", "/o:${buildDir}/preprocess/hej",
760
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=false",
761
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
762
  doFirst {
763
    mkdir "${buildDir}/preprocess/hej"
764
  }
765
}
766

    
767
task pej_preprocess(
768
  type: JavaExec,
769
  dependsOn: ["pej_setupPreprocess"],
770
  description: "Preprocess HE sources"
771
) {
772
  inputs.files fileTree(dir: "${buildDir}/filtered/pej")
773
  outputs.files fileTree(dir: "${buildDir}/preprocess/pej")
774
  classpath = configurations.preprocessor
775
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
776
  args "/c",
777
    "/i:${buildDir}/filtered/pej", "/o:${buildDir}/preprocess/pej",
778
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=false", "/p:HOF=true",
779
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
780
  doFirst {
781
    mkdir "${buildDir}/preprocess/pej"
782
  }
783
}
784

    
785
task eej_preprocess(
786
  type: JavaExec,
787
  dependsOn: ["eej_setupPreprocess", "asm_jarjar"],
788
  description: "Preprocess EE sources"
789
) {
790
  inputs.files fileTree(dir: "${buildDir}/filtered/eej")
791
  outputs.files fileTree(dir: "${buildDir}/preprocess/eej")
792
  classpath = configurations.preprocessor
793
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
794
  args "/c",
795
    "/i:${buildDir}/filtered/eej", "/o:${buildDir}/preprocess/eej",
796
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=false", "/p:HOF=true",
797
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=true",
798
    "/p:STREAM=true", "/p:PACKAGES=true", "/p:SCHEMA=true"
799
  doFirst {
800
    mkdir "${buildDir}/preprocess/eej"
801
  }
802
}
803

    
804
// ============================================================
805

    
806
task hej_sources(
807
  type: Copy,
808
  dependsOn: ["hej_preprocess"],
809
  description: "Collect the preprocessed HE sources for compilation"
810
) {
811
  from "${buildDir}/preprocess/hej"
812
  into "${buildDir}/src/hej"
813
  filter { line ->
814
    line.contains("import com.saxonica") ? null : line.replaceFirst("\\s++\$", "")
815
  }
816
}
817

    
818
task pej_sources(
819
  type: Copy,
820
  dependsOn: ["pej_preprocess"],
821
  description: "Collect the preprocessed PE sources for compilation"
822
) {
823
  from "${buildDir}/preprocess/pej"
824
  into "${buildDir}/src/pej"
825
  filter { line ->
826
    if (line.contains("import com.saxonica.ee")
827
        || line.contains("import com.saxonica.config.ee")) {
828
      null
829
    } else {
830
      line.replaceFirst("\\s++\$", "")
831
    }
832
  }
833
}
834

    
835
task eej_sources(
836
  type: Copy,
837
  dependsOn: ["eej_preprocess"],
838
  description: "Collect the preprocessed EE sources for compilation"
839
) {
840
  from "${buildDir}/preprocess/eej"
841
  into "${buildDir}/src/eej"
842
}
843

    
844
// ============================================================
845

    
846
task record_branch(
847
  type: Exec,
848
  description: "Records the branch so we can detect switches."
849
) {
850
  def recordBranch = new ByteArrayOutputStream();
851
  commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
852
  standardOutput = recordBranch
853
  doLast {
854
    def output = new FileWriter(new File("${buildDir}/built-branch"))
855
    output.write(recordBranch.toString("utf-8"))
856
    output.close()
857
  }
858
  doFirst {
859
    mkdir(buildDir)
860
  }
861
}
862

    
863
task hejCompile(
864
  type: JavaCompile,
865
  dependsOn: ["hej_sources"],
866
  description: "Compile HE for Saxon/Java"
867
) {
868
  classpath = configurations.compileClasspath
869
  source "${buildDir}/src/hej"
870
  destinationDirectory = new File("${buildDir}/classes/hej")
871
}
872

    
873
task pejCompile(
874
  type: JavaCompile,
875
  dependsOn: ["pej_sources"],
876
  description: "Compile PE for Saxon/Java"
877
) {
878
  classpath = configurations.compileClasspath
879
  source "${buildDir}/src/pej"
880
  destinationDirectory = new File("${buildDir}/classes/pej")
881
}
882

    
883
task eejCompile(
884
  type: JavaCompile,
885
  dependsOn: ["eej_sources"],
886
  description: "Compile EE for Saxon/Java"
887
) {
888
  classpath = configurations.compileClasspath + configurations.jarjarAsm
889
  source "${buildDir}/src/eej"
890
  destinationDirectory = new File("${buildDir}/classes/eej")
891
}
892

    
893
// ============================================================
894

    
895
task hej_copyTestDriverSources(
896
  type: Copy,
897
  description: "Copy test drivers sources for HE"
898
) {
899
  from "src/main/java"
900
  into "${buildDir}/src/testdrivers/hej"
901
  include "net/sf/saxon/testdriver/*.java"
902
}
903

    
904
task pej_copyTestDriverSources(
905
  type: Copy,
906
  description: "Copy test drivers sources for PE"
907
) {
908
  from "src/main/java"
909
  into "${buildDir}/src/testdrivers/pej"
910
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
911
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
912
  include "com/saxonica/testdriver/Licensor.java"
913
  include "net/sf/saxon/testdriver/*.java"
914
}
915

    
916
task eej_copyTestDriverSources(
917
  type: Copy,
918
  description: "Copy test drivers sources for EE"
919
) {
920
  from "src/main/java"
921
  into "${buildDir}/src/testdrivers/eej"
922
  include "com/saxonica/testdriver/**/*.java"
923
  include "com/saxonica/js/*.java"
924
  include "net/sf/saxon/testdriver/*.java"
925
}
926

    
927
task hej_copyTestDriverResources(
928
  type: Copy,
929
  description: "Copy test drivers resources for HE"
930
) {
931
  from "src/main/java"
932
  into "${buildDir}/testdriver_classes/hej"
933
  include "net/sf/saxon/testdriver/**"
934
  exclude "net/sf/saxon/testdriver/**/*.java"
935
}
936

    
937
task pej_copyTestDriverResources(
938
  type: Copy,
939
  description: "Copy test drivers resources for PE"
940
) {
941
  from "src/main/java"
942
  into "${buildDir}/testdriver_classes/pej"
943
  include "net/sf/saxon/testdriver/**"
944
  include "com/saxonica/testdriver/**"
945
  exclude "net/sf/saxon/testdriver/**/*.java"
946
  exclude "com/saxonica/testdriver/**/*.java"
947
  exclude "com/saxonica/testdriver/old/**"
948
  exclude "com/saxonica/testdriver/gui/cache.xml"
949
}
950

    
951
task eej_copyTestDriverResources(
952
  type: Copy,
953
  description: "Copy test drivers resources for EE"
954
) {
955
  from "src/main/java"
956
  into "${buildDir}/testdriver_classes/eej"
957
  include "net/sf/saxon/testdriver/**"
958
  include "com/saxonica/testdriver/**"
959
  exclude "net/sf/saxon/testdriver/**/*.java"
960
  exclude "com/saxonica/testdriver/**/*.java"
961
  exclude "com/saxonica/testdriver/old/**"
962
  exclude "com/saxonica/testdriver/gui/cache.xml"
963
}
964

    
965
// ============================================================
966
// These tasks all relate to renaming (re-jarring) the ASM jar files
967
// for EE so that the class names begin com.saxonica. This avoids a
968
// problem where a different version of the ASM libraries is used in
969
// the application that is using Saxon.
970

    
971
task asm_createRules(
972
  description: "Create the jarjar rules file for the ASM libraries"
973
) {
974
  outputs.file("${buildDir}/jarjar-asm.rules")
975
  doLast {
976
    new File("${buildDir}/jarjar-asm.rules")
977
      .withWriter("utf-8") { writer ->
978
        writer.writeLine("rule org.objectweb.** com.saxonica.objectweb.@1")
979
      }
980
  }
981
  doFirst {
982
    mkdir "${buildDir}"
983
  }
984
}
985

    
986
task asm_jarjar(
987
  description: "Placeholder for the ASM jarjar dependencies"
988
) {
989
  // just a task to hang dependencies on
990
}
991

    
992
task asm_unzip(
993
  type: Copy,
994
  description: "Extract classes from the asm-xml-${asmVersion} jar"
995
) {
996
  // This one is from the original ASM
997
  def zipFile = file("lib/asm-${asmVersion}/asm-xml-${asmVersion}.jar")
998
  def outputDir = "${buildDir}/classes/eej"
999
  from zipTree(zipFile)
1000
  into outputDir
1001
}
1002

    
1003
["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"].each { asm ->
1004
  Task t = task "asm_${asm}"(
1005
    type: JavaExec,
1006
    dependsOn: ["asm_createRules"],
1007
    description: "Run jarjar on ${asm}-${asmVersion} classes"
1008
) {
1009
    inputs.file "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar"
1010
    outputs.file "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
1011
    classpath = configurations.preprocessor
1012
    main = "com.tonicsystems.jarjar.Main"
1013
    args "--rules", "${buildDir}/jarjar-asm.rules",
1014
      "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar",
1015
      "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
1016
    doFirst {
1017
      mkdir "${buildDir}/lib/asm"
1018
    }
1019
  }
1020
  asm_jarjar.dependsOn t
1021

    
1022
  t = task "asm_unzip${asm}"(
1023
    type: Copy,
1024
    dependsOn: ["asm_jarjar"],
1025
    description: "Extract the classes from the ${asm}-${asmVersion} jar"
1026
  ) {
1027
    def zipFile = file("${buildDir}/lib/asm/${asm}-${asmVersion}.jar")
1028
    def outputDir = "${buildDir}/classes/eej"
1029
    from zipTree(zipFile)
1030
    into outputDir
1031
  }
1032
  asm_unzip.dependsOn t
1033
}
1034

    
1035
// ============================================================
1036

    
1037
task hej_MetaInf(
1038
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for HE"
1039
) {
1040
  outputs.file("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
1041
  doFirst {
1042
    mkdir "${buildDir}/services/saxon-he/META-INF/services"
1043
  }
1044
  doLast {
1045
    new File("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
1046
      .withWriter("utf-8") { writer ->
1047
        writer.writeLine("net.sf.saxon.TransformerFactoryImpl")
1048
      }
1049
  }
1050
}
1051

    
1052
task pej_MetaInf(
1053
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for PE"
1054
) {
1055
  outputs.file("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
1056
  doFirst {
1057
    mkdir "${buildDir}/services/saxon-pe/META-INF/services"
1058
  }
1059
  doLast {
1060
    new File("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
1061
      .withWriter("utf-8") { writer ->
1062
        writer.writeLine("com.saxonica.config.ProfessionalTransformerFactory")
1063
      }
1064
  }
1065
}
1066

    
1067
task eej_schemaFactoryMetaInf(
1068
  description: "Create META-INF/services/javax.xml.validation.SchemaFactory for EE"
1069
) {
1070
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
1071
  doFirst {
1072
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
1073
  }
1074
  doLast {
1075
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
1076
      .withWriter("utf-8") { writer ->
1077
        writer.writeLine("com.saxonica.ee.jaxp.SchemaFactoryImpl")
1078
      }
1079
  }
1080
}
1081

    
1082
task eej_MetaInf(
1083
  dependsOn: ["eej_schemaFactoryMetaInf"],
1084
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for EE"
1085
) {
1086
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
1087
  doFirst {
1088
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
1089
  }
1090
  doLast {
1091
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
1092
      .withWriter("utf-8") { writer ->
1093
        writer.writeLine("com.saxonica.config.EnterpriseTransformerFactory")
1094
      }
1095
  }
1096
}
1097

    
1098
// ============================================================
1099

    
1100
task hejJar(
1101
  type: Jar,
1102
  dependsOn: ["hej_MetaInf", "hejCompile"],
1103
  description: "Build the HE jar file"
1104
) {
1105
  archiveBaseName = "saxon-he-${saxonVersion}"
1106
  manifest {
1107
    attributes "Project-Name": "Saxon-HE"
1108
    attributes "Main-Class": "net.sf.saxon.Transform"
1109
  }
1110
  from ("${buildDir}/services/saxon-he") {
1111
    include "META-INF/**"
1112
  }
1113
  from ("${buildDir}/classes/hej") {
1114
    include "net/**/*.class"
1115
    exclude "net/sf/saxon/option/**"
1116
  }
1117
  from ("src/main/resources") {
1118
    include "net/sf/saxon/data/**"
1119
  }
1120
}
1121

    
1122
// Because the XQJ files are not open source, don't attempt to build
1123
// the jar unless the EE sources are available.
1124
if (file("${projectDir}/src/main/java/com/saxonica/xqj").exists()) {
1125
  task hejJarXqj(
1126
    type: Jar,
1127
    dependsOn: ["eejCompile"],
1128
    description: "Build the XQJ jar file for HE"
1129
  ) {
1130
    archiveBaseName = "saxon-he-xqj-${saxonVersion}"
1131
    from ("${buildDir}/classes/eej") {
1132
      include "com/saxonica/xqj/**/*.class"
1133
      include "javax/xml/xquery/**/*.class"
1134
    }
1135
  }
1136
} else {
1137
  task hejJarXqj(
1138
    description: "Ignore the XQJ file; the sources are unavailable"
1139
  ) {
1140
    doLast {
1141
      println("Ignoring XQJ jar file task; the sources are unavailable")
1142
    }
1143
  }
1144
}
1145

    
1146
task pejJar(
1147
  type: Jar,
1148
  dependsOn: ["pej_MetaInf", "pejCompile"],
1149
  description: "Build the PE jar file"
1150
) {
1151
  archiveBaseName = "saxon-pe-${saxonVersion}"
1152
  manifest {
1153
    attributes "Project-Name": "Saxon-PE"
1154
    attributes "Main-Class": "net.sf.saxon.Transform"
1155
  }
1156
  from ("${buildDir}/services/saxon-pe") {
1157
    include "META-INF/**"
1158
  }
1159
  from ("${buildDir}/classes/pej") {
1160
    include "net/**/*.class"
1161
    include "com/saxonica/**/*.class"
1162
    include "javax/xml/xquery/*.class"
1163
    exclude "**/sql/**/*.class"
1164
    exclude "com/saxonica/CompileStylesheet.class"
1165
    exclude "com/saxonica/CompileStylesheet\$TracingObjectOutputStream.class"
1166
    exclude "com/saxonica/Validate.class"
1167
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
1168
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
1169
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
1170
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
1171
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
1172
    exclude "com/saxonica/ee/**/*.class"
1173
    exclude "com/saxonica/expr/CastToList.class"
1174
    exclude "com/saxonica/expr/CastToUnion.class"
1175
    exclude "com/saxonica/expr/CastableToList.class"
1176
    exclude "com/saxonica/expr/CastableToUnion.class"
1177
    exclude "com/saxonica/functions/sql/**"
1178
    exclude "net/sf/saxon/option/sql/**"
1179
  }
1180
  from ("src/main/resources") {
1181
    include "net/sf/saxon/data/**"
1182
  }
1183
}
1184

    
1185
task pejJarSql(
1186
  type: Jar,
1187
  dependsOn: ["pejCompile"],
1188
  description: "Build the SQL jar file for PE"
1189
) {
1190
  archiveBaseName = "saxon-pe-sql-${saxonVersion}"
1191
  from ("${buildDir}/classes/pej") {
1192
    include "net/sf/saxon/option/sql/*.class"
1193
    include "com/saxonica/functions/sql/*.class"
1194
  }
1195
}
1196

    
1197
task eejJar(
1198
  type: Jar,
1199
  dependsOn: ["eej_MetaInf", "eejCompile", "asm_unzip"],
1200
  description: "Build the EE jar file"
1201
) {
1202
  archiveBaseName = "saxon-ee-${saxonVersion}"
1203
  manifest {
1204
    attributes "Project-Name": "Saxon-EE"
1205
    attributes "Main-Class": "net.sf.saxon.Transform"
1206
  }
1207
  from ("${buildDir}/services/saxon-ee") {
1208
    include "META-INF/**"
1209
  }
1210
  from ("${buildDir}/classes/eej") {
1211
    include "net/**/*.class"
1212
    include "com/saxonica/**/*.class"
1213
    include "javax/xml/xquery/*.class"
1214
    exclude "org/objectweb/**/*.class"
1215
    exclude "**/sql/**/*.class"
1216
    exclude "com/saxonica/StatsTransform*.class"
1217
    exclude "com/saxonica/functions/sql/**"
1218
    exclude "net/sf/saxon/option/sql/**"
1219
  }
1220
  from ("src/main/resources") {
1221
    include "net/sf/saxon/data/**"
1222
  }
1223
}
1224

    
1225
task eejJarSql(
1226
  type: Jar,
1227
  dependsOn: ["eejCompile"],
1228
  description: "Build the SQL jar file for EE"
1229
) {
1230
  archiveBaseName = "saxon-ee-sql-${saxonVersion}"
1231
  from ("${buildDir}/classes/eej") {
1232
    include "net/sf/saxon/option/sql/*.class"
1233
    include "com/saxonica/functions/sql/*.class"
1234
  }
1235
}
1236

    
1237
// ============================================================
1238

    
1239
task signJars(
1240
  dependsOn: ["hejSignJars", "pejSignJars", "eejSignJars"],
1241
  description: "Sign all the jar files."
1242
) {
1243
  // Just a container to hang dependencies on
1244
}
1245

    
1246
task hejSignJars(
1247
  description: "Sign the HEJ jar files"
1248
) {
1249
  // Just a container to hang dependencies on
1250
}
1251

    
1252
task pejSignJars(
1253
  description: "Sign the PEJ jar files"
1254
) {
1255
  // Just a container to hang dependencies on
1256
}
1257

    
1258
task eejSignJars(
1259
  description: "Sign the EEJ jar files"
1260
) {
1261
  // Just a container to hang dependencies on
1262
}
1263

    
1264
// Create tasks for signing jars...
1265
["he", "pe", "ee"].each { rel ->
1266
  if (canSignJars) {
1267
    Task t = task "${rel}_jJarSignJar"(
1268
      type: Exec,
1269
      dependsOn: ["${rel}jJar"],
1270
      description: "Sign the ${rel.toUpperCase()}J jar file"
1271
    ) {
1272
      inputs.file "${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar"
1273
      def args = signjarArgs +
1274
        ["${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar",
1275
         signkeyNewAlias,
1276
         "-storepass", signkeyPassword]
1277
      commandLine args
1278
    }
1279
    tasks.findByName("${rel}jSignJars").dependsOn t
1280

    
1281
    t = task "${rel}j_JarSignTests"(
1282
      type: Exec,
1283
      dependsOn: ["${rel}jJarTests"],
1284
      description: "Sign the ${rel.toUpperCase()}J test jar file"
1285
    ) {
1286
      inputs.file "${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar"
1287
      def args = signjarArgs +
1288
        ["${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar",
1289
         signkeyNewAlias,
1290
         "-storepass", signkeyPassword]
1291
      commandLine args
1292
    }
1293
    tasks.findByName("${rel}jSignJars").dependsOn t
1294

    
1295
    t = task "${rel}j_JarSignXqj"(
1296
      type: Exec,
1297
      dependsOn: ["${rel}jJarXqj"],
1298
      description: "Sign the ${rel.toUpperCase()}J XQJ jar file"
1299
    ) {
1300
      inputs.file "${buildDir}/libs/saxon-${rel}-xqj-${saxonVersion}.jar"
1301
      def args = signjarArgs +
1302
        ["${buildDir}/libs/saxon-${rel}-xqj-${saxonVersion}.jar",
1303
         signkeyNewAlias,
1304
         "-storepass", signkeyPassword]
1305
      commandLine args
1306
    }
1307
    tasks.findByName("${rel}jSignJars").dependsOn t
1308

    
1309
    if (rel != 'he') {
1310
      t = task "${rel}j_JarSignSql"(
1311
        type: Exec,
1312
        dependsOn: ["${rel}jJarSql"],
1313
        description: "Sign the ${rel.toUpperCase()} jar file"
1314
      ) {
1315
        inputs.file "${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar"
1316
        def args = signjarArgs +
1317
          ["${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar",
1318
           signkeyNewAlias,
1319
           "-storepass", signkeyPassword]
1320
        commandLine args
1321
      }
1322
      tasks.findByName("${rel}jSignJars").dependsOn t
1323
    }
1324
  } else {
1325
    Task t = task "${rel}j_JarSignJar"(
1326
      description: "Cannot sign the ${rel.toUpperCase()}J jar file"
1327
    ) {
1328
      doLast {
1329
        throw new GradleException("Jar signing is not configured.")
1330
      }
1331
    }
1332
    tasks.findByName("${rel}jSignJars").dependsOn t
1333

    
1334
    t = task "${rel}j_JarSignTests"(
1335
      description: "Cannot sign the ${rel.toUpperCase()}J test jar file"
1336
    ) {
1337
      doLast {
1338
        throw new GradleException("Jar signing is not configured.")
1339
      }
1340
    }
1341
    tasks.findByName("${rel}jSignJars").dependsOn t
1342

    
1343
    t = task "${rel}j_JarSignXqj"(
1344
      description: "Cannot sign the ${rel.toUpperCase()}J XQJ jar file"
1345
    ) {
1346
      doLast {
1347
        throw new GradleException("Jar signing is not configured.")
1348
      }
1349
    }
1350
    tasks.findByName("${rel}jSignJars").dependsOn t
1351

    
1352
    if (rel != 'he') {
1353
      t = task "${rel}j_JarSignSql"(
1354
        description: "Cannot sign the ${rel.toUpperCase()} jar file"
1355
      ) {
1356
        doLast {
1357
          throw new GradleException("Jar signing is not configured.")
1358
        }
1359
      }
1360
      tasks.findByName("${rel}jSignJars").dependsOn t
1361
    }
1362
  }    
1363
}
1364

    
1365
// ============================================================
1366

    
1367
task hejRelease(
1368
  type: Copy,
1369
  dependsOn: ["hejJar", "hejJarXqj", "hejJarTests", "hej_notices"],
1370
  description: "Build the HE release for Java"
1371
) {
1372
  from "${buildDir}/libs"
1373
  into "${buildDir}/releases/hej"
1374
  include "saxon-he-${saxonVersion}.jar"
1375
  include "saxon-he-xqj-${saxonVersion}.jar"
1376
  include "saxon-he-test-${saxonVersion}.jar"
1377
  rename { filename ->
1378
    if (filename.startsWith("saxon-he-test")) {
1379
      filename = "saxon-he-test-${saxonVersion}.jar"
1380
    }
1381
  }
1382
}
1383

    
1384
task pejRelease(
1385
  type: Copy,
1386
  dependsOn: ["pejJar", "pejJarSql", "pejJarTests", "pej_libs", "pej_notices"],
1387
  description: "Build the PE release for Java"
1388
) {
1389
  from "${buildDir}/libs"
1390
  into "${buildDir}/releases/pej"
1391
  include "saxon-pe-${saxonVersion}.jar"
1392
  include "saxon-pe-sql-${saxonVersion}.jar"
1393
  include "saxon-pe-test-${saxonVersion}.jar"
1394
  rename { filename ->
1395
    if (filename.startsWith("saxon-pe-sql")) {
1396
      filename.replace("saxon-pe-sql", "saxon-sql")
1397
    } else {
1398
      filename
1399
    }
1400
  }
1401
}
1402

    
1403
task eejRelease(
1404
  type: Copy,
1405
  dependsOn: ["eejJar", "eejJarSql", "eejJarTests", "eej_libs", "eej_notices"],
1406
  description: "Build the EE release for Java"
1407
) {
1408
  from "${buildDir}/libs"
1409
  into "${buildDir}/releases/eej"
1410
  include "saxon-ee-${saxonVersion}.jar"
1411
  include "saxon-ee-sql-${saxonVersion}.jar"
1412
  include "saxon-ee-test-${saxonVersion}.jar"
1413
  rename { filename ->
1414
    if (filename.startsWith("saxon-ee-sql")) {
1415
      filename.replace("saxon-ee-sql", "saxon-sql")
1416
    } else {
1417
      filename
1418
    }
1419
  }
1420
}
1421

    
1422
if (file("${projectDir}/src/main/java/com").exists()) {
1423
  task javaReleases(
1424
    dependsOn: ["hejRelease", "pejRelease", "eejRelease"],
1425
    description: "Build all of the Java releases"
1426
  ) {
1427
    // Just a container to hang dependencies on
1428
  }
1429
} else {
1430
  // Ignore the EEJ and PEJ releases if the sources aren't available
1431
  task javaReleases(
1432
    dependsOn: ["hejRelease"],
1433
    description: "Build all of the Java releases"
1434
  ) {
1435
    // Just a container to hang dependencies on
1436
  }
1437
}
1438

    
1439
// ============================================================
1440

    
1441
compileTestDrivers.dependsOn "${saxonEdition}j_compileTestDrivers"
1442
runQT3TestDriver.dependsOn "${saxonEdition}j_runQT3TestDriver"
1443
runXslt30TestSuiteDriver.dependsOn "${saxonEdition}j_runXslt30TestSuiteDriver"
1444

    
1445
// ============================================================
1446

    
1447
// Testing task for various Gradle debugging efforts
1448
task helloWorld() {
1449
  doLast {
1450
    println("Hello, world.")
1451
    println(testJit == "")
1452
    /*
1453
    configurations.documentation.resolve().each { path ->
1454
      println(path)
1455
    }
1456
     */
1457
  }
1458
}
(8-8/13)