Project

Profile

Help

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

he / build.gradle @ 4ae20fb4

1
buildscript {
2
  repositories {
3
    mavenLocal()
4
    mavenCentral()
5
  }
6
}
7

    
8
plugins {
9
  id "java"
10
  id "maven-publish"
11
  id "signing"
12
//  id "com.cdsap.talaiot" version "1.3.5"
13
}
14

    
15
import org.gradle.internal.os.OperatingSystem;
16

    
17
apply plugin: 'java'
18

    
19
repositories {
20
  mavenLocal()
21
  mavenCentral()
22
  maven { url = "https://org.apache.maven" }
23
  maven { url "https://dev.saxonica.com/maven" }
24
}
25

    
26
configurations.all {
27
  resolutionStrategy {
28
    force 'xml-apis:xml-apis:1.4.01'
29
  }
30
}
31

    
32
configurations {
33
  preprocessor.extendsFrom(runtimeOnly)
34
  jarjarAsm.extendsFrom(implementation)
35
  testDrivers.extendsFrom(testImplementation)
36
  ikvm.extendsFrom(implementation)
37
  compileDotNet.extendsFrom(implementation)
38
  asmDotNet.extendsFrom(implementation)
39
}
40

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

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

    
103
sourceSets {
104
  main {
105
    java {
106
      exclude "**/*.java"
107
    }
108
  }
109
}
110

    
111
test {
112
  useJUnitPlatform()
113
}
114

    
115
/*
116
talaiot {
117
  metrics {
118
    performanceMetrics = false
119
  }
120
  publishers {
121
    taskDependencyGraphPublisher {
122
      gexf = false
123
      dot = true
124
      html = false
125
    }
126
  }
127
}
128
*/
129

    
130
ext {
131
  systemOs = OperatingSystem.current()
132
  icu4jJar = null
133
  tagsoupJar = null
134
  mailJar = null
135
  resolverJar = null
136
}
137

    
138
def version_h = saxonVersion.replace(".", "-")
139

    
140
// ============================================================
141
// Find jar files that need to be part of the build or release
142
//
143
def filesep = System.getProperty("file.separator")
144
icu4jJar = "${filesep}icu4j-${icu4jVersion}.jar"
145
tagsoupJar = "${filesep}tagsoup-${tagsoupVersion}.jar"
146
mailJar = "${filesep}javax.mail-${mailVersion}.jar"
147
resolverJar = "${filesep}xml-resolver-1.2.jar"
148
configurations.compileClasspath.each { cp ->
149
  if (cp.toString().endsWith(icu4jJar)) {
150
    icu4jJar = cp.toString()
151
  }
152
  if (cp.toString().endsWith(tagsoupJar)) {
153
    tagsoupJar = cp.toString()
154
  }
155
  if (cp.toString().endsWith(mailJar)) {
156
    mailJar = cp.toString()
157
  }
158
  if (cp.toString().endsWith(resolverJar)) {
159
    resolverJar = cp.toString()
160
  }
161
}
162

    
163
apply from: "build-n.gradle"
164
apply from: "build-c.gradle"
165
apply from: "build-doc.gradle"
166

    
167
def pathExists(pathname) {
168
  // Returns true iff pathame is an existing file or directory
169
  try {
170
    // This may throw an error for a Windows pathname, c:/path/to/thing
171
    if (file(pathname).exists()) {
172
      return true;
173
    }
174
  } catch (GradleException e) {
175
    // I don't care
176
  }
177

    
178
  if (OperatingSystem.current().isWindows()) {
179
    try {
180
      // If we're on Windows, try to make c:/path/to/thing work
181
      if (file("file:///${pathname}").exists()) {
182
        return true;
183
      }
184
    } catch (GradleException e) {
185
      // I don't care
186
    }
187
  }
188

    
189
  return false
190
}
191

    
192
// ============================================================
193
// One of the features of Gradle is that you can construct tasks
194
// dynamically during the "configure" phase. This is a feature because
195
// it avoids a lot of tedious repetition of nearly identical tasks. It
196
// has the unfortunate consequence that understanding the tasks
197
// involved becomes harder. I've tried to use this feature sparingly.
198

    
199
["h", "p", "e"].each { initial ->
200
  def release = initial + "e"
201
  def Release = initial.toUpperCase() + "e"
202
  def RELEASE = release.toUpperCase()
203

    
204
  if (release != "he") {
205
    Task libs = task "${release}j_libs"(
206
      description: "Dependency to make sure library files are copie for ${RELEASE}"
207
    ) {
208
      // Just a container to hang dependencies on
209
    }
210

    
211
    Task icu4j = task "${release}j_icu4j"(
212
      type: Copy,
213
      description: "Copy the ICU4J jar into the ${RELEASE} release directory"
214
    ) {
215
      from "${icu4jJar}"
216
      into "${buildDir}/releases/${release}j"
217
    }
218
    libs.dependsOn icu4j
219
  }
220

    
221
  task "${release}j_notices"(
222
    type: Copy,
223
    description: "Copy the notices into the ${RELEASE} release directory"
224
  ) {
225
    into "${buildDir}/releases/${release}j"
226
    from ("src/docs") {
227
      exclude "saxon9"
228
      exclude "tools"
229
      exclude "saxonc-doc"
230
      exclude "welcome"
231
      exclude "notices/APACHE-ANT.txt"
232
      exclude "notices/APACHE-RESOLVER.txt"
233
      exclude "notices/APACHE-TAGSOUP.txt"
234
      exclude "notices/APACHE-XERCES.txt"
235
      exclude "notices/ASM.txt"
236
      exclude "notices/FRIJTERS.txt"
237
      exclude "notices/GPL+CLASSPATH.txt"
238
      exclude "notices/ICU-J.txt"
239
      exclude "notices/LEGAL.txt"
240
    }
241
  }
242

    
243
  task "${release}j_copyTestDrivers"(
244
    dependsOn: ["${release}j_copyTestDriverSources",
245
                "${release}j_copyTestDriverResources"],
246
    description: "Copy test driver sources and resources for ${RELEASE}"
247
  ) {
248
    // Just a container to hang dependencies on
249
  }
250
}
251

    
252
// ============================================================
253

    
254
task "hej_compileTestDrivers"(
255
  type: JavaCompile,
256
  dependsOn: ["hej_copyTestDrivers", "hejCompile"],
257
  description: "Compile the test classes for HE"
258
) {
259
  classpath = configurations.testDrivers + files("${buildDir}/classes/hej")
260
  source = "${buildDir}/src/testdrivers/hej"
261
  destinationDirectory = new File("${buildDir}/classes/hej/testdrivers")
262
}
263

    
264
task "pej_compileTestDrivers"(
265
  type: JavaCompile,
266
  dependsOn: ["pej_copyTestDrivers", "pejCompile", "eejCompile"],
267
  description: "Compile the test classes for PE"
268
) {
269
  classpath = configurations.testDrivers \
270
              + files("${buildDir}/classes/pej") \
271
              + files("${buildDir}/classes/eej")
272
  source = "${buildDir}/src/testdrivers/pej"
273
  destinationDirectory = new File("${buildDir}/classes/pej/testdrivers")
274
}
275

    
276
task "eej_compileTestDrivers"(
277
  type: JavaCompile,
278
  dependsOn: ["eej_copyTestDrivers", "eejCompile", "eejCompile"],
279
  description: "Compile the test classes for EE"
280
) {
281
  classpath = configurations.testDrivers \
282
              + files("${buildDir}/classes/eej")
283
  source = "${buildDir}/src/testdrivers/eej"
284
  destinationDirectory = new File("${buildDir}/classes/eej/testdrivers")
285
}
286

    
287
task hejJarTests(
288
  type: Jar,
289
  dependsOn: ["hejCompile", "hej_compileTestDrivers"],
290
  description: "Create the tests jar file for HE"
291
) {
292
  archiveBaseName = "saxon-he-test-${saxonVersion}"
293
  manifest {
294
    attributes "Project-Name": "Saxon-HE-TestDriver"
295
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
296
  }
297
  from ("${buildDir}/classes/hej/testdrivers") {
298
    include "net/sf/saxon/testdriver/**"
299
  }
300
}
301

    
302
task pejJarTests(
303
  type: Jar,
304
  dependsOn: ["pejCompile", "pej_compileTestDrivers"],
305
  description: "Create the tests jar file for PE"
306
) {
307
  archiveBaseName = "saxon-pe-test-${saxonVersion}"
308
  manifest {
309
    attributes "Project-Name": "Saxon-PE-TestDriver"
310
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
311
  }
312
  from ("${buildDir}/classes/pej/testdrivers") {
313
    include "net/sf/saxon/testdriver/**"
314
    include "com/saxonica/testdriver/**"
315
    exclude "com/saxonica/testdriver/ee/**"
316
  }
317
}
318

    
319
task eejJarTests(
320
  type: Jar,
321
  dependsOn: ["eejCompile", "eej_compileTestDrivers"],
322
  description: "Create the tests jar file for EE"
323
) {
324
  archiveBaseName = "saxon-ee-test-${saxonVersion}"
325
  manifest {
326
    attributes "Project-Name": "Saxon-EE-TestDriver"
327
    attributes "Main-Class": "com.saxonica.testdriver.gui.TestDriverGui"
328
  }
329
  from ("${buildDir}/classes/eej/testdrivers") {
330
    include "net/sf/saxon/testdriver/**"
331
    include "com/saxonica/testdriver/**"
332
  }
333
}
334

    
335
// ============================================================
336

    
337
task hej_sampleConfig(
338
  type: JavaExec,
339
  description: "Construct the configuration file XSD"
340
) {
341
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
342
  inputs.files "${projectDir}/src/samples/config/config-raw.xsd"
343
  outputs.file "${projectDir}/src/samples/config/config.xsd"
344
  classpath = configurations.preprocessor
345
  main = "net.sf.saxon.Transform"
346
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
347
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToSchema.xsl",
348
    "-o:${projectDir}/src/samples/config/config.xsd",
349
    "FeatureKeys=FeatureKeys.xml",
350
    "AdditionalFeatures=AdditionalFeatures.xml",
351
    "ConfigSchema=${projectDir}/src/samples/config/config-raw.xsd"
352
}
353

    
354
// There's no real dependency here, but I'm not sure how the
355
// samples directory should be integrated into the build.
356
task hej_featureKeys(
357
  type: JavaExec,
358
  dependsOn: ["hej_sampleConfig"],
359
  description: "Construct the feature keys for HE"
360
) {
361
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
362
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/Feature.java"
363
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureCode.java"
364
  outputs.file "${projectDir}/src/main/java/net/sf/saxon/lib/FeatureKeys.java"
365
  classpath = configurations.preprocessor
366
  main = "net.sf.saxon.Transform"
367
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
368
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToJava.xsl",
369
    "-o:${projectDir}/src/main/java/net/sf/saxon/lib/establish-an-output-base-uri"
370
}
371

    
372
task hej_setupPreprocess(
373
  type: Copy,
374
  dependsOn: ["hej_featureKeys"],
375
  description: "Copy HE sources for preprocessing HE"
376
) {
377
  from "${projectDir}/src/main/java"
378
  into "${buildDir}/filtered/hej"
379
  include "net/sf/saxon/**/*.java"
380
  include "net/sf/saxon/**/package.html"
381
  include "net/sf/saxon/data/**"
382
  exclude "javax/xml/xquery/*.java"
383
  exclude "**/dotnet/**"
384
  exclude "net/sf/saxon/testdriver/**"
385
  exclude "net/sf/saxon/option/sql/**"
386
  exclude "net/sf/saxon/option/cpp/**"
387
  exclude "net/sf/saxon/jetonnet/**"
388
}
389

    
390
task hej_setupPreprocessForPej(
391
  type: Copy,
392
  dependsOn: ["hej_featureKeys"],
393
  description: "Copy HE sources for preprocessing PE"
394
) {
395
  from "${projectDir}/src/main/java"
396
  into "${buildDir}/filtered/pej"
397
  include "net/sf/saxon/**/*.java"
398
  include "javax/xml/xquery/*.java"
399
  exclude "**/dotnet/**"
400
  include "net/sf/saxon/**/package.html"
401
  exclude "net/sf/saxon/testdriver/**"
402
  exclude "net/sf/saxon/option/cpp/**"
403
  exclude "net/sf/saxon/jetonnet/**"
404
  include "net/sf/saxon/data/**"
405
}
406

    
407
task eej_setupPreprocessForPej(
408
  type: Copy,
409
  description: "Copy EE sources for preprocessing PE"
410
) {
411
  from "${projectDir}/src/main/java"
412
  into "${buildDir}/filtered/pej"
413
  include "com/saxonica/**/*.java"
414
  exclude "com/saxonica/functions/extfn/cpp/*.java"
415
  exclude "com/saxonica/testdriver/**"
416
  exclude "com/saxonica/testdriver/ee/**/*.java"
417
  exclude "com/saxonica/testdriver/old/**/*.java"
418
  exclude "com/saxonica/ee/**"
419
  exclude "com/saxonica/config/EnterpriseConfiguration.java"
420
  exclude "com/saxonica/expr/CastToUnion.java"
421
  exclude "com/saxonica/expr/CastableToUnion.java"
422
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
423
  exclude "com/saxonica/config/ee/**"
424
  exclude "com/saxonica/js/**"
425
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
426
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
427
  exclude "com/saxonica/config/DotNetPlatformPE.java"
428
  exclude "com/saxonica/config/JavaPlatformEE.java"
429
  exclude "com/saxonica/config/NativePlatformPE.java"
430
  exclude "com/saxonica/Validate.java"
431
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
432
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
433
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
434
  exclude "com/saxonica/config/DynamicLoaderEE.java"
435
  exclude "com/saxonica/config/StandardSchemaResolver.java"
436
  exclude "com/saxonica/jaxp/SchemaFactoryImpl11.java"
437
  exclude "com/saxonica/functions/extfn/NativeCall.java"
438
}
439

    
440
task pej_setupPreprocess(
441
  dependsOn: ["hej_setupPreprocessForPej", "eej_setupPreprocessForPej"],
442
  description: "Copy sources for preprocessing PE"
443
) {
444
  // Just a container to hang dependencies on
445
}
446

    
447
task hej_setupPreprocessForEej(
448
  type: Copy,
449
  dependsOn: ["hej_featureKeys"],
450
  description: "Copy HE sources for EE build"
451
) {
452
  from "${projectDir}/src/main/java"
453
  into "${buildDir}/filtered/eej"
454
  include "net/sf/saxon/**/*.java"
455
  include "javax/xml/xquery/*.java"
456
  exclude "**/dotnet/**"
457
  include "net/sf/saxon/**/package.html"
458
  exclude "net/sf/saxon/testdriver/**"
459
  exclude "net/sf/saxon/option/cpp/**"
460
  exclude "net/sf/saxon/jetonnet/**"
461
  exclude "net/sf/saxon/jetonnet/**"
462
  include "net/sf/saxon/data/**"
463
}
464

    
465
// Rename org.objectweb to com.saxonica.objectweb in the bytecode sources
466
task eej_setupPreprocessBytecode(
467
  type: Copy,
468
  description: "Copy bytecode sources and fix imports"
469
) {
470
  from "${projectDir}/src/main/java"
471
  into "${buildDir}/filtered/eej"
472
  include "com/saxonica/ee/bytecode/**/*.java"
473
  filter { line ->
474
    line.contains("org.objectweb")
475
      ? line.replaceAll("org.objectweb", "com.saxonica.objectweb")
476
      : line
477
  }
478
}
479

    
480
// N.B. bytecode is explicitly excluded, see eej_setupPreprocessBytecode
481
task eej_setupPreprocess(
482
  type: Copy,
483
  dependsOn: ["hej_setupPreprocessForEej", "eej_setupPreprocessBytecode"],
484
  description: "Copy sources for preprocessing EE"
485
) {
486
  from "${projectDir}/src/main/java"
487
  into "${buildDir}/filtered/eej"
488
  include "com/saxonica/**/*.java"
489
  exclude "com/saxonica/ee/bytecode/**/*.java"
490
  exclude "com/saxonica/functions/extfn/cpp/*.java"
491
  exclude "com/saxonica/testdriver/**/*.java"
492
  exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
493
  exclude "com/saxonica/config/DotNetExtensionLibrary.java"
494
  exclude "com/saxonica/config/DotNetPlatformPE.java"
495
  exclude "com/saxonica/config/NativePlatformPE.java"
496
  exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
497
  exclude "com/saxonica/functions/extfn/NativeCall.java"
498
  include "com/saxonica/**/package.html"
499
  exclude "com/saxonica/js/**"
500
}
501

    
502
// ============================================================
503

    
504
task hej_preprocess(
505
  type: JavaExec,
506
  dependsOn: ["hej_setupPreprocess"],
507
  description: "Preprocess HE sources"
508
) {
509
  inputs.files fileTree(dir: "${buildDir}/filtered/hej")
510
  outputs.files fileTree(dir: "${buildDir}/preprocess/hej")
511
  classpath = configurations.preprocessor
512
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
513
  args "/c",
514
    "/i:${buildDir}/filtered/hej", "/o:${buildDir}/preprocess/hej",
515
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=false",
516
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
517
  doFirst {
518
    mkdir "${buildDir}/preprocess/hej"
519
  }
520
}
521

    
522
task pej_preprocess(
523
  type: JavaExec,
524
  dependsOn: ["pej_setupPreprocess"],
525
  description: "Preprocess HE sources"
526
) {
527
  inputs.files fileTree(dir: "${buildDir}/filtered/pej")
528
  outputs.files fileTree(dir: "${buildDir}/preprocess/pej")
529
  classpath = configurations.preprocessor
530
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
531
  args "/c",
532
    "/i:${buildDir}/filtered/pej", "/o:${buildDir}/preprocess/pej",
533
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=false", "/p:HOF=true",
534
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=false"
535
  doFirst {
536
    mkdir "${buildDir}/preprocess/pej"
537
  }
538
}
539

    
540
task eej_preprocess(
541
  type: JavaExec,
542
  dependsOn: ["eej_setupPreprocess", "asm_jarjar"],
543
  description: "Preprocess EE sources"
544
) {
545
  inputs.files fileTree(dir: "${buildDir}/filtered/eej")
546
  outputs.files fileTree(dir: "${buildDir}/preprocess/eej")
547
  classpath = configurations.preprocessor
548
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
549
  args "/c",
550
    "/i:${buildDir}/filtered/eej", "/o:${buildDir}/preprocess/eej",
551
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=false", "/p:HOF=true",
552
    "/p:OPT=false", "/p:SAXONC=false", "/p:BYTECODE=true",
553
    "/p:STREAM=true", "/p:PACKAGES=true", "/p:SCHEMA=true"
554
  doFirst {
555
    mkdir "${buildDir}/preprocess/eej"
556
  }
557
}
558

    
559
// ============================================================
560

    
561
task hej_sources(
562
  type: Copy,
563
  dependsOn: ["hej_preprocess"],
564
  description: "Collect the preprocessed HE sources for compilation"
565
) {
566
  from "${buildDir}/preprocess/hej"
567
  into "${buildDir}/src/hej"
568
  filter { line ->
569
    line.contains("import com.saxonica") ? null : line.replaceFirst("\\s++\$", "")
570
  }
571
}
572

    
573
task pej_sources(
574
  type: Copy,
575
  dependsOn: ["pej_preprocess"],
576
  description: "Collect the preprocessed PE sources for compilation"
577
) {
578
  from "${buildDir}/preprocess/pej"
579
  into "${buildDir}/src/pej"
580
  filter { line ->
581
    if (line.contains("import com.saxonica.ee")
582
        || line.contains("import com.saxonica.config.ee")) {
583
      null
584
    } else {
585
      line.replaceFirst("\\s++\$", "")
586
    }
587
  }
588
}
589

    
590
task eej_sources(
591
  type: Copy,
592
  dependsOn: ["eej_preprocess"],
593
  description: "Collect the preprocessed EE sources for compilation"
594
) {
595
  from "${buildDir}/preprocess/eej"
596
  into "${buildDir}/src/eej"
597
}
598

    
599
// ============================================================
600

    
601
task hejCompile(
602
  type: JavaCompile,
603
  dependsOn: ["hej_sources"],
604
  description: "Compile HE for Saxon/Java"
605
) {
606
  classpath = configurations.compileClasspath
607
  source "${buildDir}/src/hej"
608
  destinationDirectory = new File("${buildDir}/classes/hej")
609
}
610
compileJava.dependsOn hejCompile
611

    
612
task pejCompile(
613
  type: JavaCompile,
614
  dependsOn: ["pej_sources"],
615
  description: "Compile PE for Saxon/Java"
616
) {
617
  classpath = configurations.compileClasspath
618
  source "${buildDir}/src/pej"
619
  destinationDirectory = new File("${buildDir}/classes/pej")
620
}
621
compileJava.dependsOn pejCompile
622

    
623
task eejCompile(
624
  type: JavaCompile,
625
  dependsOn: ["eej_sources"],
626
  description: "Compile EE for Saxon/Java"
627
) {
628
  classpath = configurations.compileClasspath + configurations.jarjarAsm
629
  source "${buildDir}/src/eej"
630
  destinationDirectory = new File("${buildDir}/classes/eej")
631
}
632
compileJava.dependsOn eejCompile
633

    
634
// ============================================================
635

    
636
task hej_copyTestDriverSources(
637
  type: Copy,
638
  description: "Copy test drivers sources for HE"
639
) {
640
  from "src/main/java"
641
  into "${buildDir}/src/testdrivers/hej"
642
  include "net/sf/saxon/testdriver/*.java"
643
}
644

    
645
task pej_copyTestDriverSources(
646
  type: Copy,
647
  description: "Copy test drivers sources for PE"
648
) {
649
  from "src/main/java"
650
  into "${buildDir}/src/testdrivers/pej"
651
  include "net/sf/saxon/testdriver/*.java"
652
  include "com/saxonica/testdriver/ee/*.java"
653
  include "com/saxonica/testdriver/gui/**"
654
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
655
  include "com/saxonica/testdriver/XMarkBenchmark.java"
656
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverEE.java"
657
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
658
  include "com/saxonica/testdriver/ee/SchemaTestSuiteDriver.java"
659
  include "com/saxonica/testdriver/Licensor.java"
660
}
661

    
662
task eej_copyTestDriverSources(
663
  type: Copy,
664
  description: "Copy test drivers sources for EE"
665
) {
666
  from "src/main/java"
667
  into "${buildDir}/src/testdrivers/eej"
668
  include "com/saxonica/testdriver/ee/*.java"
669
  include "com/saxonica/testdriver/gui/**"
670
  include "com/saxonica/testdriver/QT3TestDriverPE.java"
671
  include "com/saxonica/testdriver/XMarkBenchmark.java"
672
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverEE.java"
673
  include "com/saxonica/testdriver/Xslt30TestSuiteDriverPE.java"
674
  include "com/saxonica/testdriver/ee/SchemaTestSuiteDriver.java"
675
  include "com/saxonica/testdriver/Licensor.java"
676
  include "net/sf/saxon/testdriver/*.java"
677
}
678

    
679
task hej_copyTestDriverResources(
680
  type: Copy,
681
  description: "Copy test drivers resources for HE"
682
) {
683
  from "src/main/java"
684
  into "${buildDir}/classes/hej/testdrivers"
685
  include "net/sf/saxon/testdriver/**"
686
  exclude "net/sf/saxon/testdriver/**/*.java"
687
}
688

    
689
task pej_copyTestDriverResources(
690
  type: Copy,
691
  description: "Copy test drivers resources for PE"
692
) {
693
  from "src/main/java"
694
  into "${buildDir}/classes/pej/testdrivers"
695
  include "net/sf/saxon/testdriver/**"
696
  include "com/saxonica/testdriver/**"
697
  exclude "net/sf/saxon/testdriver/**/*.java"
698
  exclude "com/saxonica/testdriver/**/*.java"
699
  exclude "com/saxonica/testdriver/old/**"
700
  exclude "com/saxonica/testdriver/gui/cache.xml"
701
}
702

    
703
task eej_copyTestDriverResources(
704
  type: Copy,
705
  description: "Copy test drivers resources for EE"
706
) {
707
  from "src/main/java"
708
  into "${buildDir}/classes/eej/testdrivers"
709
  include "net/sf/saxon/testdriver/**"
710
  include "com/saxonica/testdriver/**"
711
  exclude "net/sf/saxon/testdriver/**/*.java"
712
  exclude "com/saxonica/testdriver/**/*.java"
713
  exclude "com/saxonica/testdriver/old/**"
714
  exclude "com/saxonica/testdriver/gui/cache.xml"
715
}
716

    
717
// ============================================================
718
// These tasks all relate to renaming (re-jarring) the ASM jar files
719
// for EE so that the class names begin com.saxonica. This avoids a
720
// problem where a different version of the ASM libraries is used in
721
// the application that is using Saxon.
722

    
723
task asm_createRules(
724
  description: "Create the jarjar rules file for the ASM libraries"
725
) {
726
  outputs.file("${buildDir}/jarjar-asm.rules")
727
  doLast {
728
    new File("${buildDir}/jarjar-asm.rules")
729
      .withWriter("utf-8") { writer ->
730
        writer.writeLine("rule org.objectweb.** com.saxonica.objectweb.@1")
731
      }
732
  }
733
  doFirst {
734
    mkdir "${buildDir}"
735
  }
736
}
737

    
738
task asm_jarjar(
739
  description: "Placeholder for the ASM jarjar dependencies"
740
) {
741
  // just a task to hang dependencies on
742
}
743

    
744
task asm_unzip(
745
  type: Copy,
746
  description: "Extract classes from the asm-xml-${asmVersion} jar"
747
) {
748
  // This one is from the original ASM
749
  def zipFile = file("lib/asm-${asmVersion}/asm-xml-${asmVersion}.jar")
750
  def outputDir = "${buildDir}/classes/eej"
751
  from zipTree(zipFile)
752
  into outputDir
753
}
754

    
755
["asm", "asm-analysis", "asm-commons", "asm-tree", "asm-util"].each { asm ->
756
  Task t = task "asm_${asm}"(
757
    type: JavaExec,
758
    dependsOn: ["asm_createRules"],
759
    description: "Run jarjar on ${asm}-${asmVersion} classes"
760
) {
761
    inputs.file "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar"
762
    outputs.file "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
763
    classpath = configurations.preprocessor
764
    main = "com.tonicsystems.jarjar.Main"
765
    args "--rules", "${buildDir}/jarjar-asm.rules",
766
      "lib/asm-${asmVersion}/${asm}-${asmVersion}.jar",
767
      "${buildDir}/lib/asm/${asm}-${asmVersion}.jar"
768
    doFirst {
769
      mkdir "${buildDir}/lib/asm"
770
    }
771
  }
772
  asm_jarjar.dependsOn t
773

    
774
  t = task "asm_unzip${asm}"(
775
    type: Copy,
776
    dependsOn: ["asm_jarjar"],
777
    description: "Extract the classes from the ${asm}-{$asmVersion} jar"
778
  ) {
779
    def zipFile = file("${buildDir}/lib/asm/${asm}-${asmVersion}.jar")
780
    def outputDir = "${buildDir}/classes/eej"
781
    from zipTree(zipFile)
782
    into outputDir
783
  }
784
  asm_unzip.dependsOn t
785
}
786

    
787
// ============================================================
788

    
789
task hej_MetaInf(
790
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for HE"
791
) {
792
  outputs.file("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
793
  doFirst {
794
    mkdir "${buildDir}/services/saxon-he/META-INF/services"
795
  }
796
  doLast {
797
    new File("${buildDir}/services/saxon-he/META-INF/services/javax.xml.transform.TransformerFactory")
798
      .withWriter("utf-8") { writer ->
799
        writer.writeLine("net.sf.saxon.TransformerFactoryImpl")
800
      }
801
  }
802
}
803

    
804
task pej_MetaInf(
805
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for PE"
806
) {
807
  outputs.file("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
808
  doFirst {
809
    mkdir "${buildDir}/services/saxon-pe/META-INF/services"
810
  }
811
  doLast {
812
    new File("${buildDir}/services/saxon-pe/META-INF/services/javax.xml.transform.TransformerFactory")
813
      .withWriter("utf-8") { writer ->
814
        writer.writeLine("com.saxonica.config.ProfessionalTransformerFactory")
815
      }
816
  }
817
}
818

    
819
task eej_schemaFactoryMetaInf(
820
  description: "Create META-INF/services/javax.xml.validation.SchemaFactory for EE"
821
) {
822
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
823
  doFirst {
824
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
825
  }
826
  doLast {
827
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.validation.SchemaFactory")
828
      .withWriter("utf-8") { writer ->
829
        writer.writeLine("com.saxonica.ee.jaxp.SchemaFactoryImpl")
830
      }
831
  }
832
}
833

    
834
task eej_MetaInf(
835
  dependsOn: ["eej_schemaFactoryMetaInf"],
836
  description: "Create META-INF/services/javax.xml.transform.TransformerFactory for EE"
837
) {
838
  outputs.file("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
839
  doFirst {
840
    mkdir "${buildDir}/services/saxon-ee/META-INF/services"
841
  }
842
  doLast {
843
    new File("${buildDir}/services/saxon-ee/META-INF/services/javax.xml.transform.TransformerFactory")
844
      .withWriter("utf-8") { writer ->
845
        writer.writeLine("com.saxonica.config.EnterpriseTransformerFactory")
846
      }
847
  }
848
}
849

    
850
// ============================================================
851

    
852
task hejJar(
853
  type: Jar,
854
  dependsOn: ["hej_MetaInf", "hejCompile"],
855
  description: "Build the HE jar file"
856
) {
857
  archiveBaseName = "saxon-he-${saxonVersion}"
858
  manifest {
859
    attributes "Project-Name": "Saxon-HE"
860
    attributes "Main-Class": "net.sf.saxon.Transform"
861
  }
862
  from ("${buildDir}/services/saxon-he") {
863
    include "META-INF/**"
864
  }
865
  from ("${buildDir}/classes/hej") {
866
    include "net/**/*.class"
867
    exclude "net/sf/saxon/option/**"
868
  }
869
  from ("src/main/java") {
870
    include "net/sf/saxon/data/**"
871
  }
872
}
873

    
874
// Because the XQJ files are not open source, don't attempt to build
875
// the jar unless the EE sources are available.
876
if (file("${projectDir}/src/main/java/com/saxonica/xqj").exists()) {
877
  task hejJarXqj(
878
    type: Jar,
879
    dependsOn: ["eejCompile"],
880
    description: "Build the XQJ jar file for HE"
881
  ) {
882
    archiveBaseName = "saxon-he-xqj-${saxonVersion}"
883
    from ("${buildDir}/classes/eej") {
884
      include "com/saxonica/xqj/**/*.class"
885
      include "javax/xml/xquery/**/*.class"
886
    }
887
  }
888
} else {
889
  task hejJarXqj(
890
    description: "Ignore the XQJ file; the sources are unavailable"
891
  ) {
892
    doLast {
893
      println("Ignoring XQJ jar file task; the sources are unavailable")
894
    }
895
  }
896
}
897

    
898
task pejJar(
899
  type: Jar,
900
  dependsOn: ["pej_MetaInf", "pejCompile"],
901
  description: "Build the PE jar file"
902
) {
903
  archiveBaseName = "saxon-pe-${saxonVersion}"
904
  manifest {
905
    attributes "Project-Name": "Saxon-PE"
906
    attributes "Main-Class": "net.sf.saxon.Transform"
907
  }
908
  from ("${buildDir}/services/saxon-pe") {
909
    include "META-INF/**"
910
  }
911
  from ("${buildDir}/classes/pej") {
912
    include "net/**/*.class"
913
    include "com/saxonica/**/*.class"
914
    include "javax/xml/xquery/*.class"
915
    exclude "**/sql/**/*.class"
916
    exclude "com/saxonica/CompileStylesheet.class"
917
    exclude "com/saxonica/CompileStylesheet\$TracingObjectOutputStream.class"
918
    exclude "com/saxonica/Validate.class"
919
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
920
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
921
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
922
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
923
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
924
    exclude "com/saxonica/ee/**/*.class"
925
    exclude "com/saxonica/expr/CastToList.class"
926
    exclude "com/saxonica/expr/CastToUnion.class"
927
    exclude "com/saxonica/expr/CastableToList.class"
928
    exclude "com/saxonica/expr/CastableToUnion.class"
929
    exclude "com/saxonica/functions/sql/**"
930
    exclude "net/sf/saxon/option/sql/**"
931
  }
932
  from ("src/main/java") {
933
    include "net/sf/saxon/data/**"
934
  }
935
}
936

    
937
task pejJarSql(
938
  type: Jar,
939
  dependsOn: ["pejCompile"],
940
  description: "Build the SQL jar file for PE"
941
) {
942
  archiveBaseName = "saxon-pe-sql-${saxonVersion}"
943
  from ("${buildDir}/classes/pej") {
944
    include "net/sf/saxon/option/sql/*.class"
945
    include "com/saxonica/functions/sql/*.class"
946
  }
947
}
948

    
949
task eejJar(
950
  type: Jar,
951
  dependsOn: ["eej_MetaInf", "eejCompile", "asm_unzip"],
952
  description: "Build the EE jar file"
953
) {
954
  archiveBaseName = "saxon-ee-${saxonVersion}"
955
  manifest {
956
    attributes "Project-Name": "Saxon-EE"
957
    attributes "Main-Class": "net.sf.saxon.Transform"
958
  }
959
  from ("${buildDir}/services/saxon-ee") {
960
    include "META-INF/**"
961
  }
962
  from ("${buildDir}/classes/eej") {
963
    include "net/**/*.class"
964
    include "com/saxonica/**/*.class"
965
    include "javax/xml/xquery/*.class"
966
    include "org/objectweb/**/*.class"
967
    exclude "**/sql/**/*.class"
968
    exclude "com/saxonica/StatsTransform*.class"
969
    exclude "com/saxonica/functions/sql/**"
970
    exclude "net/sf/saxon/option/sql/**"
971
  }
972
  from ("src/main/java") {
973
    include "net/sf/saxon/data/**"
974
  }
975
}
976

    
977
task eejJarSql(
978
  type: Jar,
979
  dependsOn: ["eejCompile"],
980
  description: "Build the SQL jar file for EE"
981
) {
982
  archiveBaseName = "saxon-ee-sql-${saxonVersion}"
983
  from ("${buildDir}/classes/eej") {
984
    include "net/sf/saxon/option/sql/*.class"
985
    include "com/saxonica/functions/sql/*.class"
986
  }
987
}
988

    
989
// ============================================================
990

    
991
task hej_releaseSetup(
992
  type: Copy,
993
  dependsOn: ["hejJar", "hejJarXqj", "hejJarTests", "hej_notices"],
994
  description: "Build the HE release for Java"
995
) {
996
  from "${buildDir}/libs"
997
  into "${buildDir}/releases/hej"
998
  include "saxon-he-${saxonVersion}.jar"
999
  include "saxon-he-xqj-${saxonVersion}.jar"
1000
  include "saxon-he-test-${saxonVersion}.jar"
1001
  rename { filename ->
1002
    if (filename.startsWith("saxon-he-xqj")) {
1003
      filename = "saxon9-xqj.jar"
1004
    } else if (filename.startsWith("saxon-he-test")) {
1005
      filename = "saxon9-test.jar"
1006
    } else {
1007
      filename = "saxon9he.jar"
1008
    }
1009
  }
1010
}
1011

    
1012
task hejRelease(
1013
  type: Zip,
1014
  dependsOn: ["hej_releaseSetup"],
1015
  description: "Make the HE release ZIP file for Java"
1016
) {
1017
  from("${buildDir}/releases/hej")
1018
  archiveFileName = "SaxonHE${version_h}J.zip"
1019
}
1020

    
1021
task pejRelease(
1022
  type: Copy,
1023
  dependsOn: ["pejJar", "pejJarSql", "pejJarTests", "pej_libs", "pej_notices"],
1024
  description: "Build the PE release for Java"
1025
) {
1026
  from "${buildDir}/libs"
1027
  into "${buildDir}/releases/pej"
1028
  include "saxon-pe-${saxonVersion}.jar"
1029
  include "saxon-pe-sql-${saxonVersion}.jar"
1030
  include "saxon-pe-test-${saxonVersion}.jar"
1031
  rename { filename ->
1032
    if (filename.startsWith("saxon-pe-sql")) {
1033
      filename.replace("saxon-pe-sql", "saxon-sql")
1034
    } else {
1035
      filename
1036
    }
1037
  }
1038
}
1039

    
1040
task eejRelease(
1041
  type: Copy,
1042
  dependsOn: ["eejJar", "eejJarSql", "eejJarTests", "eej_libs", "eej_notices"],
1043
  description: "Build the EE release for Java"
1044
) {
1045
  from "${buildDir}/libs"
1046
  into "${buildDir}/releases/eej"
1047
  include "saxon-ee-${saxonVersion}.jar"
1048
  include "saxon-ee-sql-${saxonVersion}.jar"
1049
  include "saxon-ee-test-${saxonVersion}.jar"
1050
  rename { filename ->
1051
    if (filename.startsWith("saxon-ee-sql")) {
1052
      filename.replace("saxon-ee-sql", "saxon-sql")
1053
    } else {
1054
      filename
1055
    }
1056
  }
1057
}
1058

    
1059
task javaReleases(
1060
  dependsOn: ["hejRelease", "pejRelease", "eejRelease"],
1061
  description: "Build all of the Java releases"
1062
) {
1063
  // Just a container to hang dependencies on
1064
}
1065

    
1066
// ============================================================
1067

    
1068
task dockerCoreContainer(
1069
  type: Exec,
1070
  description: "Build the CentOS 8 core container"
1071
) {
1072
  inputs.files("${projectDir}/src/docker/centos8-core")
1073
  commandLine "docker", "build",
1074
    "-t", "${dockerCentos8Core}",
1075
    "${projectDir}/src/docker/centos8-core"
1076
}
1077

    
1078
// In order to build this container, you must specify the location
1079
// of the JDK and the Jet software archive. Use
1080
// -PdockerJdk= to specify the location of the JDK RPM. Use
1081
// -PdockerJet= to specify the location of the Jet archive.
1082
task dockerBuilderContainer(
1083
  type: Exec,
1084
  dependsOn: ["docker_setupBuilder", "dockerCoreContainer"],
1085
  description: "Build the Saxonica builder container"
1086
) {
1087
  inputs.files("${buildDir}/docker/builder")
1088
  commandLine "docker", "build",
1089
    "-t", "${dockerBuildContainer}",
1090
    "${buildDir}/docker/builder"
1091
}
1092

    
1093
task docker_setupBuilder(
1094
  type: Copy,
1095
  dependsOn: ["docker_setupJdk", "docker_setupJet"],
1096
  description: "Setup to build the builder container"
1097
) {
1098
  from "src/docker/builder"
1099
  into "${buildDir}/docker/builder"
1100
}
1101

    
1102
task docker_testJdk(
1103
  description: "Test that the dockerJdk property has been specified"
1104
) {
1105
  doLast {
1106
    if (dockerJdk == "none") {
1107
      throw new GradleException("You must specify the JDK with -PdockerJdk=...")
1108
    }
1109
  }
1110
}
1111

    
1112
task docker_setupJdk(
1113
  type: Copy,
1114
  dependsOn: ["docker_testJdk"],
1115
  description: "Setup the JDK for the builder container"
1116
) {
1117
  from dockerJdk
1118
  into "${buildDir}/docker/builder"
1119
}
1120

    
1121
task docker_testJet(
1122
  description: "Test that the dockerJet property has been specified"
1123
) {
1124
  doLast {
1125
    if (dockerJet == "none") {
1126
      throw new GradleException("You must specify Jet archive with -PdockerJet=...")
1127
    }
1128
  }
1129
}
1130

    
1131
task docker_setupJet(
1132
  type: Copy,
1133
  dependsOn: ["docker_testJet"],
1134
  description: "Setup the Jet archive for the builder container"
1135
) {
1136
  from dockerJet
1137
  into "${buildDir}/docker/builder"
1138
}
1139

    
1140
// ============================================================
1141

    
1142
// Testing task for various Gradle debugging efforts
1143
task helloWorld() {
1144
  doLast {
1145
    println("Hello, world.")
1146
  }
1147
}
1148

    
(7-7/12)