Project

Profile

Help

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

he / build.gradle @ acdcff21

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

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

    
131
javadoc {
132
  classpath = configurations.implementation
133
}
134

    
135
test {
136
  useJUnitPlatform {
137
    excludeTags 'bytecode'
138
  }
139
}
140

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
303
  return false
304
}
305

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

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

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

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

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

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

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

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

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

    
389
task cloneXsdTestSuite() {
390
  doLast {
391
    if (w3cXsdTestSuiteDir == null) {
392
      throw new GradleException("The location of the XSD test suite is unknown.")
393
    }
394
  }
395
}
396

    
397
// ============================================================
398

    
399
task hejJarTests(
400
  type: Jar,
401
  dependsOn: ["hejCompile", "hej_compileTestDrivers"],
402
  description: "Create the tests jar file for HE"
403
) {
404
  archiveBaseName = "saxon-he-test-${saxonVersion}"
405
  manifest {
406
    attributes "Project-Name": "Saxon-HE-TestDriver"
407
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
408
  }
409
  from ("${buildDir}/testdriver_classes/hej") {
410
    include "net/sf/saxon/testdriver/**"
411
  }
412
}
413

    
414
task pejJarTests(
415
  type: Jar,
416
  dependsOn: ["pejCompile", "pej_compileTestDrivers"],
417
  description: "Create the tests jar file for PE"
418
) {
419
  archiveBaseName = "saxon-pe-test-${saxonVersion}"
420
  manifest {
421
    attributes "Project-Name": "Saxon-PE-TestDriver"
422
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
423
  }
424
  from ("${buildDir}/testdriver_classes/pej") {
425
    include "net/sf/saxon/testdriver/**"
426
    include "com/saxonica/testdriver/**"
427
    exclude "com/saxonica/testdriver/ee/**"
428
  }
429
}
430

    
431
task eejJarTests(
432
  type: Jar,
433
  dependsOn: ["eejCompile", "eej_compileTestDrivers"],
434
  description: "Create the tests jar file for EE"
435
) {
436
  archiveBaseName = "saxon-ee-test-${saxonVersion}"
437
  manifest {
438
    attributes "Project-Name": "Saxon-EE-TestDriver"
439
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
440
  }
441
  from ("${buildDir}/testdriver_classes/eej") {
442
    include "net/sf/saxon/testdriver/**"
443
    include "com/saxonica/testdriver/**"
444
    include "com/saxonica/js/**"
445
  }
446
}
447

    
448
// ============================================================
449

    
450
task hej_featureKeys(
451
  type: JavaExec,
452
  description: "Construct the feature keys for HE"
453
) {
454
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
455
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/Feature.java"
456
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureCode.java"
457
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureKeys.java"
458
  classpath = configurations.preprocessor
459
  main = "net.sf.saxon.Transform"
460
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
461
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToJava.xsl",
462
    "-o:${projectDir}/src/main/java/net/sf/saxon/lib/establish-an-output-base-uri"
463
}
464

    
465
// Make sure we create feature keys before compiling Java
466
compileJava.dependsOn hej_featureKeys
467

    
468
task hej_setupPreprocess(
469
  type: Copy,
470
  dependsOn: ["hej_featureKeys", "record_branch"],
471
  description: "Copy HE sources for preprocessing HE"
472
) {
473
  from "${projectDir}/src/main/java"
474
  into "${buildDir}/filtered/hej"
475
  include "net/sf/saxon/**/*.java"
476
  include "net/sf/saxon/**/package.html"
477
  //include "net/sf/saxon/data/**"
478
  exclude "javax/xml/xquery/*.java"
479
  exclude "**/dotnet/**"
480
  exclude "net/sf/saxon/testdriver/**"
481
  exclude "net/sf/saxon/option/sql/**"
482
  exclude "net/sf/saxon/option/cpp/**"
483
  exclude "net/sf/saxon/jetonnet/**"
484
}
485

    
486
task hej_setupPreprocessForPej(
487
  type: Copy,
488
  dependsOn: ["hej_featureKeys"],
489
  description: "Copy HE sources for preprocessing PE"
490
) {
491
  from "${projectDir}/src/main/java"
492
  into "${buildDir}/filtered/pej"
493
  include "net/sf/saxon/**/*.java"
494
  include "javax/xml/xquery/*.java"
495
  exclude "**/dotnet/**"
496
  include "net/sf/saxon/**/package.html"
497
  exclude "net/sf/saxon/testdriver/**"
498
  exclude "net/sf/saxon/option/cpp/**"
499
  exclude "net/sf/saxon/jetonnet/**"
500
  //include "net/sf/saxon/data/**"
501
}
502

    
503
task eej_setupPreprocessForPej(
504
  type: Copy,
505
  description: "Copy EE sources for preprocessing PE"
506
) {
507
  from "${projectDir}/src/main/java"
508
  into "${buildDir}/filtered/pej"
509
  include "com/saxonica/**/*.java"
510
  exclude "com/saxonica/functions/extfn/cpp/*.java"
511
  exclude "com/saxonica/testdriver/**"
512
  exclude "com/saxonica/testdriver/ee/**/*.java"
513
  exclude "com/saxonica/testdriver/old/**/*.java"
514
  exclude "com/saxonica/ee/**"
515
  exclude "com/saxonica/config/EnterpriseConfiguration.java"
516
  exclude "com/saxonica/expr/CastToUnion.java"
517
  exclude "com/saxonica/expr/CastableToUnion.java"
518
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
519
  exclude "com/saxonica/config/ee/**"
520
  exclude "com/saxonica/js/**"
521
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
522
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
523
  exclude "com/saxonica/config/DotNetPlatformPE.java"
524
  exclude "com/saxonica/config/JavaPlatformEE.java"
525
  exclude "com/saxonica/config/NativePlatformPE.java"
526
  exclude "com/saxonica/Validate.java"
527
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
528
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
529
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
530
  exclude "com/saxonica/config/DynamicLoaderEE.java"
531
  exclude "com/saxonica/config/StandardSchemaResolver.java"
532
  exclude "com/saxonica/jaxp/SchemaFactoryImpl11.java"
533
  exclude "com/saxonica/functions/extfn/NativeCall.java"
534
}
535

    
536
task pej_setupPreprocess(
537
  dependsOn: ["hej_setupPreprocessForPej", "eej_setupPreprocessForPej", "record_branch"],
538
  description: "Copy sources for preprocessing PE"
539
) {
540
  // Just a container to hang dependencies on
541
}
542

    
543
task hej_setupPreprocessForEej(
544
  type: Copy,
545
  dependsOn: ["hej_featureKeys", "record_branch"],
546
  description: "Copy HE sources for EE build"
547
) {
548
  from "${projectDir}/src/main/java"
549
  into "${buildDir}/filtered/eej"
550
  include "net/sf/saxon/**/*.java"
551
  include "javax/xml/xquery/*.java"
552
  exclude "**/dotnet/**"
553
  include "net/sf/saxon/**/package.html"
554
  exclude "net/sf/saxon/testdriver/**"
555
  exclude "net/sf/saxon/option/cpp/**"
556
  exclude "net/sf/saxon/jetonnet/**"
557
  exclude "net/sf/saxon/jetonnet/**"
558
  //include "net/sf/saxon/data/**"
559
}
560

    
561
// Rename org.objectweb to com.saxonica.objectweb in the bytecode sources
562
task eej_setupPreprocessBytecode(
563
  type: Copy,
564
  description: "Copy bytecode sources and fix imports"
565
) {
566
  from "${projectDir}/src/main/java"
567
  into "${buildDir}/filtered/eej"
568
  include "com/saxonica/ee/bytecode/**/*.java"
569
  filter { line ->
570
    line.contains("org.objectweb")
571
      ? line.replaceAll("org.objectweb", "com.saxonica.objectweb")
572
      : line
573
  }
574
}
575

    
576
// N.B. bytecode is explicitly excluded, see eej_setupPreprocessBytecode
577
task eej_setupPreprocess(
578
  type: Copy,
579
  dependsOn: ["hej_setupPreprocessForEej", "eej_setupPreprocessBytecode", "record_branch"],
580
  description: "Copy sources for preprocessing EE"
581
) {
582
  from "${projectDir}/src/main/java"
583
  into "${buildDir}/filtered/eej"
584
  include "com/saxonica/**/*.java"
585
  exclude "com/saxonica/ee/bytecode/**/*.java"
586
  exclude "com/saxonica/functions/extfn/cpp/*.java"
587
  exclude "com/saxonica/testdriver/**/*.java"
588
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
589
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
590
  exclude "com/saxonica/config/DotNetPlatformPE.java"
591
  exclude "com/saxonica/config/NativePlatformPE.java"
592
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
593
  exclude "com/saxonica/functions/extfn/NativeCall.java"
594
  include "com/saxonica/**/package.html"
595
  exclude "com/saxonica/js/**"
596
}
597

    
598
// ============================================================
599

    
600
task hej_preprocess(
601
  type: JavaExec,
602
  dependsOn: ["hej_setupPreprocess"],
603
  description: "Preprocess HE sources"
604
) {
605
  inputs.files fileTree(dir: "${buildDir}/filtered/hej")
606
  outputs.files fileTree(dir: "${buildDir}/preprocess/hej")
607
  classpath = configurations.preprocessor
608
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
609
  args "/c",
610
    "/i:${buildDir}/filtered/hej", "/o:${buildDir}/preprocess/hej",
611
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=false",
612
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
613
  doFirst {
614
    mkdir "${buildDir}/preprocess/hej"
615
  }
616
}
617

    
618
task pej_preprocess(
619
  type: JavaExec,
620
  dependsOn: ["pej_setupPreprocess"],
621
  description: "Preprocess HE sources"
622
) {
623
  inputs.files fileTree(dir: "${buildDir}/filtered/pej")
624
  outputs.files fileTree(dir: "${buildDir}/preprocess/pej")
625
  classpath = configurations.preprocessor
626
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
627
  args "/c",
628
    "/i:${buildDir}/filtered/pej", "/o:${buildDir}/preprocess/pej",
629
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=false", "/p:HOF=true",
630
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
631
  doFirst {
632
    mkdir "${buildDir}/preprocess/pej"
633
  }
634
}
635

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

    
655
// ============================================================
656

    
657
task hej_sources(
658
  type: Copy,
659
  dependsOn: ["hej_preprocess"],
660
  description: "Collect the preprocessed HE sources for compilation"
661
) {
662
  from "${buildDir}/preprocess/hej"
663
  into "${buildDir}/src/hej"
664
  filter { line ->
665
    line.contains("import com.saxonica") ? null : line.replaceFirst("\\s++\$", "")
666
  }
667
}
668

    
669
task pej_sources(
670
  type: Copy,
671
  dependsOn: ["pej_preprocess"],
672
  description: "Collect the preprocessed PE sources for compilation"
673
) {
674
  from "${buildDir}/preprocess/pej"
675
  into "${buildDir}/src/pej"
676
  filter { line ->
677
    if (line.contains("import com.saxonica.ee")
678
        || line.contains("import com.saxonica.config.ee")) {
679
      null
680
    } else {
681
      line.replaceFirst("\\s++\$", "")
682
    }
683
  }
684
}
685

    
686
task eej_sources(
687
  type: Copy,
688
  dependsOn: ["eej_preprocess"],
689
  description: "Collect the preprocessed EE sources for compilation"
690
) {
691
  from "${buildDir}/preprocess/eej"
692
  into "${buildDir}/src/eej"
693
}
694

    
695
// ============================================================
696

    
697
task record_branch(
698
  type: Exec,
699
  description: "Records the branch so we can detect switches."
700
) {
701
  def recordBranch = new ByteArrayOutputStream();
702
  commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
703
  standardOutput = recordBranch
704
  doLast {
705
    def output = new FileWriter(new File("${buildDir}/built-branch"))
706
    output.write(recordBranch.toString("utf-8"))
707
    output.close()
708
  }
709
  doFirst {
710
    mkdir(buildDir)
711
  }
712
}
713

    
714
task hejCompile(
715
  type: JavaCompile,
716
  dependsOn: ["hej_sources"],
717
  description: "Compile HE for Saxon/Java"
718
) {
719
  classpath = configurations.compileClasspath
720
  source "${buildDir}/src/hej"
721
  destinationDirectory = new File("${buildDir}/classes/hej")
722
}
723

    
724
task pejCompile(
725
  type: JavaCompile,
726
  dependsOn: ["pej_sources"],
727
  description: "Compile PE for Saxon/Java"
728
) {
729
  classpath = configurations.compileClasspath
730
  source "${buildDir}/src/pej"
731
  destinationDirectory = new File("${buildDir}/classes/pej")
732
}
733

    
734
task eejCompile(
735
  type: JavaCompile,
736
  dependsOn: ["eej_sources"],
737
  description: "Compile EE for Saxon/Java"
738
) {
739
  classpath = configurations.compileClasspath + configurations.jarjarAsm
740
  source "${buildDir}/src/eej"
741
  destinationDirectory = new File("${buildDir}/classes/eej")
742
}
743

    
744
// ============================================================
745

    
746
task hej_copyTestDriverSources(
747
  type: Copy,
748
  description: "Copy test drivers sources for HE"
749
) {
750
  from "src/main/java"
751
  into "${buildDir}/src/testdrivers/hej"
752
  include "net/sf/saxon/testdriver/*.java"
753
}
754

    
755
task pej_copyTestDriverSources(
756
  type: Copy,
757
  description: "Copy test drivers sources for PE"
758
) {
759
  from "src/main/java"
760
  into "${buildDir}/src/testdrivers/pej"
761
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
762
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
763
  include "com/saxonica/testdriver/Licensor.java"
764
  include "net/sf/saxon/testdriver/*.java"
765
}
766

    
767
task eej_copyTestDriverSources(
768
  type: Copy,
769
  description: "Copy test drivers sources for EE"
770
) {
771
  from "src/main/java"
772
  into "${buildDir}/src/testdrivers/eej"
773
  include "com/saxonica/testdriver/**/*.java"
774
  include "com/saxonica/js/*.java"
775
  include "net/sf/saxon/testdriver/*.java"
776
}
777

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

    
788
task pej_copyTestDriverResources(
789
  type: Copy,
790
  description: "Copy test drivers resources for PE"
791
) {
792
  from "src/main/java"
793
  into "${buildDir}/testdriver_classes/pej"
794
  include "net/sf/saxon/testdriver/**"
795
  include "com/saxonica/testdriver/**"
796
  exclude "net/sf/saxon/testdriver/**/*.java"
797
  exclude "com/saxonica/testdriver/**/*.java"
798
  exclude "com/saxonica/testdriver/old/**"
799
  exclude "com/saxonica/testdriver/gui/cache.xml"
800
}
801

    
802
task eej_copyTestDriverResources(
803
  type: Copy,
804
  description: "Copy test drivers resources for EE"
805
) {
806
  from "src/main/java"
807
  into "${buildDir}/testdriver_classes/eej"
808
  include "net/sf/saxon/testdriver/**"
809
  include "com/saxonica/testdriver/**"
810
  exclude "net/sf/saxon/testdriver/**/*.java"
811
  exclude "com/saxonica/testdriver/**/*.java"
812
  exclude "com/saxonica/testdriver/old/**"
813
  exclude "com/saxonica/testdriver/gui/cache.xml"
814
}
815

    
816
// ============================================================
817
// These tasks all relate to renaming (re-jarring) the ASM jar files
818
// for EE so that the class names begin com.saxonica. This avoids a
819
// problem where a different version of the ASM libraries is used in
820
// the application that is using Saxon.
821

    
822
task asm_createRules(
823
  description: "Create the jarjar rules file for the ASM libraries"
824
) {
825
  outputs.file("${buildDir}/jarjar-asm.rules")
826
  doLast {
827
    new File("${buildDir}/jarjar-asm.rules")
828
      .withWriter("utf-8") { writer ->
829
        writer.writeLine("rule org.objectweb.** com.saxonica.objectweb.@1")
830
      }
831
  }
832
  doFirst {
833
    mkdir "${buildDir}"
834
  }
835
}
836

    
837
task asm_jarjar(
838
  description: "Placeholder for the ASM jarjar dependencies"
839
) {
840
  // just a task to hang dependencies on
841
}
842

    
843
task asm_unzip(
844
  type: Copy,
845
  description: "Extract classes from the asm-xml-${asmVersion} jar"
846
) {
847
  // This one is from the original ASM
848
  def zipFile = file("lib/asm-${asmVersion}/asm-xml-${asmVersion}.jar")
849
  def outputDir = "${buildDir}/classes/eej"
850
  from zipTree(zipFile)
851
  into outputDir
852
}
853

    
854
["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"].each { asm ->
855
  Task t = task "asm_${asm}"(
856
    type: JavaExec,
857
    dependsOn: ["asm_createRules"],
858
    description: "Run jarjar on ${asm}-${asmVersion} classes"
859
) {
860
    inputs.file "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar"
861
    outputs.file "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
862
    classpath = configurations.preprocessor
863
    main = "com.tonicsystems.jarjar.Main"
864
    args "--rules", "${buildDir}/jarjar-asm.rules",
865
      "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar",
866
      "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
867
    doFirst {
868
      mkdir "${buildDir}/lib/asm"
869
    }
870
  }
871
  asm_jarjar.dependsOn t
872

    
873
  t = task "asm_unzip${asm}"(
874
    type: Copy,
875
    dependsOn: ["asm_jarjar"],
876
    description: "Extract the classes from the ${asm}-${asmVersion} jar"
877
  ) {
878
    def zipFile = file("${buildDir}/lib/asm/${asm}-${asmVersion}.jar")
879
    def outputDir = "${buildDir}/classes/eej"
880
    from zipTree(zipFile)
881
    into outputDir
882
  }
883
  asm_unzip.dependsOn t
884
}
885

    
886
// ============================================================
887

    
888
task hej_MetaInf(
889
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for HE"
890
) {
891
  outputs.file("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
892
  doFirst {
893
    mkdir "${buildDir}/services/saxon-he/META-INF/services"
894
  }
895
  doLast {
896
    new File("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
897
      .withWriter("utf-8") { writer ->
898
        writer.writeLine("net.sf.saxon.TransformerFactoryImpl")
899
      }
900
  }
901
}
902

    
903
task pej_MetaInf(
904
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for PE"
905
) {
906
  outputs.file("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
907
  doFirst {
908
    mkdir "${buildDir}/services/saxon-pe/META-INF/services"
909
  }
910
  doLast {
911
    new File("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
912
      .withWriter("utf-8") { writer ->
913
        writer.writeLine("com.saxonica.config.ProfessionalTransformerFactory")
914
      }
915
  }
916
}
917

    
918
task eej_schemaFactoryMetaInf(
919
  description: "Create META-INF/services/javax.xml.validation.SchemaFactory for EE"
920
) {
921
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
922
  doFirst {
923
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
924
  }
925
  doLast {
926
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
927
      .withWriter("utf-8") { writer ->
928
        writer.writeLine("com.saxonica.ee.jaxp.SchemaFactoryImpl")
929
      }
930
  }
931
}
932

    
933
task eej_MetaInf(
934
  dependsOn: ["eej_schemaFactoryMetaInf"],
935
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for EE"
936
) {
937
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
938
  doFirst {
939
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
940
  }
941
  doLast {
942
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
943
      .withWriter("utf-8") { writer ->
944
        writer.writeLine("com.saxonica.config.EnterpriseTransformerFactory")
945
      }
946
  }
947
}
948

    
949
// ============================================================
950

    
951
task hejJar(
952
  type: Jar,
953
  dependsOn: ["hej_MetaInf", "hejCompile"],
954
  description: "Build the HE jar file"
955
) {
956
  archiveBaseName = "saxon-he-${saxonVersion}"
957
  manifest {
958
    attributes "Project-Name": "Saxon-HE"
959
    attributes "Main-Class": "net.sf.saxon.Transform"
960
  }
961
  from ("${buildDir}/services/saxon-he") {
962
    include "META-INF/**"
963
  }
964
  from ("${buildDir}/classes/hej") {
965
    include "net/**/*.class"
966
    exclude "net/sf/saxon/option/**"
967
  }
968
  from ("src/main/resources") {
969
    include "net/sf/saxon/data/**"
970
  }
971
}
972

    
973
// Because the XQJ files are not open source, don't attempt to build
974
// the jar unless the EE sources are available.
975
if (file("${projectDir}/src/main/java/com/saxonica/xqj").exists()) {
976
  task hejJarXqj(
977
    type: Jar,
978
    dependsOn: ["eejCompile"],
979
    description: "Build the XQJ jar file for HE"
980
  ) {
981
    archiveBaseName = "saxon-he-xqj-${saxonVersion}"
982
    from ("${buildDir}/classes/eej") {
983
      include "com/saxonica/xqj/**/*.class"
984
      include "javax/xml/xquery/**/*.class"
985
    }
986
  }
987
} else {
988
  task hejJarXqj(
989
    description: "Ignore the XQJ file; the sources are unavailable"
990
  ) {
991
    doLast {
992
      println("Ignoring XQJ jar file task; the sources are unavailable")
993
    }
994
  }
995
}
996

    
997
task pejJar(
998
  type: Jar,
999
  dependsOn: ["pej_MetaInf", "pejCompile"],
1000
  description: "Build the PE jar file"
1001
) {
1002
  archiveBaseName = "saxon-pe-${saxonVersion}"
1003
  manifest {
1004
    attributes "Project-Name": "Saxon-PE"
1005
    attributes "Main-Class": "net.sf.saxon.Transform"
1006
  }
1007
  from ("${buildDir}/services/saxon-pe") {
1008
    include "META-INF/**"
1009
  }
1010
  from ("${buildDir}/classes/pej") {
1011
    include "net/**/*.class"
1012
    include "com/saxonica/**/*.class"
1013
    include "javax/xml/xquery/*.class"
1014
    exclude "**/sql/**/*.class"
1015
    exclude "com/saxonica/CompileStylesheet.class"
1016
    exclude "com/saxonica/CompileStylesheet\$TracingObjectOutputStream.class"
1017
    exclude "com/saxonica/Validate.class"
1018
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
1019
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
1020
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
1021
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
1022
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
1023
    exclude "com/saxonica/ee/**/*.class"
1024
    exclude "com/saxonica/expr/CastToList.class"
1025
    exclude "com/saxonica/expr/CastToUnion.class"
1026
    exclude "com/saxonica/expr/CastableToList.class"
1027
    exclude "com/saxonica/expr/CastableToUnion.class"
1028
    exclude "com/saxonica/functions/sql/**"
1029
    exclude "net/sf/saxon/option/sql/**"
1030
  }
1031
  from ("src/main/resources") {
1032
    include "net/sf/saxon/data/**"
1033
  }
1034
}
1035

    
1036
task pejJarSql(
1037
  type: Jar,
1038
  dependsOn: ["pejCompile"],
1039
  description: "Build the SQL jar file for PE"
1040
) {
1041
  archiveBaseName = "saxon-pe-sql-${saxonVersion}"
1042
  from ("${buildDir}/classes/pej") {
1043
    include "net/sf/saxon/option/sql/*.class"
1044
    include "com/saxonica/functions/sql/*.class"
1045
  }
1046
}
1047

    
1048
task eejJar(
1049
  type: Jar,
1050
  dependsOn: ["eej_MetaInf", "eejCompile", "asm_unzip"],
1051
  description: "Build the EE jar file"
1052
) {
1053
  archiveBaseName = "saxon-ee-${saxonVersion}"
1054
  manifest {
1055
    attributes "Project-Name": "Saxon-EE"
1056
    attributes "Main-Class": "net.sf.saxon.Transform"
1057
  }
1058
  from ("${buildDir}/services/saxon-ee") {
1059
    include "META-INF/**"
1060
  }
1061
  from ("${buildDir}/classes/eej") {
1062
    include "net/**/*.class"
1063
    include "com/saxonica/**/*.class"
1064
    include "javax/xml/xquery/*.class"
1065
    exclude "org/objectweb/**/*.class"
1066
    exclude "**/sql/**/*.class"
1067
    exclude "com/saxonica/StatsTransform*.class"
1068
    exclude "com/saxonica/functions/sql/**"
1069
    exclude "net/sf/saxon/option/sql/**"
1070
  }
1071
  from ("src/main/resources") {
1072
    include "net/sf/saxon/data/**"
1073
  }
1074
}
1075

    
1076
task eejJarSql(
1077
  type: Jar,
1078
  dependsOn: ["eejCompile"],
1079
  description: "Build the SQL jar file for EE"
1080
) {
1081
  archiveBaseName = "saxon-ee-sql-${saxonVersion}"
1082
  from ("${buildDir}/classes/eej") {
1083
    include "net/sf/saxon/option/sql/*.class"
1084
    include "com/saxonica/functions/sql/*.class"
1085
  }
1086
}
1087

    
1088
// ============================================================
1089

    
1090
task signJars(
1091
  dependsOn: ["hejSignJars", "pejSignJars", "eejSignJars"],
1092
  description: "Sign all the jar files."
1093
) {
1094
  // Just a container to hang dependencies on
1095
}
1096

    
1097
task hejSignJars(
1098
  description: "Sign the HEJ jar files"
1099
) {
1100
  // Just a container to hang dependencies on
1101
}
1102

    
1103
task pejSignJars(
1104
  description: "Sign the PEJ jar files"
1105
) {
1106
  // Just a container to hang dependencies on
1107
}
1108

    
1109
task eejSignJars(
1110
  description: "Sign the EEJ jar files"
1111
) {
1112
  // Just a container to hang dependencies on
1113
}
1114

    
1115
// Create tasks for signing jars...
1116
["he", "pe", "ee"].each { rel ->
1117
  if (canSignJars) {
1118
    Task t = task "${rel}_jJarSignJar"(
1119
      type: Exec,
1120
      dependsOn: ["${rel}jJar"],
1121
      description: "Sign the ${rel.toUpperCase()}J jar file"
1122
    ) {
1123
      inputs.file "${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar"
1124
      def args = signjarArgs +
1125
        ["${buildDir}/libs/saxon-${rel}-${saxonVersion}.jar",
1126
         signkeyNewAlias,
1127
         "-storepass", signkeyPassword]
1128
      commandLine args
1129
    }
1130
    tasks.findByName("${rel}jSignJars").dependsOn t
1131

    
1132
    t = task "${rel}j_JarSignTests"(
1133
      type: Exec,
1134
      dependsOn: ["${rel}jJarTests"],
1135
      description: "Sign the ${rel.toUpperCase()}J test jar file"
1136
    ) {
1137
      inputs.file "${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar"
1138
      def args = signjarArgs +
1139
        ["${buildDir}/libs/saxon-${rel}-test-${saxonVersion}.jar",
1140
         signkeyNewAlias,
1141
         "-storepass", signkeyPassword]
1142
      commandLine args
1143
    }
1144
    tasks.findByName("${rel}jSignJars").dependsOn t
1145

    
1146
    t = task "${rel}j_JarSignXqj"(
1147
      type: Exec,
1148
      dependsOn: ["${rel}jJarXqj"],
1149
      description: "Sign the ${rel.toUpperCase()}J XQJ jar file"
1150
    ) {
1151
      inputs.file "${buildDir}/libs/saxon-${rel}-xqj-${saxonVersion}.jar"
1152
      def args = signjarArgs +
1153
        ["${buildDir}/libs/saxon-${rel}-xqj-${saxonVersion}.jar",
1154
         signkeyNewAlias,
1155
         "-storepass", signkeyPassword]
1156
      commandLine args
1157
    }
1158
    tasks.findByName("${rel}jSignJars").dependsOn t
1159

    
1160
    if (rel != 'he') {
1161
      t = task "${rel}j_JarSignSql"(
1162
        type: Exec,
1163
        dependsOn: ["${rel}jJarSql"],
1164
        description: "Sign the ${rel.toUpperCase()} jar file"
1165
      ) {
1166
        inputs.file "${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar"
1167
        def args = signjarArgs +
1168
          ["${buildDir}/libs/saxon-${rel}-sql-${saxonVersion}.jar",
1169
           signkeyNewAlias,
1170
           "-storepass", signkeyPassword]
1171
        commandLine args
1172
      }
1173
      tasks.findByName("${rel}jSignJars").dependsOn t
1174
    }
1175
  } else {
1176
    Task t = task "${rel}j_JarSignJar"(
1177
      description: "Cannot sign the ${rel.toUpperCase()}J jar file"
1178
    ) {
1179
      doLast {
1180
        throw new GradleException("Jar signing is not configured.")
1181
      }
1182
    }
1183
    tasks.findByName("${rel}jSignJars").dependsOn t
1184

    
1185
    t = task "${rel}j_JarSignTests"(
1186
      description: "Cannot sign the ${rel.toUpperCase()}J test jar file"
1187
    ) {
1188
      doLast {
1189
        throw new GradleException("Jar signing is not configured.")
1190
      }
1191
    }
1192
    tasks.findByName("${rel}jSignJars").dependsOn t
1193

    
1194
    t = task "${rel}j_JarSignXqj"(
1195
      description: "Cannot sign the ${rel.toUpperCase()}J XQJ jar file"
1196
    ) {
1197
      doLast {
1198
        throw new GradleException("Jar signing is not configured.")
1199
      }
1200
    }
1201
    tasks.findByName("${rel}jSignJars").dependsOn t
1202

    
1203
    if (rel != 'he') {
1204
      t = task "${rel}j_JarSignSql"(
1205
        description: "Cannot sign the ${rel.toUpperCase()} jar file"
1206
      ) {
1207
        doLast {
1208
          throw new GradleException("Jar signing is not configured.")
1209
        }
1210
      }
1211
      tasks.findByName("${rel}jSignJars").dependsOn t
1212
    }
1213
  }    
1214
}
1215

    
1216
// ============================================================
1217

    
1218
task hejRelease(
1219
  type: Copy,
1220
  dependsOn: ["hejJar", "hejJarXqj", "hejJarTests", "hej_notices"],
1221
  description: "Build the HE release for Java"
1222
) {
1223
  from "${buildDir}/libs"
1224
  into "${buildDir}/releases/hej"
1225
  include "saxon-he-${saxonVersion}.jar"
1226
  include "saxon-he-xqj-${saxonVersion}.jar"
1227
  include "saxon-he-test-${saxonVersion}.jar"
1228
  rename { filename ->
1229
    if (filename.startsWith("saxon-he-test")) {
1230
      filename = "saxon-he-test-${saxonVersion}.jar"
1231
    }
1232
  }
1233
}
1234

    
1235
task pejRelease(
1236
  type: Copy,
1237
  dependsOn: ["pejJar", "pejJarSql", "pejJarTests", "pej_libs", "pej_notices"],
1238
  description: "Build the PE release for Java"
1239
) {
1240
  from "${buildDir}/libs"
1241
  into "${buildDir}/releases/pej"
1242
  include "saxon-pe-${saxonVersion}.jar"
1243
  include "saxon-pe-sql-${saxonVersion}.jar"
1244
  include "saxon-pe-test-${saxonVersion}.jar"
1245
  rename { filename ->
1246
    if (filename.startsWith("saxon-pe-sql")) {
1247
      filename.replace("saxon-pe-sql", "saxon-sql")
1248
    } else {
1249
      filename
1250
    }
1251
  }
1252
}
1253

    
1254
task eejRelease(
1255
  type: Copy,
1256
  dependsOn: ["eejJar", "eejJarSql", "eejJarTests", "eej_libs", "eej_notices"],
1257
  description: "Build the EE release for Java"
1258
) {
1259
  from "${buildDir}/libs"
1260
  into "${buildDir}/releases/eej"
1261
  include "saxon-ee-${saxonVersion}.jar"
1262
  include "saxon-ee-sql-${saxonVersion}.jar"
1263
  include "saxon-ee-test-${saxonVersion}.jar"
1264
  rename { filename ->
1265
    if (filename.startsWith("saxon-ee-sql")) {
1266
      filename.replace("saxon-ee-sql", "saxon-sql")
1267
    } else {
1268
      filename
1269
    }
1270
  }
1271
}
1272

    
1273
if (file("${projectDir}/src/main/java/com").exists()) {
1274
  task javaReleases(
1275
    dependsOn: ["hejRelease", "pejRelease", "eejRelease"],
1276
    description: "Build all of the Java releases"
1277
  ) {
1278
    // Just a container to hang dependencies on
1279
  }
1280
} else {
1281
  // Ignore the EEJ and PEJ releases if the sources aren't available
1282
  task javaReleases(
1283
    dependsOn: ["hejRelease"],
1284
    description: "Build all of the Java releases"
1285
  ) {
1286
    // Just a container to hang dependencies on
1287
  }
1288
}
1289

    
1290
// ============================================================
1291

    
1292
// Testing task for various Gradle debugging efforts
1293
task helloWorld() {
1294
  doLast {
1295
    println("Hello, world.")
1296
    /*
1297
    configurations.documentation.resolve().each { path ->
1298
      println(path)
1299
    }
1300
     */
1301
  }
1302
}
(8-8/14)