Project

Profile

Help

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

he / build.gradle @ 0431096a

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
    files(saxonLicenseDir)
118
  )
119
  jeldoclet (
120
    files("lib/jeldoc.jar"),
121
    // I don't really understand why this has to be done explicitly...
122
    files("${System.getProperty('java.home')}/../lib/tools.jar")
123
  )
124
  samples (
125
    [group: 'javax.servlet', name: 'servlet-api', version: '2.5']
126
  )
127
}
128

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
301
  return false
302
}
303

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

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

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

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

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

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

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

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

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

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

    
395
// ============================================================
396

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

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

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

    
446
// ============================================================
447

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

    
463
// Make sure we create feature keys before compiling Java
464
compileJava.dependsOn hej_featureKeys
465

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

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

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

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

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

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

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

    
596
// ============================================================
597

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

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

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

    
653
// ============================================================
654

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

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

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

    
693
// ============================================================
694

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

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

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

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

    
742
// ============================================================
743

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

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

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

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

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

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

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

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

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

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

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

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

    
884
// ============================================================
885

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

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

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

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

    
947
// ============================================================
948

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

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

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

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

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

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

    
1086
// ============================================================
1087

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

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

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

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

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

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

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

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

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

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

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

    
1214
// ============================================================
1215

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

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

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

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

    
1288
// ============================================================
1289

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