Project

Profile

Help

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

he / build-n.gradle @ eea2149f

1
// Find C# compiler: the first path that exists in this list
2
// will be used as the C# compiler.
3
//
4
def csharpCompiler = null
5
["C:/Windows/Microsoft.net/Framework/${dotNetFrameworkVersion}/csc.exe",
6
 "z:/some/other/compiler/path"].each { csc ->
7
  // This only makes sense on Windows, so always using file:/// is ok
8
  if (csharpCompiler == null && pathExists(csc)) {
9
    csharpCompiler = csc
10
  }
11
}
12

    
13
def additionalIkvmOptions = []
14
if (hasProperty("ikvmDebug")) {
15
  additionalIkvmOptions += ["-debug"]
16
}
17

    
18
task hen_featureKeys(
19
  type: JavaExec,
20
  description: "Construct the feature keys for HE"
21
) {
22
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
23
  outputs.file "${projectDir}/src/main/csharp/api/Saxon.Api/Feature.cs"
24
  outputs.file "${projectDir}/src/main/csharp/api/Saxon.Api/FeatureKeys.cs"
25
  classpath = configurations.preprocessor
26
  main = "net.sf.saxon.Transform"
27
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
28
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToCSharp.xsl",
29
    "-o:${projectDir}/src/main/csharp/api/Saxon.Api/establish-an-output-base-uri"
30
}
31

    
32
task hen_setupPreprocess(
33
  type: Copy,
34
  dependsOn: ["hen_featureKeys"],
35
  description: "Copy HE sources for preprocessing HE"
36
) {
37
  from "${projectDir}/src/main/java"
38
  into "${buildDir}/filtered/hen"
39
  include "net/sf/saxon/**/*.java"
40
  include "net/sf/saxon/data/**"
41
  exclude "net/sf/saxon/option/cpp/**"
42
  exclude "net/sf/saxon/jetonnet/**"
43
  exclude "net/sf/saxon/Gizmo.java"
44
  exclude "**/TransformerFactoryImpl.java"
45
  exclude "net/sf/saxon/BasicTransformerFactory.java"
46
  exclude "**/ant/**"
47
  exclude "**/dom/**"
48
  exclude "**/dom4j/**"
49
  exclude "**/java/**"
50
  exclude "**/testdriver/**"
51
  exclude "net/sf/saxon/testdriver/**/*.java"
52
  exclude "**/jaxp/**"
53
  exclude "**/jdom/**"
54
  exclude "**/jdom2/**"
55
  exclude "**/axiom/**"
56
  exclude "**/s9api/DOMDestination.java"
57
  exclude "**/sql/**"
58
  exclude "**/xom/**"
59
  exclude "**/xpath/**"
60
  exclude "**/xqj/**"
61
  exclude "**/stax/**"
62
}
63

    
64
task pen_setupPreprocess(
65
  type: Copy,
66
  dependsOn: ["hen_featureKeys"],
67
  description: "Copy PE sources for preprocessing PE"
68
) {
69
  from "${projectDir}/src/main/java"
70
  into "${buildDir}/filtered/pen"
71
  include "net/sf/saxon/**/*.java"
72
  include "net/sf/saxon/data/**"
73
  exclude "net/sf/saxon/option/cpp/**"
74
  exclude "net/sf/saxon/jetonnet/**"
75
  exclude "net/sf/saxon/Gizmo.java"
76
  exclude "**/TransformerFactoryImpl.java"
77
  exclude "net/sf/saxon/BasicTransformerFactory.java"
78
  exclude "**/testdriver/**"
79
  exclude "**/ant/**"
80
  exclude "**/dom/**"
81
  exclude "**/dom4j/**"
82
  exclude "**/java/**"
83
  exclude "**/jaxp/**"
84
  exclude "**/jdom/**"
85
  exclude "**/jdom2/**"
86
  exclude "**/axiom/**"
87
  exclude "**/s9api/DOMDestination.java"
88
  exclude "**/sql/**"
89
  exclude "**/xom/**"
90
  exclude "**/xpath/**"
91
  exclude "**/xqj/**"
92
  exclude "**/stax/**"
93
  include "com/saxonica/**/*.java"
94
  exclude "com/saxonica/ee/**/*.java"
95
  exclude "com/saxonica/functions/extfn/cpp/*.java"
96
  exclude "com/saxonica/testdriver/**/*.java"
97
  exclude "net/sf/saxon/testdriver/**/*.java"
98
  exclude "com/saxonica/jaxp/*.java"
99
  exclude "com/saxonica/js/**"
100
  exclude "com/saxonica/config/ProfessionalXPathFactory.java" 
101
  exclude "com/saxonica/config/EnterpriseConfiguration.java" 
102
  exclude "com/saxonica/config/JavaPlatformPE.java" 
103
  exclude "com/saxonica/config/JavaPlatformEE.java" 
104
  exclude "com/saxonica/config/JavaPlatformC.java"
105
  exclude "com/saxonica/config/ee/**" 
106
  exclude "com/saxonica/stream/**" 
107
  exclude "com/saxonica/schema/**" 
108
  exclude "com/saxonica/bytecode/**" 
109
  exclude "com/saxonica/expr/ee/**" 
110
  exclude "com/saxonica/update/**/*.java"
111
  exclude "com/saxonica/validate/**/*.java"
112
  exclude "com/saxonica/expr/CastToUnion.java"
113
  exclude "com/saxonica/expr/CastableToUnion.java"
114
  exclude "com/saxonica/expr/CastableToUnion.java"
115
  exclude "com/saxonica/Validate.java"
116
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
117
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
118
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
119
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
120
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
121
  exclude "com/saxonica/config/DynamicLoaderEE.java"
122
  exclude "com/saxonica/config/StandardSchemaResolver.java"
123
  exclude "com/saxonica/functions/extfn/NativeCall.java"
124
  exclude "**/xqj/**"
125
}
126

    
127
task een_setupPreprocess(
128
  type: Copy,
129
  dependsOn: ["hen_featureKeys"],
130
  description: "Copy EE sources for preprocessing EE"
131
) {
132
  from "${projectDir}/src/main/java"
133
  into "${buildDir}/filtered/een"
134
  include "net/sf/saxon/**/*.java"
135
  include "net/sf/saxon/data/**"
136
  exclude "net/sf/saxon/TransformerFactoryImpl.java"
137
  exclude "net/sf/saxon/BasicTransformerFactory.java"
138
  exclude "net/sf/saxon/option/cpp/**"
139
  exclude "net/sf/saxon/jetonnet/**"
140
  exclude "net/sf/saxon/Gizmo.java"
141
  exclude "**/ant/**"
142
  exclude "**/dom/**"
143
  exclude "**/dom4j/**"
144
  exclude "**/java/**"
145
  exclude "**/jaxp/**"
146
  exclude "**/jdom/**"
147
  exclude "**/jdom2/**"
148
  exclude "**/axiom/**"
149
  exclude "**/s9api/DOMDestination.java"
150
  exclude "**/sql/**"
151
  exclude "**/xom/**"
152
  exclude "**/xpath/**"
153
  exclude "**/xqj/**"
154
  exclude "**/stax/**"
155
  include "com/saxonica/**/*.java"
156
  exclude "com/saxonica/functions/extfn/cpp/*.java"
157
  exclude "com/saxonica/testdriver/**/*.java"
158
  exclude "net/sf/saxon/testdriver/**/*.java"
159
  exclude "com/saxonica/ee/jaxp/*.java"
160
  exclude "com/saxonica/js/**"
161
  exclude "com/saxonica/ee/domino/**/*.java"
162
  exclude "com/saxonica/config/JavaPlatformPE.java"
163
  exclude "com/saxonica/config/JavaPlatformEE.java"
164
  exclude "com/saxonica/config/JavaPlatformC.java"
165
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
166
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
167
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
168
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
169
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
170
  exclude "com/saxonica/config/NativePlatformPE.java"
171
  exclude "**/xqj/**"
172
}
173

    
174
task hen_preprocess(
175
  type: JavaExec,
176
  dependsOn: ["hen_setupPreprocess"],
177
  description: "Preprocess HE sources"
178
) {
179
  inputs.files fileTree(dir: "${buildDir}/filtered/hen")
180
  outputs.files fileTree(dir: "${buildDir}/preprocess/hen")
181
  classpath = configurations.preprocessor
182
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
183
  args "/c",
184
    "/i:${buildDir}/filtered/hen", "/o:${buildDir}/preprocess/hen",
185
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=true",
186
    "/p:SAXONC=false", "/p:BYTECODE=false"
187
  doFirst {
188
    mkdir "${buildDir}/preprocess/hen"
189
  }
190
}
191

    
192
task pen_preprocess(
193
  type: JavaExec,
194
  dependsOn: ["pen_setupPreprocess"],
195
  description: "Preprocess PE sources"
196
) {
197
  inputs.files fileTree(dir: "${buildDir}/filtered/pen")
198
  outputs.files fileTree(dir: "${buildDir}/preprocess/pen")
199
  classpath = configurations.preprocessor
200
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
201
  args "/c",
202
    "/i:${buildDir}/filtered/pen", "/o:${buildDir}/preprocess/pen",
203
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=true",
204
    "/p:SAXONC=false", "/p:BYTECODE=false", "/p:HOF=true"
205
  doFirst {
206
    mkdir "${buildDir}/preprocess/pen"
207
  }
208
}
209

    
210
task een_preprocess(
211
  type: JavaExec,
212
  dependsOn: ["een_setupPreprocess"],
213
  description: "Preprocess EE sources"
214
) {
215
  inputs.files fileTree(dir: "${buildDir}/filtered/een")
216
  outputs.files fileTree(dir: "${buildDir}/preprocess/een")
217
  classpath = configurations.preprocessor
218
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
219
  args "/c",
220
    "/i:${buildDir}/filtered/een", "/o:${buildDir}/preprocess/een",
221
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=true",
222
    "/p:SAXONC=false", "/p:BYTECODE=true", "/p:HOF=true",
223
    "/p:STREAM=true", "/p:SCHEMA=true"
224
  doFirst {
225
    mkdir "${buildDir}/preprocess/een"
226
  }
227
}
228

    
229
task hen_sources(
230
  type: Copy,
231
  dependsOn: ["hen_preprocess"],
232
  description: "Collect the preprocessed HE sources for compilation"
233
) {
234
  from "${buildDir}/preprocess/hen"
235
  into "${buildDir}/src/hen"
236
  filter { line ->
237
    if (line.contains("import com.saxonica")
238
        || line.contains("import net.sf.saxon.stax")
239
        || line.contains("import net.sf.saxon.jaxp")
240
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")) {
241
      null
242
    } else {
243
      line
244
    }
245
  }
246
}
247

    
248
task pen_sources(
249
  type: Copy,
250
  dependsOn: ["pen_preprocess"],
251
  description: "Collect the preprocessed PE sources for compilation"
252
) {
253
  from "${buildDir}/preprocess/pen"
254
  into "${buildDir}/src/pen"
255
  filter { line ->
256
    if (line.contains("import com.saxonica.ee")
257
        || line.contains("import com.saxonica.config.ee")
258
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
259
        || line.contains("import net.sf.saxon.stax")
260
        || line.contains("import net.sf.saxon.jaxp")) {
261
      null
262
    } else {
263
      line
264
    }
265
  }
266
}
267

    
268
task een_sources(
269
  type: Copy,
270
  dependsOn: ["een_preprocess"],
271
  description: "Collect the preprocessed EE sources for compilation"
272
) {
273
  from "${buildDir}/preprocess/een"
274
  into "${buildDir}/src/een"
275
  filter { line ->
276
    if (line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
277
        || line.contains("import com.saxonica.ee.jaxp.SchemaFactoryImpl")
278
        || line.contains("import net.sf.saxon.stax")
279
        || line.contains("import net.sf.saxon.jaxp")) {
280
      null
281
    } else {
282
      line
283
    }
284
  }
285
}
286

    
287
// ============================================================
288

    
289
Task chsa = task hen_copySaxonApi(
290
  type: Copy,
291
  description: "Copy the Saxon.API C# files"
292
) {
293
  from "${projectDir}/src/main/csharp/api/Saxon.Api"
294
  into "${buildDir}/n/csharp/api/Saxon.Api"
295
  include "*.cs"
296
}
297

    
298
task hen_ApiAssemblyInfo(
299
  description: "Create the AssemblyInfo.cs file for the Saxon.Api"
300
) {
301
  outputs.file("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
302
  doLast {
303
    new File("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
304
      .withWriter("utf-8") { writer ->
305
        writer.writeLine("          using System.Reflection;")
306
        writer.writeLine("          using System.Runtime.CompilerServices;")
307
        writer.writeLine("          using System.Runtime.InteropServices;")
308
        writer.writeLine("          [assembly: AssemblyTitle(\"Saxon.Api\")]")
309
        writer.writeLine("          [assembly: AssemblyDescription(\"\")]")
310
        writer.writeLine("          [assembly: AssemblyConfiguration(\"\")]")
311
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
312
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.Api\")]")
313
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2020\")]")
314
        writer.writeLine("          [assembly: AssemblyTrademark(\"\")]")
315
        writer.writeLine("          [assembly: AssemblyCulture(\"\")]")
316
        writer.writeLine("          [assembly: ComVisible(false)]")
317
        writer.writeLine("          [assembly: Guid(\"8cf9aad8-da5f-47f0-9251-1fbcbdcfe477\")]")
318
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
319
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
320
      }
321
  }
322
  doFirst {
323
    mkdir "${buildDir}/n/csharp/api/Saxon.Api/Properties"
324
  }
325
}
326

    
327
task hen_copySaxonCmd(
328
  type: Copy,
329
  description: "Copy the cmd C# files"
330
) {
331
  from "${projectDir}/src/main/csharp/cmd"
332
  into "${buildDir}/n/csharp/cmd"
333
  include "**/Transform.cs"
334
  include "**/Query.cs"
335
  include "**/Validate.cs"
336
}
337

    
338
task hen_copySamples(
339
  type: Copy,
340
  description: "Copy the HE sample C# files"
341
) {
342
  from "${projectDir}/src/samples/cs"
343
  into "${buildDir}/n/csharp/samples"
344
  include "ExamplesEE.cs"
345
  include "ExamplesHE.cs"
346
  include "ExamplesPE.cs"
347
  include "SampleExtensions.cs"
348
  include "XPathExample.cs"
349
}
350

    
351
task hen_copyDevelopmentSources(
352
  dependsOn: ["hen_copySaxonApi", "hen_ApiAssemblyInfo",
353
              "hen_copySaxonCmd", "hen_copySamples"],
354
  description: "Setup the C# build environment"
355
) {
356
    // Just a task to hang dependencies on
357
}
358

    
359
task henCompile(
360
  type: JavaCompile,
361
  dependsOn: ["hen_sources", "hen_copyDevelopmentSources"],
362
  description: "Compile HE for .NET"
363
) {
364
  classpath = configurations.compileClasspath + configurations.compileDotNet
365
  source = "${buildDir}/src/hen"
366
  destinationDirectory = new File("${buildDir}/classes/hen")
367
}
368

    
369
task penCompile(
370
  type: JavaCompile,
371
  dependsOn: ["pen_sources", "hen_copyDevelopmentSources"],
372
  description: "Compile PE for .NET"
373
) {
374
  classpath = configurations.compileClasspath + configurations.compileDotNet
375
  source = "${buildDir}/src/pen"
376
  destinationDirectory = new File("${buildDir}/classes/pen")
377
}
378

    
379
task eenCompile(
380
  type: JavaCompile,
381
  dependsOn: ["een_sources", "hen_copyDevelopmentSources"],
382
  description: "Compile EE for .NET"
383
) {
384
  classpath = configurations.compileClasspath + configurations.asmDotNet
385
  source = "${buildDir}/src/een"
386
  destinationDirectory = new File("${buildDir}/classes/een")
387
}
388

    
389
task hen_jar(
390
  type: Jar,
391
  dependsOn: ["henCompile"],
392
  description: "Build the HE jar file for Saxon .NET"
393
) {
394
  archiveBaseName = "saxon10he"
395
  destinationDirectory = file("${buildDir}/n/jar")
396
  from ("build/classes/hen") {
397
    include "net/**/*.class"
398
    exclude "net/sf/saxon/option/**/*.class"
399
  }
400
  from ("build/src/hen") {
401
    include "**"
402
  }
403
  doFirst {
404
    mkdir "build/n/jar"
405
  }
406
}
407

    
408
task pen_jar(
409
  type: Jar,
410
  dependsOn: ["penCompile"],
411
  description: "Build the PE jar file for Saxon .NET"
412
) {
413
  archiveBaseName = "saxon10pe"
414
  destinationDirectory = file("${buildDir}/n/jar")
415
  from ("build/classes/pen") {
416
    include "net/**/*.class"
417
    exclude "net/sf/saxon/ant/*.class"
418
    exclude "**/sql/**/*.class"
419
    include "com/saxonica/**/*.class"
420
    exclude "com/saxonica/bytecode/**/*.class"
421
    exclude "com/saxonica/jaxp/**/**/*.class"
422
    exclude "com/saxonica/schema/**/*.class"
423
    exclude "com/saxonica/stream/**/*.class"
424
    exclude "com/saxonica/testdriver/**/*.class"
425
    exclude "net/sf/saxon/testdriver/**/*.class"
426
    exclude "com/saxonica/update/**/*.class"
427
    exclude "com/saxonica/validate/**/*.class"
428
    exclude "com/saxonica/expr/CastToUnion.class"
429
    exclude "com/saxonica/expr/CastableToUnion.class"
430
    exclude "com/saxonica/expr/CastableToList.class"
431
    exclude "com/saxonica/Validate.class"
432
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
433
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
434
    exclude "com/saxonica/config/EnterpriseConfiguration\$1.class"
435
    exclude "com/saxonica/config/ProfessionalTransformerFactory.class"
436
    exclude "com/saxonica/config/ProfessionalXPathFactory.class"
437
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
438
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
439
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
440
    exclude "com/saxonica/config/DynamicLoaderEE.class"
441
    exclude "com/saxonica/config/StandardSchemaResolver.class"
442
    exclude "com/saxonica/expr/ee/*.class"
443
  }
444
  from ("src/main/java") {
445
    include "net/sf/saxon/data/**"
446
  }
447
  doFirst {
448
    mkdir "build/n/jar"
449
  }
450
}
451

    
452
task een_jar(
453
  type: Jar,
454
  dependsOn: ["eenCompile"],
455
  description: "Build the EE jar file for Saxon .NET"
456
) {
457
  archiveBaseName = "saxon10ee"
458
  destinationDirectory = file("${buildDir}/n/jar")
459
  from ("build/classes/een") {
460
    include "net/**/*.class"
461
    include "com/saxonica/**/*.class"
462
    include "org/objectweb/**/*.class"
463
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
464
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
465
  }
466
  from ("src/main/java") {
467
    include "net/sf/saxon/data/**"
468
  }
469
  doFirst {
470
    mkdir "build/n/jar"
471
  }
472
}
473

    
474
task ikvm_prepareJarAsm(
475
  type: Copy,
476
  description: "Copy the ASM jars for IKVM"
477
) {
478
  from "lib/asm-${asmVersion}"
479
  into "${buildDir}/n/jar/asm-${asmVersion}"
480
  include "*.jar"
481
}
482

    
483
task ikvm_prepareJar(
484
  type: Copy,
485
  dependsOn: ["ikvm_prepareJarAsm", "rejar_Xerces"],
486
  description: "Copy the ICU4J, TagSoup, Mail, and Xerces jars for IKVM"
487
) {
488
  from "${icu4jJar}"
489
  into "${buildDir}/n/jar"
490
  from "${tagsoupJar}"
491
  into "${buildDir}/n/jar"
492
  from "${mailJar}"
493
  into "${buildDir}/n/jar"
494
  from "${buildDir}/xerces/xerces.jar"
495
  into "${buildDir}/n/jar"
496
}
497

    
498
task "n_notices"(
499
  type: Copy,
500
  description: "Copy the notices into the staging directory"
501
) {
502
  from "src/docs/notices"
503
  into "${buildDir}/n/notices"
504
}
505

    
506
["h", "p", "e"].each { initial ->
507
  def release = initial + "e"
508
  def RELEASE = release.toUpperCase()
509
  task "${release}n_setupDll"(
510
    type: Copy,
511
    dependsOn: ["${release}n_jar", "ikvm_prepareJar"],
512
    description: "Setup the IKVM environment for ${RELEASE}"
513
) {
514
    from "${ikvmDir}/ikvm-${ikvmVersion}/bin"
515
    into "${buildDir}/n/bin/${release}"
516
    include "IKVM.OpenJDK.Core.dll"
517
    include "IKVM.OpenJDK.Charsets.dll"
518
    include "IKVM.OpenJDK.Text.dll"
519
    include "IKVM.OpenJDK.Util.dll"
520
    include "IKVM.OpenJDK.XML.API.dll"
521
    include "IKVM.OpenJDK.Security.dll"
522
    //include "xercesImpl.dll"
523
    include "IKVM.Runtime.dll"
524
  }
525

    
526
  task "${release}n_iss"(
527
    type: Copy,
528
    description: "Create the ${release}.iss file for the .net installer"
529
  ) {
530
    inputs.file("${projectDir}/src/dotnet/${release}.iss")
531
    outputs.file("${buildDir}/n/${release}.iss")
532

    
533
    from "${projectDir}/src/dotnet/${release}.iss"
534
    into "${buildDir}/n"
535
    filter { line ->
536
      line \
537
        .replace("@@SOURCE_DIR@@", "bin\\${release}") \
538
        .replace("@@OUTPUT_DIR@@", "..\\..\\..\\distributions") \
539
        .replace("@@VERSION@@", saxonVersion) \
540
        .replace("@@VERSION_H@@", version_h) \
541
        .replace("@@IKVM_STRONGNAME@@", ikvmStrongname) \
542
        .replace("@@MAJOR_VERSION@@", saxonMajorVersion) \
543
        .replace("@@MINOR_VERSION@@", saxonMinorVersion) \
544
        .replace("@@COPYRIGHT_YEAR@@", "2020")
545
    }
546
  }
547

    
548
  task "${release}nInstaller"(
549
    type: Exec,
550
    dependsOn: ["${release}nProduct", "${release}n_iss", "n_notices"],
551
    description: "Build the ${RELEASE} installer for .NET"
552
  ) {
553
    commandLine "${dotNetInstaller}",
554
      "/cc", "${buildDir}/n/${release}.iss"
555
  }
556
}
557

    
558
task henDll(
559
  type: Exec,
560
  dependsOn: ["hen_setupDll"],
561
  description: "Build HE .dll with IKVM"
562
) {
563
  inputs.files("${buildDir}/n/bin/he")
564
  inputs.file("${buildDir}/xerces/xerces.jar")
565
  inputs.file("${ikvmDir}/saxondotnet.snk")
566
  outputs.file("build/n/bin/he/saxon-he-${saxonMajorVersion}.${saxonMinorVersion}.dll")
567

    
568
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
569
  + additionalIkvmOptions \
570
  + ["-out:${buildDir}/n/bin/he/saxon-he-${saxonMajorVersion}.${saxonMinorVersion}.dll",
571
     "-assembly:saxon-he-${saxonMajorVersion}.${saxonMinorVersion}",
572
     "-target:library",
573
     "-keyfile:${ikvmDir}/saxondotnet.snk",
574
     "-version:${saxonVersion}",
575
     "-srcpath:${buildDir}/preprocess/hen",
576
     "-reference:mscorlib.dll",
577
     "-reference:System.Xml.dll",
578
     "-reference:System.dll",
579
     "-reference:${buildDir}/n/bin/he/IKVM.OpenJDK.Core.dll",
580
     "${buildDir}/n/jar/saxon10he.jar",
581
     "${buildDir}/n/jar/xerces.jar"]
582

    
583
  commandLine ikvmCommand
584
  doFirst {
585
    mkdir "${buildDir}/n/bin/he"
586
  }
587
}
588

    
589
task penDll(
590
  type: Exec,
591
  dependsOn: ["pen_setupDll"],
592
  description: "Build PE .dll with IKVM"
593
) {
594
  inputs.files("${buildDir}/n/bin/pe")
595
  inputs.file("${buildDir}/xerces/xerces.jar")
596
  inputs.file("${ikvmDir}/saxondotnet.snk")
597
  outputs.file("build/n/bin/pe/saxon-pe-${saxonMajorVersion}.${saxonMinorVersion}.dll")
598

    
599
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
600
  + additionalIkvmOptions \
601
  + ["-out:${buildDir}/n/bin/pe/saxon-pe-${saxonMajorVersion}.${saxonMinorVersion}.dll",
602
     "-assembly:saxon-pe-${saxonMajorVersion}.${saxonMinorVersion}",
603
     "-target:library",
604
     "-keyfile:${ikvmDir}/saxondotnet.snk",
605
     "-version:${saxonVersion}",
606
     "-srcpath:${buildDir}/preprocess/pen",
607
     "-reference:mscorlib.dll",
608
     "-reference:System.Xml.dll",
609
     "-reference:System.dll",
610
     "-reference:${buildDir}/n/bin/pe/IKVM.OpenJDK.Core.dll",
611
     "-reference:System.Security.dll",
612
     "${buildDir}/n/jar/saxon10pe.jar",
613
     "${buildDir}/n/jar/xerces.jar",
614
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
615
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
616
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
617

    
618
  commandLine ikvmCommand
619
  doFirst {
620
    mkdir "${buildDir}/n/bin/pe"
621
  }
622
}
623

    
624
task eenDll(
625
  type: Exec,
626
  dependsOn: ["een_setupDll"],
627
  description: "Build EE .dll with IKVM"
628
) {
629
  inputs.files("${buildDir}/n/bin/ee")
630
  inputs.file("${buildDir}/xerces/xerces.jar")
631
  inputs.file("${ikvmDir}/saxondotnet.snk")
632
  outputs.file("build/n/bin/ee/saxon-ee-${saxonMajorVersion}.${saxonMinorVersion}.dll")
633

    
634
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
635
  + additionalIkvmOptions \
636
  + ["-out:${buildDir}/n/bin/ee/saxon-ee-${saxonMajorVersion}.${saxonMinorVersion}.dll",
637
     "-assembly:saxon-ee-${saxonMajorVersion}.${saxonMinorVersion}",
638
     "-target:library",
639
     "-keyfile:${ikvmDir}/saxondotnet.snk",
640
     "-version:${saxonVersion}",
641
     "-srcpath:${buildDir}/preprocess/een",
642
     "-reference:mscorlib.dll",
643
     "-reference:System.Xml.dll",
644
     "-reference:System.dll",
645
     "-reference:${buildDir}/n/bin/ee/IKVM.OpenJDK.Core.dll",
646
     "-reference:System.Security.dll",
647
     "${buildDir}/n/jar/saxon10ee.jar",
648
     "${buildDir}/n/jar/xerces.jar",
649
     "${buildDir}/n/jar/asm-${asmVersion}/asm-${asmVersion}.jar",
650
     "${buildDir}/n/jar/asm-${asmVersion}/asm-analysis-${asmVersion}.jar",
651
     "${buildDir}/n/jar/asm-${asmVersion}/asm-commons-${asmVersion}.jar",
652
     "${buildDir}/n/jar/asm-${asmVersion}/asm-tree-${asmVersion}.jar",
653
     "${buildDir}/n/jar/asm-${asmVersion}/asm-util-${asmVersion}.jar",
654
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
655
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
656
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
657

    
658
  commandLine ikvmCommand
659
  doFirst {
660
    mkdir "${buildDir}/n/bin/ee"
661
  }
662
}
663

    
664
task productDlls(
665
  dependsOn: ["henDll", "penDll", "eenDll"],
666
  description: "Build all the product .dll files with IKVM"
667
) {
668
  doLast {
669
    println("Built DLLs")
670
  }
671
}
672

    
673
// ============================================================
674
// Tasks to rejar Xerces and Resolver for .NET
675

    
676
task unjar_XercesImpl(
677
  type: Copy,
678
  description: "Unjar XercesImple for .NET build"
679
) {
680
  inputs.file("lib/xercesImpl.jar")
681
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xerces"))
682
  from zipTree(file("lib/xercesImpl.jar"))
683
  into "${buildDir}/xerces"
684
}
685

    
686
task unjar_Resolver(
687
  type: Copy,
688
  description: "Unjar Resolver for .NET build"
689
) {
690
  inputs.file("${resolverJar}")
691
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xml/resolver"))
692
  from zipTree(file("${resolverJar}"))
693
  into "${buildDir}/xerces"
694
}
695

    
696
task rejar_Xerces(
697
  type: Jar,
698
  dependsOn: ["unjar_XercesImpl", "unjar_Resolver"],
699
  description: "Unjar Xerces and Resolver for .NET build"
700
) {
701
  archiveBaseName = "xerces"
702
  destinationDirectory = file("${buildDir}/xerces")
703
  from ("${buildDir}/xerces") {
704
    include "**/*.class"
705
    include "**/*.properties"
706
    exclude "org.w3c.dom.html.HTMLDOMImplementation.class"
707
    exclude "META-INF/MANIFEST.MF"
708
  }
709
}
710

    
711
task hen_cmdAssemblyInfo(
712
  description: "Create the AssemblyInfo.cs file for the Saxon commands"
713
) {
714
  outputs.file("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
715
  doLast {
716
    new File("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
717
      .withWriter("utf-8") { writer ->
718
        writer.writeLine("          using System.Reflection;")
719
        writer.writeLine("          using System.Runtime.CompilerServices;")
720
        writer.writeLine("          using System.Runtime.InteropServices;")
721
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
722
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.HE\")]")
723
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2020\")]")
724
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
725
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
726
      }
727
  }
728
  doFirst {
729
    mkdir "${buildDir}/n/csharp/cmd"
730
  }
731
}
732

    
733
// If we didn't find a C# compiler, abort all the C# compile steps
734
if (csharpCompiler == null) {
735
  ["h", "p", "e"].each { initial ->
736
    def release = initial + "e"
737
    def Release = initial.toUpperCase() + "e"
738
    def RELEASE = release.toUpperCase()
739
    def product = "${release}n"
740
    ["csharpApi", "csharpTransform", "csharpQuery"].each { step ->
741
      def desc = "Compile Saxon.Api for ${RELEASE}"
742
      if (step == "csharpTransform") {
743
        desc = "Compile Tranform.exe for ${RELEASE}"
744
      } else if (step == "csharpQuery") {
745
        desc = "Compile Query.exe for ${RELEASE}"
746
      }
747
      desc = desc + " (Fails on this platform)"
748
      task "${product}_${step}"(
749
        description: desc
750
      ) {
751
        doLast {
752
          throw new GradleException("Cannot build .NET; no C# compiler.")
753
        }
754
      }
755
    }
756
  }
757
  task een_csharpValidate(
758
    description: "Compile Validate.exe for EE (Fails on this platform)"
759
  ) {
760
    doLast {
761
      throw new GradleException("Cannot build .NET; no C# compiler.")
762
    }
763
  } 
764
} else {
765
  task hen_csharpApi(
766
    dependsOn: ["henDll"],
767
    description: "Compile Saxon.Api for HE"
768
  ) {
769
    inputs.files("${buildDir}/n/build/dll/he")
770
    inputs.files("${buildDir}/n/csharp/api")
771
    outputs.file("${buildDir}/n/bin/he/saxon-he-api-${saxonMajorVersion}.${saxonMinorVersion}.dll")
772

    
773
    doLast {
774
      def args = [csharpCompiler,
775
                  "-out:${buildDir}/n/bin/he/saxon-he-api-${saxonMajorVersion}.${saxonMinorVersion}.dll",
776
                  "-target:library", "-doc:${buildDir}/n/saxon-he-api-${saxonMajorVersion}.${saxonMinorVersion}.xml",
777
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
778
      fileTree(dir: "${buildDir}/n/bin/he",
779
               include: "*.dll").each { dll ->
780
        args += ["-reference:${dll}"]
781
      }
782
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
783
               include: "**/*.cs").each { cs ->
784
        args += [cs]
785
      }
786

    
787
      exec {
788
        commandLine args
789
      }
790
    }
791
  }
792

    
793
  task hen_csharpTransform(
794
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
795
    description: "Compile Transform.exe for HE"
796
  ) {
797
    inputs.files("${buildDir}/n/build/dll/he")
798
    inputs.files("${buildDir}/n/csharp/cmd")
799
    outputs.file("${buildDir}/n/bin/he/Transform.exe")
800

    
801
    doLast {
802
      def args = [csharpCompiler,
803
                  "-out:${buildDir}/n/bin/he/Transform.exe",
804
                  "-target:exe",
805
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
806
      fileTree(dir: "${buildDir}/n/bin/he",
807
               include: "*.dll").each { dll ->
808
        args += ["-reference:${dll}"]
809
      }
810
      // This only runs on Windows, so make sure you use "\"
811
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
812
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
813

    
814
      exec {
815
        commandLine args
816
      }
817
    }
818
  }
819

    
820
  task hen_csharpQuery(
821
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
822
    description: "Compile Query.exe for HE"
823
  ) {
824
    inputs.files("${buildDir}/n/build/dll/he")
825
    inputs.files("${buildDir}/n/csharp/cmd")
826
    outputs.file("${buildDir}/n/bin/he/Query.exe")
827

    
828
    doLast {
829
      def args = [csharpCompiler,
830
                  "-out:${buildDir}/n/bin/he/Query.exe",
831
                  "-target:exe",
832
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
833
      fileTree(dir: "${buildDir}/n/bin/he",
834
               include: "*.dll").each { dll ->
835
        args += ["-reference:${dll}"]
836
      }
837
      // This only runs on Windows, so make sure you use "\"
838
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
839
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
840

    
841
      exec {
842
        commandLine args
843
      }
844
    }
845
  }
846

    
847
  task pen_csharpApi(
848
    dependsOn: ["penDll"],
849
    description: "Compile Saxon.Api for PE"
850
  ) {
851
    inputs.files("${buildDir}/n/build/dll/pe")
852
    inputs.files("${buildDir}/n/csharp/api")
853
    outputs.file("${buildDir}/n/bin/pe/saxon-pe-api-${saxonMajorVersion}.${saxonMinorVersion}.dll")
854

    
855
    doLast {
856
      def args = [csharpCompiler,
857
                  "-out:${buildDir}/n/bin/pe/saxon-pe-api-${saxonMajorVersion}.${saxonMinorVersion}.dll",
858
                  "-target:library", "-doc:${buildDir}/n/saxon-pe-api-${saxonMajorVersion}.${saxonMinorVersion}.xml",
859
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
860
      fileTree(dir: "${buildDir}/n/bin/pe",
861
               include: "*.dll").each { dll ->
862
        args += ["-reference:${dll}"]
863
      }
864
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
865
               include: "**/*.cs").each { cs ->
866
        args += [cs]
867
      }
868

    
869
      exec {
870
        commandLine args
871
      }
872
    }
873
  }
874

    
875
  task pen_csharpTransform(
876
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
877
    description: "Compile Transform.exe for PE"
878
  ) {
879
    inputs.files("${buildDir}/n/build/dll/pe")
880
    inputs.files("${buildDir}/n/csharp/cmd")
881
    outputs.file("${buildDir}/n/bin/pe/Transform.exe")
882

    
883
    doLast {
884
      def args = [csharpCompiler,
885
                  "-out:${buildDir}/n/bin/pe/Transform.exe",
886
                  "-target:exe",
887
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
888
      fileTree(dir: "${buildDir}/n/bin/pe",
889
               include: "*.dll").each { dll ->
890
        args += ["-reference:${dll}"]
891
      }
892
      // This only runs on Windows, so make sure you use "\"
893
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
894
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
895

    
896
      exec {
897
        commandLine args
898
      }
899
    }
900
  }
901

    
902
  task pen_csharpQuery(
903
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
904
    description: "Compile Query.exe for PE"
905
  ) {
906
    inputs.files("${buildDir}/n/build/dll/pe")
907
    inputs.files("${buildDir}/n/csharp/cmd")
908
    outputs.file("${buildDir}/n/bin/pe/Query.exe")
909

    
910
    doLast {
911
      def args = [csharpCompiler,
912
                  "-out:${buildDir}/n/bin/pe/Query.exe",
913
                  "-target:exe",
914
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
915
      fileTree(dir: "${buildDir}/n/bin/pe",
916
               include: "*.dll").each { dll ->
917
        args += ["-reference:${dll}"]
918
      }
919
      // This only runs on Windows, so make sure you use "\"
920
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
921
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
922

    
923
      exec {
924
        commandLine args
925
      }
926
    }
927
  }
928

    
929
  task een_csharpApi(
930
    dependsOn: ["eenDll"],
931
    description: "Compile Saxon.Api for EE"
932
  ) {
933
    inputs.files("${buildDir}/n/build/dll/ee")
934
    inputs.files("${buildDir}/n/csharp/api")
935
    outputs.file("${buildDir}/n/bin/ee/saxon-ee-api-${saxonMajorVersion}.${saxonMinorVersion}.dll")
936

    
937
    doLast {
938
      def args = [csharpCompiler,
939
                  "-out:${buildDir}/n/bin/ee/saxon-ee-api-${saxonMajorVersion}.${saxonMinorVersion}.dll",
940
                  "-target:library", "-doc:${buildDir}/n/saxon-ee-api-${saxonMajorVersion}.${saxonMinorVersion}.xml",
941
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
942
      fileTree(dir: "${buildDir}/n/bin/ee",
943
               include: "*.dll").each { dll ->
944
        args += ["-reference:${dll}"]
945
      }
946
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
947
               include: "**/*.cs").each { cs ->
948
        args += [cs]
949
      }
950

    
951
      exec {
952
        commandLine args
953
      }
954
    }
955
  }
956

    
957
  task een_csharpTransform(
958
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
959
    description: "Compile Transform.exe for EE"
960
  ) {
961
    inputs.files("${buildDir}/n/build/dll/ee")
962
    inputs.files("${buildDir}/n/csharp/cmd")
963
    outputs.file("${buildDir}/n/bin/ee/Transform.exe")
964

    
965
    doLast {
966
      def args = [csharpCompiler,
967
                  "-out:${buildDir}/n/bin/ee/Transform.exe",
968
                  "-target:exe",
969
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
970
      fileTree(dir: "${buildDir}/n/bin/ee",
971
               include: "*.dll").each { dll ->
972
        args += ["-reference:${dll}"]
973
      }
974
      // This only runs on Windows, so make sure you use "\"
975
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
976
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
977

    
978
      exec {
979
        commandLine args
980
      }
981
    }
982
  }
983

    
984
  task een_csharpQuery(
985
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
986
    description: "Compile Query.exe for EE"
987
  ) {
988
    inputs.files("${buildDir}/n/build/dll/ee")
989
    inputs.files("${buildDir}/n/csharp/cmd")
990
    outputs.file("${buildDir}/n/bin/ee/Query.exe")
991

    
992
    doLast {
993
      def args = [csharpCompiler,
994
                  "-out:${buildDir}/n/bin/ee/Query.exe",
995
                  "-target:exe",
996
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
997
      fileTree(dir: "${buildDir}/n/bin/ee",
998
               include: "*.dll").each { dll ->
999
        args += ["-reference:${dll}"]
1000
      }
1001
      // This only runs on Windows, so make sure you use "\"
1002
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
1003
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
1004

    
1005
      exec {
1006
        commandLine args
1007
      }
1008
    }
1009
  }
1010

    
1011
  task een_csharpValidate(
1012
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
1013
    description: "Compile Validate.exe for EE"
1014
  ) {
1015
    inputs.files("${buildDir}/n/build/dll/ee")
1016
    inputs.files("${buildDir}/n/csharp/cmd")
1017
    outputs.file("${buildDir}/n/bin/ee/Validate.exe")
1018

    
1019
    doLast {
1020
      def args = [csharpCompiler,
1021
                  "-out:${buildDir}/n/bin/ee/Validate.exe",
1022
                  "-target:exe",
1023
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
1024
      fileTree(dir: "${buildDir}/n/bin/ee",
1025
               include: "*.dll").each { dll ->
1026
        args += ["-reference:${dll}"]
1027
      }
1028
      // This only runs on Windows, so make sure you use "\"
1029
      args += ["${buildDir}\\n\\csharp\\cmd\\Validate.cs",
1030
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
1031

    
1032
      exec {
1033
        commandLine args
1034
      }
1035
    }
1036
  }
1037
}
1038

    
1039
task henProduct(
1040
  type: Copy,
1041
  dependsOn: ["hen_csharpApi", "hen_csharpTransform", "hen_csharpQuery"],
1042
  description: "Build Saxon HE for .NET"
1043
) {
1044
  from "${buildDir}/n/saxon-he-api-${saxonMajorVersion}.${saxonMinorVersion}.xml"
1045
  into "${buildDir}/n/bin/he"
1046
}
1047

    
1048
task penProduct(
1049
  type: Copy,
1050
  dependsOn: ["pen_csharpApi", "pen_csharpTransform", "pen_csharpQuery"],
1051
  description: "Build Saxon PE for .NET"
1052
) {
1053
  from "${buildDir}/n/saxon-pe-api-${saxonMajorVersion}.${saxonMinorVersion}.xml"
1054
  into "${buildDir}/n/bin/pe"
1055
}
1056

    
1057
task eenProduct(
1058
  type: Copy,
1059
  dependsOn: ["een_csharpApi", "een_csharpTransform", "een_csharpQuery", "een_csharpValidate"],
1060
  description: "Build Saxon EE for .NET"
1061
) {
1062
  from "${buildDir}/n/saxon-ee-api-${saxonMajorVersion}.${saxonMinorVersion}.xml"
1063
  into "${buildDir}/n/bin/ee"
1064
}
1065

    
1066
task dotNetProducts(
1067
  dependsOn: ["henProduct", "penProduct", "eenProduct"],
1068
  description: "Builds all of the .NET products"
1069
) {
1070
  // nop
1071
}
1072

    
1073
task dotNetInstallers(
1074
  dependsOn: ["henInstaller", "penInstaller", "eenInstaller"],
1075
  description: "Builds all of the .NET installers"
1076
) {
1077
  // nop
1078
}
(6-6/12)