Project

Profile

Help

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

he / build.gradle @ a31dd97a

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
  samples.extendsFrom(implementation)
35
}
36

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

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

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

    
133
javadoc {
134
  classpath = configurations.implementation
135
}
136

    
137
test {
138
  useJUnitPlatform {
139
    excludeTags 'bytecode'
140
  }
141
}
142

    
143
/*
144
talaiot {
145
  metrics {
146
    performanceMetrics = false
147
  }
148
  publishers {
149
    taskDependencyGraphPublisher {
150
      gexf = false
151
      dot = true
152
      html = false
153
    }
154
  }
155
}
156
*/
157

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

    
169
public class DeleteFilesRecursively {
170
  static void delete(File file){
171
    for (File fspec : file.listFiles()) {
172
      if (fspec.isDirectory()) {
173
        delete(fspec);
174
      } else {
175
        fspec.delete();
176
      }
177
    }
178
    file.delete();
179
  }
180
}
181

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

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

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

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

    
225
def signkeyNewAlias = "THIS-IS-NOT-THE-ALIAS"
226
if (System.getenv("SAXON_SIGN_ALIAS") != null) {
227
  signkeyNewAlias = System.getenv("SAXON_SIGN_ALIAS")
228
}
229

    
230
def signkeyPassword = "THIS-IS-NOT-THE-PASSWORD"
231
if (System.getenv("SAXON_SIGN_PASSWORD") != null) {
232
  signkeyPassword = System.getenv("SAXON_SIGN_PASSWORD")
233
}
234

    
235
def canSignJars = (!eToken.startsWith("THIS-IS-NOT")
236
                   && !signkeyNewAlias.startsWith("THIS-IS-NOT")
237
                   && !signkeyPassword.startsWith("THIS-IS-NOT"))
238

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

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

    
278
apply from: "build-n.gradle"
279
apply from: "build-c.gradle"
280
apply from: "build-doc.gradle"
281
apply from: "test-suites.gradle"
282

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

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

    
305
  return false
306
}
307

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

    
315
["h", "p", "e"].each { initial ->
316
  def release = initial + "e"
317
  def Release = initial.toUpperCase() + "e"
318
  def RELEASE = release.toUpperCase()
319

    
320
  if (release != "he") {
321
    Task libs = task "${release}j_libs"(
322
      description: "Dependency to make sure library files are copie for ${RELEASE}"
323
    ) {
324
      // Just a container to hang dependencies on
325
    }
326

    
327
    Task icu4j = task "${release}j_icu4j"(
328
      type: Copy,
329
      description: "Copy the ICU4J jar into the ${RELEASE} release directory"
330
    ) {
331
      from "${icu4jJar}"
332
      into "${buildDir}/releases/${release}j"
333
    }
334
    libs.dependsOn icu4j
335
  }
336

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

    
359
  task "${release}j_copyTestDrivers"(
360
    dependsOn: ["${release}j_copyTestDriverSources",
361
                "${release}j_copyTestDriverResources"],
362
    description: "Copy test driver sources and resources for ${RELEASE}"
363
  ) {
364
    // Just a container to hang dependencies on
365
  }
366
}
367

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

    
375
task cloneQT3TestSuite() {
376
  doLast {
377
    if (w3cQT3TestSuiteDir == null) {
378
      throw new GradleException("The location of the QT3 test suite is unknown.")
379
    }
380
  }
381
}
382

    
383
task cloneXslt30TestSuite() {
384
  doLast {
385
    if (w3cXslt30TestSuiteDir == null) {
386
      throw new GradleException("The location of the XSLT 3.0 test suite is unknown.")
387
    }
388
  }
389
}
390

    
391
task cloneQT3ExtraTestSuite() {
392
  doLast {
393
    if (saxonQT3ExtraTestSuiteDir == null) {
394
      throw new GradleException("The location of the QT3 extra test suite is unknown.")
395
    }
396
  }
397
}
398

    
399
task cloneXsdTestSuite() {
400
  doLast {
401
    if (w3cXsdTestSuiteDir == null) {
402
      throw new GradleException("The location of the XSD test suite is unknown.")
403
    }
404
  }
405
}
406

    
407
// ============================================================
408

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

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

    
417
task runXslt30TestSuiteDriver() {
418
  // Just a container to hang dependencies on
419
}
420

    
421
["h", "p", "e"].each { initial ->
422
  def release = initial + "e"
423
  def RELEASE = release.toUpperCase()
424
  def jpackage = "com.saxonica.testdriver"
425
  if (release == "he") {
426
    jpackage = "net.sf.saxon.testdriver"
427
  }
428

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

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

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

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

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

    
531
// ============================================================
532

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

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

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

    
582
// ============================================================
583

    
584
task hej_featureKeys(
585
  type: JavaExec,
586
  description: "Construct the feature keys for HE"
587
) {
588
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
589
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/Feature.java"
590
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureCode.java"
591
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureKeys.java"
592
  classpath = configurations.preprocessor
593
  main = "net.sf.saxon.Transform"
594
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
595
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToJava.xsl",
596
    "-o:${projectDir}/src/main/java/net/sf/saxon/lib/establish-an-output-base-uri"
597
}
598

    
599
// Make sure we create feature keys before compiling Java
600
compileJava.dependsOn hej_featureKeys
601

    
602
task hej_setupPreprocess(
603
  type: Copy,
604
  dependsOn: ["hej_featureKeys", "record_branch"],
605
  description: "Copy HE sources for preprocessing HE"
606
) {
607
  from "${projectDir}/src/main/java"
608
  into "${buildDir}/filtered/hej"
609
  include "net/sf/saxon/**/*.java"
610
  include "net/sf/saxon/**/package.html"
611
  //include "net/sf/saxon/data/**"
612
  exclude "javax/xml/xquery/*.java"
613
  exclude "**/dotnet/**"
614
  exclude "net/sf/saxon/testdriver/**"
615
  exclude "net/sf/saxon/option/sql/**"
616
  exclude "net/sf/saxon/option/cpp/**"
617
  exclude "net/sf/saxon/jetonnet/**"
618
}
619

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

    
637
task eej_setupPreprocessForPej(
638
  type: Copy,
639
  description: "Copy EE sources for preprocessing PE"
640
) {
641
  from "${projectDir}/src/main/java"
642
  into "${buildDir}/filtered/pej"
643
  include "com/saxonica/**/*.java"
644
  exclude "com/saxonica/functions/extfn/cpp/*.java"
645
  exclude "com/saxonica/testdriver/**"
646
  exclude "com/saxonica/testdriver/ee/**/*.java"
647
  exclude "com/saxonica/testdriver/old/**/*.java"
648
  exclude "com/saxonica/ee/**"
649
  exclude "com/saxonica/config/EnterpriseConfiguration.java"
650
  exclude "com/saxonica/expr/CastToUnion.java"
651
  exclude "com/saxonica/expr/CastableToUnion.java"
652
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
653
  exclude "com/saxonica/config/ee/**"
654
  exclude "com/saxonica/js/**"
655
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
656
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
657
  exclude "com/saxonica/config/DotNetPlatformPE.java"
658
  exclude "com/saxonica/config/JavaPlatformEE.java"
659
  exclude "com/saxonica/config/NativePlatformPE.java"
660
  exclude "com/saxonica/Validate.java"
661
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
662
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
663
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
664
  exclude "com/saxonica/config/DynamicLoaderEE.java"
665
  exclude "com/saxonica/config/StandardSchemaResolver.java"
666
  exclude "com/saxonica/jaxp/SchemaFactoryImpl11.java"
667
  exclude "com/saxonica/functions/extfn/NativeCall.java"
668
}
669

    
670
task pej_setupPreprocess(
671
  dependsOn: ["hej_setupPreprocessForPej", "eej_setupPreprocessForPej", "record_branch"],
672
  description: "Copy sources for preprocessing PE"
673
) {
674
  // Just a container to hang dependencies on
675
}
676

    
677
task hej_setupPreprocessForEej(
678
  type: Copy,
679
  dependsOn: ["hej_featureKeys", "record_branch"],
680
  description: "Copy HE sources for EE build"
681
) {
682
  from "${projectDir}/src/main/java"
683
  into "${buildDir}/filtered/eej"
684
  include "net/sf/saxon/**/*.java"
685
  include "javax/xml/xquery/*.java"
686
  exclude "**/dotnet/**"
687
  include "net/sf/saxon/**/package.html"
688
  exclude "net/sf/saxon/testdriver/**"
689
  exclude "net/sf/saxon/option/cpp/**"
690
  exclude "net/sf/saxon/jetonnet/**"
691
  exclude "net/sf/saxon/jetonnet/**"
692
  //include "net/sf/saxon/data/**"
693
}
694

    
695
// Rename org.objectweb to com.saxonica.objectweb in the bytecode sources
696
task eej_setupPreprocessBytecode(
697
  type: Copy,
698
  description: "Copy bytecode sources and fix imports"
699
) {
700
  from "${projectDir}/src/main/java"
701
  into "${buildDir}/filtered/eej"
702
  include "com/saxonica/ee/bytecode/**/*.java"
703
  filter { line ->
704
    line.contains("org.objectweb")
705
      ? line.replaceAll("org.objectweb", "com.saxonica.objectweb")
706
      : line
707
  }
708
}
709

    
710
// N.B. bytecode is explicitly excluded, see eej_setupPreprocessBytecode
711
task eej_setupPreprocess(
712
  type: Copy,
713
  dependsOn: ["hej_setupPreprocessForEej", "eej_setupPreprocessBytecode", "record_branch"],
714
  description: "Copy sources for preprocessing EE"
715
) {
716
  from "${projectDir}/src/main/java"
717
  into "${buildDir}/filtered/eej"
718
  include "com/saxonica/**/*.java"
719
  exclude "com/saxonica/ee/bytecode/**/*.java"
720
  exclude "com/saxonica/functions/extfn/cpp/*.java"
721
  exclude "com/saxonica/testdriver/**/*.java"
722
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
723
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
724
  exclude "com/saxonica/config/DotNetPlatformPE.java"
725
  exclude "com/saxonica/config/NativePlatformPE.java"
726
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
727
  exclude "com/saxonica/functions/extfn/NativeCall.java"
728
  include "com/saxonica/**/package.html"
729
  exclude "com/saxonica/js/**"
730
}
731

    
732
// ============================================================
733

    
734
task hej_preprocess(
735
  type: JavaExec,
736
  dependsOn: ["hej_setupPreprocess"],
737
  description: "Preprocess HE sources"
738
) {
739
  inputs.files fileTree(dir: "${buildDir}/filtered/hej")
740
  outputs.files fileTree(dir: "${buildDir}/preprocess/hej")
741
  classpath = configurations.preprocessor
742
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
743
  args "/c",
744
    "/i:${buildDir}/filtered/hej", "/o:${buildDir}/preprocess/hej",
745
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=false",
746
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
747
  doFirst {
748
    mkdir "${buildDir}/preprocess/hej"
749
  }
750
}
751

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

    
770
task eej_preprocess(
771
  type: JavaExec,
772
  dependsOn: ["eej_setupPreprocess", "asm_jarjar"],
773
  description: "Preprocess EE sources"
774
) {
775
  inputs.files fileTree(dir: "${buildDir}/filtered/eej")
776
  outputs.files fileTree(dir: "${buildDir}/preprocess/eej")
777
  classpath = configurations.preprocessor
778
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
779
  args "/c",
780
    "/i:${buildDir}/filtered/eej", "/o:${buildDir}/preprocess/eej",
781
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=false", "/p:HOF=true",
782
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=true",
783
    "/p:STREAM=true", "/p:PACKAGES=true", "/p:SCHEMA=true"
784
  doFirst {
785
    mkdir "${buildDir}/preprocess/eej"
786
  }
787
}
788

    
789
// ============================================================
790

    
791
task hej_sources(
792
  type: Copy,
793
  dependsOn: ["hej_preprocess"],
794
  description: "Collect the preprocessed HE sources for compilation"
795
) {
796
  from "${buildDir}/preprocess/hej"
797
  into "${buildDir}/src/hej"
798
  filter { line ->
799
    line.contains("import com.saxonica") ? null : line.replaceFirst("\\s++\$", "")
800
  }
801
}
802

    
803
task pej_sources(
804
  type: Copy,
805
  dependsOn: ["pej_preprocess"],
806
  description: "Collect the preprocessed PE sources for compilation"
807
) {
808
  from "${buildDir}/preprocess/pej"
809
  into "${buildDir}/src/pej"
810
  filter { line ->
811
    if (line.contains("import com.saxonica.ee")
812
        || line.contains("import com.saxonica.config.ee")) {
813
      null
814
    } else {
815
      line.replaceFirst("\\s++\$", "")
816
    }
817
  }
818
}
819

    
820
task eej_sources(
821
  type: Copy,
822
  dependsOn: ["eej_preprocess"],
823
  description: "Collect the preprocessed EE sources for compilation"
824
) {
825
  from "${buildDir}/preprocess/eej"
826
  into "${buildDir}/src/eej"
827
}
828

    
829
// ============================================================
830

    
831
task record_branch(
832
  type: Exec,
833
  description: "Records the branch so we can detect switches."
834
) {
835
  def recordBranch = new ByteArrayOutputStream();
836
  commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
837
  standardOutput = recordBranch
838
  doLast {
839
    def output = new FileWriter(new File("${buildDir}/built-branch"))
840
    output.write(recordBranch.toString("utf-8"))
841
    output.close()
842
  }
843
  doFirst {
844
    mkdir(buildDir)
845
  }
846
}
847

    
848
task hejCompile(
849
  type: JavaCompile,
850
  dependsOn: ["hej_sources"],
851
  description: "Compile HE for Saxon/Java"
852
) {
853
  classpath = configurations.compileClasspath
854
  source "${buildDir}/src/hej"
855
  destinationDirectory = new File("${buildDir}/classes/hej")
856
}
857

    
858
task pejCompile(
859
  type: JavaCompile,
860
  dependsOn: ["pej_sources"],
861
  description: "Compile PE for Saxon/Java"
862
) {
863
  classpath = configurations.compileClasspath
864
  source "${buildDir}/src/pej"
865
  destinationDirectory = new File("${buildDir}/classes/pej")
866
}
867

    
868
task eejCompile(
869
  type: JavaCompile,
870
  dependsOn: ["eej_sources"],
871
  description: "Compile EE for Saxon/Java"
872
) {
873
  classpath = configurations.compileClasspath + configurations.jarjarAsm
874
  source "${buildDir}/src/eej"
875
  destinationDirectory = new File("${buildDir}/classes/eej")
876
}
877

    
878
// ============================================================
879

    
880
task hej_copyTestDriverSources(
881
  type: Copy,
882
  description: "Copy test drivers sources for HE"
883
) {
884
  from "src/main/java"
885
  into "${buildDir}/src/testdrivers/hej"
886
  include "net/sf/saxon/testdriver/*.java"
887
}
888

    
889
task pej_copyTestDriverSources(
890
  type: Copy,
891
  description: "Copy test drivers sources for PE"
892
) {
893
  from "src/main/java"
894
  into "${buildDir}/src/testdrivers/pej"
895
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
896
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
897
  include "com/saxonica/testdriver/Licensor.java"
898
  include "net/sf/saxon/testdriver/*.java"
899
}
900

    
901
task eej_copyTestDriverSources(
902
  type: Copy,
903
  description: "Copy test drivers sources for EE"
904
) {
905
  from "src/main/java"
906
  into "${buildDir}/src/testdrivers/eej"
907
  include "com/saxonica/testdriver/**/*.java"
908
  include "com/saxonica/js/*.java"
909
  include "net/sf/saxon/testdriver/*.java"
910
}
911

    
912
task hej_copyTestDriverResources(
913
  type: Copy,
914
  description: "Copy test drivers resources for HE"
915
) {
916
  from "src/main/java"
917
  into "${buildDir}/testdriver_classes/hej"
918
  include "net/sf/saxon/testdriver/**"
919
  exclude "net/sf/saxon/testdriver/**/*.java"
920
}
921

    
922
task pej_copyTestDriverResources(
923
  type: Copy,
924
  description: "Copy test drivers resources for PE"
925
) {
926
  from "src/main/java"
927
  into "${buildDir}/testdriver_classes/pej"
928
  include "net/sf/saxon/testdriver/**"
929
  include "com/saxonica/testdriver/**"
930
  exclude "net/sf/saxon/testdriver/**/*.java"
931
  exclude "com/saxonica/testdriver/**/*.java"
932
  exclude "com/saxonica/testdriver/old/**"
933
  exclude "com/saxonica/testdriver/gui/cache.xml"
934
}
935

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

    
950
// ============================================================
951
// These tasks all relate to renaming (re-jarring) the ASM jar files
952
// for EE so that the class names begin com.saxonica. This avoids a
953
// problem where a different version of the ASM libraries is used in
954
// the application that is using Saxon.
955

    
956
task asm_createRules(
957
  description: "Create the jarjar rules file for the ASM libraries"
958
) {
959
  outputs.file("${buildDir}/jarjar-asm.rules")
960
  doLast {
961
    new File("${buildDir}/jarjar-asm.rules")
962
      .withWriter("utf-8") { writer ->
963
        writer.writeLine("rule org.objectweb.** com.saxonica.objectweb.@1")
964
      }
965
  }
966
  doFirst {
967
    mkdir "${buildDir}"
968
  }
969
}
970

    
971
task asm_jarjar(
972
  description: "Placeholder for the ASM jarjar dependencies"
973
) {
974
  // just a task to hang dependencies on
975
}
976

    
977
task asm_unzip(
978
  type: Copy,
979
  description: "Extract classes from the asm-xml-${asmVersion} jar"
980
) {
981
  // This one is from the original ASM
982
  def zipFile = file("lib/asm-${asmVersion}/asm-xml-${asmVersion}.jar")
983
  def outputDir = "${buildDir}/classes/eej"
984
  from zipTree(zipFile)
985
  into outputDir
986
}
987

    
988
["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"].each { asm ->
989
  Task t = task "asm_${asm}"(
990
    type: JavaExec,
991
    dependsOn: ["asm_createRules"],
992
    description: "Run jarjar on ${asm}-${asmVersion} classes"
993
) {
994
    inputs.file "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar"
995
    outputs.file "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
996
    classpath = configurations.preprocessor
997
    main = "com.tonicsystems.jarjar.Main"
998
    args "--rules", "${buildDir}/jarjar-asm.rules",
999
      "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar",
1000
      "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
1001
    doFirst {
1002
      mkdir "${buildDir}/lib/asm"
1003
    }
1004
  }
1005
  asm_jarjar.dependsOn t
1006

    
1007
  t = task "asm_unzip${asm}"(
1008
    type: Copy,
1009
    dependsOn: ["asm_jarjar"],
1010
    description: "Extract the classes from the ${asm}-${asmVersion} jar"
1011
  ) {
1012
    def zipFile = file("${buildDir}/lib/asm/${asm}-${asmVersion}.jar")
1013
    def outputDir = "${buildDir}/classes/eej"
1014
    from zipTree(zipFile)
1015
    into outputDir
1016
  }
1017
  asm_unzip.dependsOn t
1018
}
1019

    
1020
// ============================================================
1021

    
1022
task hej_MetaInf(
1023
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for HE"
1024
) {
1025
  outputs.file("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
1026
  doFirst {
1027
    mkdir "${buildDir}/services/saxon-he/META-INF/services"
1028
  }
1029
  doLast {
1030
    new File("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
1031
      .withWriter("utf-8") { writer ->
1032
        writer.writeLine("net.sf.saxon.TransformerFactoryImpl")
1033
      }
1034
  }
1035
}
1036

    
1037
task pej_MetaInf(
1038
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for PE"
1039
) {
1040
  outputs.file("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
1041
  doFirst {
1042
    mkdir "${buildDir}/services/saxon-pe/META-INF/services"
1043
  }
1044
  doLast {
1045
    new File("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
1046
      .withWriter("utf-8") { writer ->
1047
        writer.writeLine("com.saxonica.config.ProfessionalTransformerFactory")
1048
      }
1049
  }
1050
}
1051

    
1052
task eej_schemaFactoryMetaInf(
1053
  description: "Create META-INF/services/javax.xml.validation.SchemaFactory for EE"
1054
) {
1055
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
1056
  doFirst {
1057
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
1058
  }
1059
  doLast {
1060
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
1061
      .withWriter("utf-8") { writer ->
1062
        writer.writeLine("com.saxonica.ee.jaxp.SchemaFactoryImpl")
1063
      }
1064
  }
1065
}
1066

    
1067
task eej_MetaInf(
1068
  dependsOn: ["eej_schemaFactoryMetaInf"],
1069
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for EE"
1070
) {
1071
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
1072
  doFirst {
1073
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
1074
  }
1075
  doLast {
1076
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
1077
      .withWriter("utf-8") { writer ->
1078
        writer.writeLine("com.saxonica.config.EnterpriseTransformerFactory")
1079
      }
1080
  }
1081
}
1082

    
1083
// ============================================================
1084

    
1085
task hejJar(
1086
  type: Jar,
1087
  dependsOn: ["hej_MetaInf", "hejCompile"],
1088
  description: "Build the HE jar file"
1089
) {
1090
  archiveBaseName = "saxon-he-${saxonVersion}"
1091
  manifest {
1092
    attributes "Project-Name": "Saxon-HE"
1093
    attributes "Main-Class": "net.sf.saxon.Transform"
1094
  }
1095
  from ("${buildDir}/services/saxon-he") {
1096
    include "META-INF/**"
1097
  }
1098
  from ("${buildDir}/classes/hej") {
1099
    include "net/**/*.class"
1100
    exclude "net/sf/saxon/option/**"
1101
  }
1102
  from ("src/main/resources") {
1103
    include "net/sf/saxon/data/**"
1104
  }
1105
}
1106

    
1107
// Because the XQJ files are not open source, don't attempt to build
1108
// the jar unless the EE sources are available.
1109
if (file("${projectDir}/src/main/java/com/saxonica/xqj").exists()) {
1110
  task hejJarXqj(
1111
    type: Jar,
1112
    dependsOn: ["eejCompile"],
1113
    description: "Build the XQJ jar file for HE"
1114
  ) {
1115
    archiveBaseName = "saxon-he-xqj-${saxonVersion}"
1116
    from ("${buildDir}/classes/eej") {
1117
      include "com/saxonica/xqj/**/*.class"
1118
      include "javax/xml/xquery/**/*.class"
1119
    }
1120
  }
1121
} else {
1122
  task hejJarXqj(
1123
    description: "Ignore the XQJ file; the sources are unavailable"
1124
  ) {
1125
    doLast {
1126
      println("Ignoring XQJ jar file task; the sources are unavailable")
1127
    }
1128
  }
1129
}
1130

    
1131
task pejJar(
1132
  type: Jar,
1133
  dependsOn: ["pej_MetaInf", "pejCompile"],
1134
  description: "Build the PE jar file"
1135
) {
1136
  archiveBaseName = "saxon-pe-${saxonVersion}"
1137
  manifest {
1138
    attributes "Project-Name": "Saxon-PE"
1139
    attributes "Main-Class": "net.sf.saxon.Transform"
1140
  }
1141
  from ("${buildDir}/services/saxon-pe") {
1142
    include "META-INF/**"
1143
  }
1144
  from ("${buildDir}/classes/pej") {
1145
    include "net/**/*.class"
1146
    include "com/saxonica/**/*.class"
1147
    include "javax/xml/xquery/*.class"
1148
    exclude "**/sql/**/*.class"
1149
    exclude "com/saxonica/CompileStylesheet.class"
1150
    exclude "com/saxonica/CompileStylesheet\$TracingObjectOutputStream.class"
1151
    exclude "com/saxonica/Validate.class"
1152
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
1153
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
1154
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
1155
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
1156
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
1157
    exclude "com/saxonica/ee/**/*.class"
1158
    exclude "com/saxonica/expr/CastToList.class"
1159
    exclude "com/saxonica/expr/CastToUnion.class"
1160
    exclude "com/saxonica/expr/CastableToList.class"
1161
    exclude "com/saxonica/expr/CastableToUnion.class"
1162
    exclude "com/saxonica/functions/sql/**"
1163
    exclude "net/sf/saxon/option/sql/**"
1164
  }
1165
  from ("src/main/resources") {
1166
    include "net/sf/saxon/data/**"
1167
  }
1168
}
1169

    
1170
task pejJarSql(
1171
  type: Jar,
1172
  dependsOn: ["pejCompile"],
1173
  description: "Build the SQL jar file for PE"
1174
) {
1175
  archiveBaseName = "saxon-pe-sql-${saxonVersion}"
1176
  from ("${buildDir}/classes/pej") {
1177
    include "net/sf/saxon/option/sql/*.class"
1178
    include "com/saxonica/functions/sql/*.class"
1179
  }
1180
}
1181

    
1182
task eejJar(
1183
  type: Jar,
1184
  dependsOn: ["eej_MetaInf", "eejCompile", "asm_unzip"],
1185
  description: "Build the EE jar file"
1186
) {
1187
  archiveBaseName = "saxon-ee-${saxonVersion}"
1188
  manifest {
1189
    attributes "Project-Name": "Saxon-EE"
1190
    attributes "Main-Class": "net.sf.saxon.Transform"
1191
  }
1192
  from ("${buildDir}/services/saxon-ee") {
1193
    include "META-INF/**"
1194
  }
1195
  from ("${buildDir}/classes/eej") {
1196
    include "net/**/*.class"
1197
    include "com/saxonica/**/*.class"
1198
    include "javax/xml/xquery/*.class"
1199
    exclude "org/objectweb/**/*.class"
1200
    exclude "**/sql/**/*.class"
1201
    exclude "com/saxonica/StatsTransform*.class"
1202
    exclude "com/saxonica/functions/sql/**"
1203
    exclude "net/sf/saxon/option/sql/**"
1204
  }
1205
  from ("src/main/resources") {
1206
    include "net/sf/saxon/data/**"
1207
  }
1208
}
1209

    
1210
task eejJarSql(
1211
  type: Jar,
1212
  dependsOn: ["eejCompile"],
1213
  description: "Build the SQL jar file for EE"
1214
) {
1215
  archiveBaseName = "saxon-ee-sql-${saxonVersion}"
1216
  from ("${buildDir}/classes/eej") {
1217
    include "net/sf/saxon/option/sql/*.class"
1218
    include "com/saxonica/functions/sql/*.class"
1219
  }
1220
}
1221

    
1222
// ============================================================
1223

    
1224
task signJars(
1225
  dependsOn: ["hejSignJars", "pejSignJars", "eejSignJars"],
1226
  description: "Sign all the jar files."
1227
) {
1228
  // Just a container to hang dependencies on
1229
}
1230

    
1231
task hejSignJars(
1232
  description: "Sign the HEJ jar files"
1233
) {
1234
  // Just a container to hang dependencies on
1235
}
1236

    
1237
task pejSignJars(
1238
  description: "Sign the PEJ jar files"
1239
) {
1240
  // Just a container to hang dependencies on
1241
}
1242

    
1243
task eejSignJars(
1244
  description: "Sign the EEJ jar files"
1245
) {
1246
  // Just a container to hang dependencies on
1247
}
1248

    
1249
// Create tasks for signing jars...
1250
["he", "pe", "ee"].each { rel ->
1251
  if (canSignJars) {
1252
    Task t = task "${rel}_jJarSignJar"(
1253
      type: Exec,
1254
      dependsOn: ["${rel}jJar"],
1255
      description: "Sign the ${rel.toUpperCase()}J jar file"
1256
    ) {
1257
      inputs.file "${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar"
1258
      def args = signjarArgs +
1259
        ["${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar",
1260
         signkeyNewAlias,
1261
         "-storepass", signkeyPassword]
1262
      commandLine args
1263
    }
1264
    tasks.findByName("${rel}jSignJars").dependsOn t
1265

    
1266
    t = task "${rel}j_JarSignTests"(
1267
      type: Exec,
1268
      dependsOn: ["${rel}jJarTests"],
1269
      description: "Sign the ${rel.toUpperCase()}J test jar file"
1270
    ) {
1271
      inputs.file "${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar"
1272
      def args = signjarArgs +
1273
        ["${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar",
1274
         signkeyNewAlias,
1275
         "-storepass", signkeyPassword]
1276
      commandLine args
1277
    }
1278
    tasks.findByName("${rel}jSignJars").dependsOn t
1279

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

    
1294
    if (rel != 'he') {
1295
      t = task "${rel}j_JarSignSql"(
1296
        type: Exec,
1297
        dependsOn: ["${rel}jJarSql"],
1298
        description: "Sign the ${rel.toUpperCase()} jar file"
1299
      ) {
1300
        inputs.file "${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar"
1301
        def args = signjarArgs +
1302
          ["${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar",
1303
           signkeyNewAlias,
1304
           "-storepass", signkeyPassword]
1305
        commandLine args
1306
      }
1307
      tasks.findByName("${rel}jSignJars").dependsOn t
1308
    }
1309
  } else {
1310
    Task t = task "${rel}j_JarSignJar"(
1311
      description: "Cannot sign the ${rel.toUpperCase()}J jar file"
1312
    ) {
1313
      doLast {
1314
        throw new GradleException("Jar signing is not configured.")
1315
      }
1316
    }
1317
    tasks.findByName("${rel}jSignJars").dependsOn t
1318

    
1319
    t = task "${rel}j_JarSignTests"(
1320
      description: "Cannot sign the ${rel.toUpperCase()}J test jar file"
1321
    ) {
1322
      doLast {
1323
        throw new GradleException("Jar signing is not configured.")
1324
      }
1325
    }
1326
    tasks.findByName("${rel}jSignJars").dependsOn t
1327

    
1328
    t = task "${rel}j_JarSignXqj"(
1329
      description: "Cannot sign the ${rel.toUpperCase()}J XQJ jar file"
1330
    ) {
1331
      doLast {
1332
        throw new GradleException("Jar signing is not configured.")
1333
      }
1334
    }
1335
    tasks.findByName("${rel}jSignJars").dependsOn t
1336

    
1337
    if (rel != 'he') {
1338
      t = task "${rel}j_JarSignSql"(
1339
        description: "Cannot sign the ${rel.toUpperCase()} jar file"
1340
      ) {
1341
        doLast {
1342
          throw new GradleException("Jar signing is not configured.")
1343
        }
1344
      }
1345
      tasks.findByName("${rel}jSignJars").dependsOn t
1346
    }
1347
  }    
1348
}
1349

    
1350
// ============================================================
1351

    
1352
task hejRelease(
1353
  type: Copy,
1354
  dependsOn: ["hejJar", "hejJarXqj", "hejJarTests", "hej_notices"],
1355
  description: "Build the HE release for Java"
1356
) {
1357
  from "${buildDir}/libs"
1358
  into "${buildDir}/releases/hej"
1359
  include "saxon-he-${saxonVersion}.jar"
1360
  include "saxon-he-xqj-${saxonVersion}.jar"
1361
  include "saxon-he-test-${saxonVersion}.jar"
1362
  rename { filename ->
1363
    if (filename.startsWith("saxon-he-test")) {
1364
      filename = "saxon-he-test-${saxonVersion}.jar"
1365
    }
1366
  }
1367
}
1368

    
1369
task pejRelease(
1370
  type: Copy,
1371
  dependsOn: ["pejJar", "pejJarSql", "pejJarTests", "pej_libs", "pej_notices"],
1372
  description: "Build the PE release for Java"
1373
) {
1374
  from "${buildDir}/libs"
1375
  into "${buildDir}/releases/pej"
1376
  include "saxon-pe-${saxonVersion}.jar"
1377
  include "saxon-pe-sql-${saxonVersion}.jar"
1378
  include "saxon-pe-test-${saxonVersion}.jar"
1379
  rename { filename ->
1380
    if (filename.startsWith("saxon-pe-sql")) {
1381
      filename.replace("saxon-pe-sql", "saxon-sql")
1382
    } else {
1383
      filename
1384
    }
1385
  }
1386
}
1387

    
1388
task eejRelease(
1389
  type: Copy,
1390
  dependsOn: ["eejJar", "eejJarSql", "eejJarTests", "eej_libs", "eej_notices"],
1391
  description: "Build the EE release for Java"
1392
) {
1393
  from "${buildDir}/libs"
1394
  into "${buildDir}/releases/eej"
1395
  include "saxon-ee-${saxonVersion}.jar"
1396
  include "saxon-ee-sql-${saxonVersion}.jar"
1397
  include "saxon-ee-test-${saxonVersion}.jar"
1398
  rename { filename ->
1399
    if (filename.startsWith("saxon-ee-sql")) {
1400
      filename.replace("saxon-ee-sql", "saxon-sql")
1401
    } else {
1402
      filename
1403
    }
1404
  }
1405
}
1406

    
1407
if (file("${projectDir}/src/main/java/com").exists()) {
1408
  task javaReleases(
1409
    dependsOn: ["hejRelease", "pejRelease", "eejRelease"],
1410
    description: "Build all of the Java releases"
1411
  ) {
1412
    // Just a container to hang dependencies on
1413
  }
1414
} else {
1415
  // Ignore the EEJ and PEJ releases if the sources aren't available
1416
  task javaReleases(
1417
    dependsOn: ["hejRelease"],
1418
    description: "Build all of the Java releases"
1419
  ) {
1420
    // Just a container to hang dependencies on
1421
  }
1422
}
1423

    
1424
// ============================================================
1425

    
1426
compileTestDrivers.dependsOn "${saxonEdition}j_compileTestDrivers"
1427
runQT3TestDriver.dependsOn "${saxonEdition}j_runQT3TestDriver"
1428
runXslt30TestSuiteDriver.dependsOn "${saxonEdition}j_runXslt30TestSuiteDriver"
1429

    
1430
// ============================================================
1431

    
1432
// Testing task for various Gradle debugging efforts
1433
task helloWorld() {
1434
  doLast {
1435
    println("Hello, world.")
1436
    println(testJit == "")
1437
    /*
1438
    configurations.documentation.resolve().each { path ->
1439
      println(path)
1440
    }
1441
     */
1442
  }
1443
}
(8-8/14)