-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
build.gradle
1841 lines (1686 loc) · 70.5 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Paths
import com.github.spotbugs.snom.Confidence
plugins {
id 'base'
id 'application'
id 'java-library'
id 'java-test-fixtures'
id 'maven-publish'
id 'signing'
id 'eclipse'
id 'checkstyle'
id 'jacoco'
id 'jacoco-report-aggregation'
alias(libs.plugins.spotbugs)
alias(libs.plugins.spotless)
alias(libs.plugins.versions)
alias(libs.plugins.launch4j)
alias(libs.plugins.ssh)
}
apply from: 'gradle/utils.gradle'
application {
applicationName = 'OmegaT'
mainClass = 'org.omegat.Main'
}
// Force Java runtime for Gradle on Java 17
def gradleOnJava17OrLater = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)
tasks.named('updateDaemonJvm') {
jvmVersion = JavaVersion.VERSION_17
}
// Define target Java version to compatible.
def javaVersion = 11;
// OmegaT distribution package meta data.
def shortDescription = 'The free translation memory tool'
def distDescription = 'OmegaT is a free and open source multiplatform Computer Assisted Translation tool with' +
' fuzzy matching, translation memory, keyword search, glossaries, and translation leveraging into updated' +
' projects.'
def distAppVendor = 'The OmegaT project'
// Definition of OmegaT versioning
def localPropsFile = file('local.properties')
ext {
omtVersion = loadProperties(file('src/org/omegat/Version.properties'))
if (localPropsFile.file) {
loadProperties(localPropsFile).each { k, v ->
if (!findProperty(k)) {
set(k, v)
}
}
}
providedCoreLibsDir = file('lib/provided/core')
providedModuleLibsDir = file('lib/provided/module')
}
def omtFlavor = omtVersion.beta.empty ? 'standard' : 'latest'
def omtWebsite = 'https://omegat.org'
version = omtVersion.version + getUpdateSuffix(omtVersion.update)
// Flag to detect CI/CD environment
def envIsCi = project.hasProperty('envIsCi') as Boolean
// Definition of bundled JRE file names
def assetDir = findProperty('assetDir') ?: '../'
def macJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_mac_*.tar.gz')
def armMacJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_mac_*.tar.gz')
def linux64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_linux_*.tar.gz')
def linuxArm64JRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_aarch64_linux_*.tar.gz')
def windowsJRE32 = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x86-32_windows_*.zip')
def windowsJRE = fileTree(dir: assetDir, include: 'OpenJDK17U-jre_x64_windows_*.zip')
java {
withSourcesJar()
withJavadocJar()
}
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'jacoco'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}
javadoc {
failOnError = false
options {
jFlags('-Duser.language=en')
addStringOption('locale', 'en_US')
addStringOption('bottom', '<span>Copyright 2000-2023, OmegaT project and contributors</span>')
addStringOption('encoding', 'UTF-8')
addBooleanOption("Xdoclint:none", true)
addBooleanOption('html5', true)
addBooleanOption('frames', false)
addBooleanOption('public', true)
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs.addAll '-Xlint', '-Werror'
}
sourcesJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
spotbugs {
reportLevel = Confidence.valueOf('HIGH')
}
tasks.register('spotbugsMainReport') {
def reportFile = file("build/reports/spotbugs/main.txt")
doLast {
if (reportFile.exists()) {
println()
reportFile.readLines().forEach {
println(it)
}
}
}
group = 'verification'
}
tasks.register('spotbugsTestReport') {
def reportFile = file("build/reports/spotbugs/test.txt")
doLast {
if (reportFile.exists()) {
println()
reportFile.readLines().forEach {
println(it)
}
}
}
group = 'verification'
}
spotbugsMain {
if (envIsCi) {
extraArgs = ['-longBugCodes']
jvmArgs = ['-Duser.language=en']
}
reports {
text.required = envIsCi
html.required = !envIsCi
}
finalizedBy(spotbugsMainReport)
}
spotbugsTest {
if (envIsCi) {
extraArgs = ['-longBugCodes']
jvmArgs = ['-Duser.language=en']
}
reports {
text.required = envIsCi
html.required = !envIsCi
}
finalizedBy(spotbugsTestReport)
}
checkstyle {
toolVersion = libs.versions.checkstyle.get()
}
checkstyleMain.exclude '**/gen/**'
spotless {
enforceCheck false
java {
targetExclude 'src/gen/**'
eclipse().configFile file("${rootDir}/config/spotless/eclipse-formatting.xml")
removeUnusedImports()
}
}
repositories {
mavenCentral()
mavenLocal()
// Sonatype OSSRH snapshots
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test/src'
}
resources {
srcDir 'test/src'
srcDir 'test/data'
}
}
testFixtures {
java {
srcDir 'test/fixtures'
}
}
testAcceptance {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir 'test-acceptance/src'
}
}
testIntegration {
java {
srcDir 'test-integration/src'
}
}
}
configurations {
all
[testRuntime, testCompile]*.exclude group: 'org.languagetool', module: 'language-all'
testIntegrationImplementation.extendsFrom implementation
testAcceptanceImplementation.extendsFrom testImplementation
testAcceptanceRuntime.extendsFrom testRuntime
jaxb
genMac
}
dependencies {
// Libs are provided in the "source" distribution only
if (providedCoreLibsDir.directory) {
api fileTree(dir: providedCoreLibsDir, includes: ['**/slf4j-api-*.jar', '**/jaxb-api-*.jar'])
implementation fileTree(dir: providedCoreLibsDir, include: '**/*.jar', excludes: ['**/slf4j-api-*.jar',
'**/slf4j-jdk14-*.jar', 'language-detector-*.jar', '**/hunspell-*.jar',
'**/groovy*.jar', '**/jaxb-runtime-*.jar'])
runtimeOnly fileTree(dir: providedCoreLibsDir, includes: ['**/slf4j-jdk14-*.jar',
'**/language-detector-*.jar', '**/hunspell-*.jar', '**/groovy*.jar', '**/jaxb-runtime-*.jar'])
} else {
implementation(libs.commons.io)
implementation(libs.commons.lang3)
implementation(libs.commons.validator)
api(libs.slf4j.api)
implementation(libs.slf4j.format.jdk14)
runtimeOnly(libs.slf4j.jdk14)
// jaxb gen compilation
implementation(libs.jaxb.api)
runtimeOnly(libs.jaxb.core)
runtimeOnly(libs.jaxb.runtime)
// macOS integration
implementation(libs.madlonkay.desktopsupport)
// extra locales
implementation(libs.swing.extra.locales)
// stax
implementation(libs.stax2.api)
implementation(libs.woodstox.core)
// Data: inline data URL handler
implementation(libs.url.protocol.handler)
// PDF Filter
implementation(libs.apache.pdfbox)
// Dictionary
implementation(libs.bundles.dictionary)
// Encoding detections
implementation(libs.juniversal.chardet)
// Legacy projects re-hosted on Maven Central
api(libs.omegat.vldocking)
implementation(libs.omegat.htmlparser)
implementation(libs.omegat.gnudiff4j)
implementation(libs.omegat.mnemonics)
// LanguageTool
implementation(libs.languagetool.core) {
exclude module: 'guava'
exclude module: 'language-detector'
exclude group: 'com.google.android'
exclude module: 'hunspell'
}
runtimeOnly(libs.language.detector)
runtimeOnly(libs.dumont.hunspell)
implementation(libs.icu4j)
// Lucene for tokenizers
implementation(libs.bundles.lucene)
// Team project server support
implementation(libs.bundles.jgit)
// For ed25519 and ecdsa support of ssh, java16+ or BC
implementation(libs.bundles.ecdsa)
// For gpg signing
implementation(libs.jgit.bc)
// For subversion
implementation(libs.svnkit) {
exclude module: 'sshd-core'
exclude module: 'sshd-common'
}
// Team project conflict resolution
implementation(libs.madlonkay.supertmxmerge)
// Credentials encryption
implementation(libs.jasypt)
// Groovy used for scripts - needed at implementation for GroovyClassLoader modifications
// Ivy is needed to handle Grape/@Grab dependencies
runtimeOnly(libs.bundles.groovy)
// Javascript used for scripts
implementation(libs.nashorn.core)
// Script editor
implementation(libs.bundles.fifesoft) {
exclude module: 'rhino'
}
implementation(libs.guava)
implementation(libs.jetbrains.annotations)
// JSON parser
implementation(libs.bundles.jackson)
implementation(libs.jetbrains.annotations)
implementation(libs.bundles.caffeine) {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.class, Bundling.EXTERNAL))
}
}
// Platform integration with Windows and macOS
implementation(libs.jna)
implementation(libs.jfa) {
exclude module: 'jna'
}
}
// Test dependencies
testFixturesApi(libs.junit4)
// for http connection test
testFixturesApi(libs.wiremock) {
exclude module: 'guava'
}
testFixturesApi(libs.slf4j.api)
testFixturesImplementation(libs.commons.io)
testFixturesImplementation(libs.omegat.vldocking)
testFixturesImplementation(libs.assertj.swing.junit)
testImplementation(libs.assertj)
testImplementation(libs.bundles.xmlunit)
testImplementation(libs.languagetool.server) {
exclude module: "logback-classic"
}
testRuntimeOnly(libs.slf4j.jdk14)
// JAXB codegen only
jaxb(libs.jaxb.xjc)
// genMac only
genMac(libs.omegat.appbundler)
testAcceptanceImplementation sourceSets.main.output
testAcceptanceImplementation(libs.commons.io)
testAcceptanceImplementation(libs.slf4j.jdk14)
testAcceptanceImplementation(libs.slf4j.format.jdk14)
testAcceptanceImplementation(testFixtures(project.rootProject))
testAcceptanceImplementation(libs.assertj.swing.junit)
testAcceptanceImplementation(libs.bundles.jackson)
testAcceptanceImplementation(project(':aligner'))
testIntegrationImplementation sourceSets.main.output, sourceSets.test.output
testIntegrationImplementation(testFixtures(project.rootProject))
testIntegrationRuntimeOnly(libs.slf4j.jdk14)
jacocoAggregation project(':aligner')
jacocoAggregation project(":machinetranslators:apertium")
jacocoAggregation project(":machinetranslators:belazar")
jacocoAggregation project(":machinetranslators:deepl")
jacocoAggregation project(":machinetranslators:google")
jacocoAggregation project(":machinetranslators:ibmwatson")
jacocoAggregation project(":machinetranslators:mymemory")
jacocoAggregation project(":machinetranslators:yandex")
}
jar {
def omtPlugins = loadProperties(file('Plugins.properties'))
manifest {
attributes('License': 'GNU Public License version 3 or later',
'Implementation-Version': project.version,
'Permissions': 'all-permissions',
'OmegaT-Plugin': 'true',
'OmegaT-Plugins': omtPlugins.plugin,
'Plugin-Author': 'OmegaT team',
'Plugin-Link': 'https://omegat.org',
'Plugin-Version': project.version,
'Main-Class': application.mainClass,
'Class-Path': configurations.runtimeClasspath.collect { "lib/${it.name}" }.join(' '))
ext.pluginAttr = { name, path, category, description ->
attributes('Plugin-Name': name, 'Plugin-Category': category, 'Plugin-Description': description, path)
}
def desc = [:]
omtPlugins.each { key, val ->
if (key.startsWith('plugin.desc')) {
desc[key.split('\\.').last()] = val
} else if (key != 'plugin') {
val.tokenize().each { cls ->
attributes('OmegaT-Plugin': key, cls)
}
}
}
pluginAttr('Dictionary driver[bundle]', 'org/omegat/core/dictionaries/', 'dictionary', desc.dictionary)
pluginAttr('File filters[bundle]', 'org/omegat/filters2/', 'filter', desc.filters2)
pluginAttr('XML filters[bundle]', 'org/omegat/filters3/', 'filter', desc.filters3)
pluginAttr('New XML filters[bundle]', 'org/omegat/filters4/', 'filter', desc.filters4)
pluginAttr('Tokenizers[bundle]', 'org/omegat/tokenizer/', 'tokenizer', desc.tokenizer)
pluginAttr('Themes [bundle]', 'org/omegat/gui/theme/', 'theme', desc.theme)
pluginAttr('Scripting engine', 'org/omegat/gui/script/', 'miscellaneous', desc.script)
pluginAttr('GUI extensions', 'org/omegat/util/gui/', 'miscellaneous', desc.guiutil)
pluginAttr('Local external search', 'org/omegat/externalfinder/', 'miscellaneous', desc.externalfinder)
pluginAttr('Repository connector', 'org/omegat/core/team2/impl/', 'repository', desc.repository)
}
// Don't include extra stuff like version number in JAR name
archiveFileName.set("${archiveBaseName.get()}.${archiveExtension.get()}")
}
def omegatJarFilename = jar.archiveFileName.get()
project(":machinetranslators") {jar.enabled = false}
project(":spellchecker") {jar.enabled = false}
/*
* Configuration of launch4j java launcher.
* OmegaT uses it as launcher for windows.
*/
launch4j {
libraryDir = "." // assume OmegaT.jar is located as same folder as OmegaT.exe
dontWrapJar = true
downloadUrl = 'https://adoptium.net/'
supportUrl = 'https://omegat.org/support'
icon = "${projectDir}/images/OmegaT.ico"
errTitle = 'OmegaT'
headerType = 'gui'
jreMinVersion = '11.0'
jreMaxVersion = '21.1'
copyConfigurable = [] // hack: don't copy dependencies to $libraryDir
// assume bundled JRE in jre/, fallback to JAVA_HOME env then PATH
bundledJrePath = 'jre;%JAVA_HOME%;%PATH%'
requires64Bit = false // support 32bit distribution
copyright = "The GNU General Public License, Version 3.0"
version = omtVersion.version
textVersion = omtVersion.version
companyName = distAppVendor
fileDescription = shortDescription
restartOnCrash = false
stayAlive = false
priority = 'normal'
}
tasks.register('manualZips') {
description = 'Build ZIP manuals to bundle into application. Requires container runtime.'
group = 'documentation'
}
tasks.register('manualPdfs') {
description = 'Build PDF manuals for all languages. Requires container runtime.'
group = 'documentation'
}
tasks.register('manualHtmls') {
description = 'Build HTML manuals and zip for all languages. Requires container runtime.'
group = 'documentation'
}
tasks.register('genDocIndex', Copy) {
def docPropsFiles = fileTree(dir: 'doc_src', include: '*/version*.properties').findAll {
file("${it.parent}/OmegaTUsersManual_xinclude full.xml").file }
def langNameExceptions = loadProperties(file('doc_src/lang_exceptions.properties'))
def langInfos = docPropsFiles.toSorted{ it.parentFile.name }.collect { props ->
def docVersion = loadProperties(props).version
['code': props.parentFile.name, 'nomanual': false, 'version': docVersion,
'name': langNameExceptions[props.parentFile.name] ?:
Locale.forLanguageTag(props.parentFile.name.replace('_', '-')).getDisplayName(),
'status': docVersion == omtVersion.version ? 'up-to-date' : 'out-of-date'] }
def inputTemplate = file('doc_src/index_template.html')
def outputIndex = layout.buildDirectory.file("docs/manual/index.html").get().asFile
description = 'Generate the docs index file'
inputs.files docPropsFiles, inputTemplate
outputs.files file(outputIndex)
from inputTemplate
into outputIndex.parent
rename('index_template.html', 'index.html')
expand('languages': langInfos)
filteringCharset = 'UTF-8'
dependsOn manualHtmls
group = 'documentation'
}
tasks.register('webManual', Sync) {
group = 'documentation'
description = 'Sync the HTML manual files'
dependsOn manualHtmls, genDocIndex
destinationDir file(layout.buildDirectory.file("docs/htdocs"))
from file(layout.buildDirectory.file("docs/manual"))
from('release') {
include 'doc-license.txt'
}
}
ext.manualIndexXmls = fileTree(dir: 'doc_src', include: '**/OmegaTUsersManual_xinclude full.xml')
manualIndexXmls.each { xml ->
def lang = xml.parentFile.name
def pdfTaskName = "manualPdf${lang.capitalize()}"
tasks.register(pdfTaskName, Exec) {
inputs.files fileTree(dir: "doc_src/${lang}", includes: ['**/*.xml', 'images/*.png'],
excludes: ['xhtml5/*', 'index.xml'])
outputs.files layout.buildDirectory.file("docs/pdfs/OmegaT_documentation_${lang}.PDF")
onlyIf {
conditions([exePresent('docker') || exePresent('nerdctl'), 'Docker or nerdctl is not installed'],
[!project.hasProperty('forceSkipDocumentBuild'), 'Specified forceSkipDocumentBuild property'])
}
workingDir = 'doc_src'
commandLine './docgen', "-Dlanguage=${lang}", "-Dtarget=../build/docs/pdfs", 'pdf'
doLast {
delete fileTree(dir: "doc_src/${lang}", includes: ['pdf/*', 'index.xml'])
}
}
manualPdfs.dependsOn pdfTaskName
def htmlTaskName = "manualHtml${lang.capitalize()}"
tasks.register(htmlTaskName, Exec) {
inputs.files fileTree(dir: "doc_src/${lang}", includes: ['**/*.xml', 'images/*.png'],
excludes: ['xhtml5/*', 'index.xml'])
outputs.files fileTree(dir: layout.buildDirectory.file("docs/manual/${lang}/"),
includes: ['*.html', 'OmegaT.css', 'images/*.png', '_wh/**/*.js', '_wh/wh.css'])
onlyIf {
conditions([exePresent('docker') || exePresent('nerdctl'), 'Docker or nerdctl is not installed'],
[!project.hasProperty('forceSkipDocumentBuild'), 'Specified forceSkipDocumentBuild property'])
}
workingDir = 'doc_src'
commandLine './docgen', "-Dlanguage=${lang}", "-Dtarget=../build/docs/manual/${lang}", 'html5'
}
manualHtmls.dependsOn htmlTaskName
def zipTaskName="manualZip${lang.capitalize()}"
def versionProperties = loadProperties(file("doc_src/${lang}/version_${lang}.properties"))
if (lang.equals("en") || versionProperties.version.equals(omtVersion.version)) {
tasks.register(zipTaskName, Zip) {
from fileTree(dir: layout.buildDirectory.file("docs/manual/${lang}"))
exclude 'docs/manual/index.html'
from fileTree(dir: "doc_src/${lang}", include: '**/version*.properties')
archiveFileName = "${lang}.zip"
destinationDirectory = file("${buildDir}/docs/manuals/")
}
manualZips.dependsOn zipTaskName
tasks.getByName(zipTaskName).dependsOn htmlTaskName
}
}
tasks.register('firstSteps') {
description = 'Build First pages for all languages at docs/greetings/. Requires Docker.'
group = 'documentation'
}
tasks.register('updateManuals') {
group = 'documentation'
description = 'Update Instant Start guides and HTML manuals.'
dependsOn manualHtmls, firstSteps, genDocIndex
}
ext.firstStepsXmls = fileTree(dir: 'doc_src', include: '**/First_Steps.xml')
firstStepsXmls.each { xml ->
def lang = xml.parentFile.name
def taskName = "firstSteps${lang.capitalize()}"
tasks.register(taskName, Exec) {
inputs.files fileTree(dir: "doc_src/${lang}", include: 'First_Steps.xml')
outputs.files fileTree(dir: layout.buildDirectory.file('docs/greetings/'),
includes: ["${lang}/first_steps.html", "${lang}/OmegaT.css"])
onlyIf {
conditions([exePresent('docker') || exePresent('nerdctl'), 'Docker or nerdctl is not installed'],
[!project.hasProperty('forceSkipDocumentBuild'), 'Specified forceSkipDocumentBuild property'])
}
workingDir = 'doc_src'
commandLine './docgen', "-Dlanguage=${lang}", "-Dtarget=../build/docs/greetings/${lang}", 'first-steps'
}
firstSteps.dependsOn taskName
}
ext.instantStartXmls = fileTree(dir: 'doc_src', include: '**/InstantStartGuide.xml')
instantStartXmls.each { xml ->
def lang = xml.parentFile.name
def taskName = "instantStartGuide${lang.capitalize()}"
tasks.register(taskName, Exec) {
inputs.files fileTree(dir: "doc_src/${lang}", includes: ['InstantStartGuide.xml', '**/InstantGuide*png'])
outputs.files fileTree(dir: layout.buildDirectory.file('docs/greetings/'),
includes: ["${lang}/first_steps.html", "${lang}/images/InstantGuide*png", "${lang}/OmegaT.css"])
onlyIf {
conditions([exePresent('docker') || exePresent('nerdctl'), 'Docker or nerdctl is not installed'],
[!project.hasProperty('forceSkipDocumentBuild'), 'Specified forceSkipDocumentBuild property'])
}
workingDir = 'doc_src'
commandLine './docgen', "-Dlanguage=${lang}", "-Dtarget=../build/docs/greetings/${lang}", 'instant-start'
}
firstSteps.dependsOn taskName
}
tasks.register('genMac') {
def appbundlerClasspath = configurations.genMac.asPath
def outDir = layout.buildDirectory.file("appbundler").get().toString()
def appName = application.applicationName
def appClass = application.mainClass.get()
description = 'Generate the Mac .app skeleton. Depends AppBundler (https://github.com/TheInfiniteKind/appbundler)'
outputs.dir layout.buildDirectory.file("appbundler")
doLast {
ant.taskdef(name: 'appbundler',
classname: 'com.oracle.appbundler.AppBundlerTask',
classpath: appbundlerClasspath)
ant.appbundler(outputdirectory: outDir,
name: appName,
displayname: appName,
executablename: appName,
identifier: 'org.omegat.OmegaT',
icon: 'images/OmegaT.icns',
version: '${version}',
jvmrequired: '${jvmRequired}',
shortversion: '${version}',
mainclassname: appClass) {
option(value: "-Xdock:name=${appName}")
option(value: "-Dapple.awt.application.name=${appName}")
option(value: "-Dapple.awt.application.appearance=system")
argument(value: '--config-file=${configfile}')
bundledocument(extensions: 'project',
name: "${appName} Project",
role: 'editor',
icon: 'images/OmegaT.icns')
bundledocument(extensions: '*',
name: 'All Files',
role: 'none')
plistentry(key: 'JVMRuntime', value: 'jre.bundle')
}
}
}
distributions {
main {
contents {
// docs targets
// /docs
// ...../greetings/<lang>/first_steps.html
// ...../manuals/<lang>.zip
from('release') {
into 'docs'
include 'doc-license.txt'
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
}
from('release') {
// ** Caution!! **
// 'readme*.txt' and 'changes.txt' are expected
// in releases/win32-specific/OmegaT.iss
// 'contributors.txt' and 'libraries.txt' are expected
// in org.omegat.gui.dialogs.AboutDialog#getContributors
// and org.omegat.gui.dialogs.AboutDialog#getLibraries
exclude 'doc-license.txt'
include '*.txt', '*.html'
filter(ReplaceTokens, tokens: [
TRANSLATION_NOTICE: ''
])
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
}
project.tasks.matching {it.name.startsWith('firstSteps') || it.name.startsWith('instantStart')}.forEach {
from(it.outputs) { into 'docs/greetings' }
}
project.tasks.matching {it.name.startsWith('manualZip')}.forEach {
from(it.outputs) { into 'docs/manuals' }
}
from('scripts') {
into 'scripts'
}
from('images') {
into 'images'
}
from('release/plugins-specific') {
into 'plugins'
}
from('release/linux-specific') {
filter ReplaceTokens, tokens: [
VERSION_NUMBER_SUBST: project.version,
JAR_SUBST : omegatJarFilename
]
fileMode 0755
}
from('release/win32-specific') {
include 'OmegaT.bat'
filter(ReplaceTokens, tokens: [
JAR_SUBST : omegatJarFilename
])
}
from('lib/licenses') {
into 'lib'
}
// system core plugins into modules
into('modules') {
from(subprojects.collect {it.tasks.withType(Jar)})
from('releases/modules-specific')
}
eachFile {
// Move main JAR up one level from lib.
if (it.name == omegatJarFilename) {
it.relativePath = it.relativePath.parent.parent.append(true, omegatJarFilename)
}
}
}
distZip.archiveFileName.set("${application.applicationName}_${version}${omtVersion.beta}_Without_JRE.zip")
}
source {
contents {
from(rootDir) {
include 'config/**', 'ci/iscc', 'ci/osslsigncode', 'images/**', 'lib/**', 'release/**',
'src/**/*.java', 'test/**','test-acceptance/**', 'test-integration/**', 'doc_src/**',
'docs_devel/**', 'scripts/**',
'gradle/**', 'gradle*', 'build.gradle', 'settings.gradle', 'README.md', '*.properties',
'tipoftheday/**', 'machinetranslators/**', 'scriptengine/**', 'LICENSE', 'compose.yml',
'aligner/**', 'language-modules/**', 'spellchecker/**', 'theme/**', '.checkstyle'
exclude '**/build/**', 'doc_src/**/pdf/**', 'doc_src/**/xhtml5/**', 'local.properties', '**/out/**'
}
from(processResources) {
into('src')
}
into('lib/provided/core') {
from configurations.runtimeClasspath
}
into('lib/provided/module') {
// collect project runtime dependencies in all subprojects and sourceSets
from {subprojects.findAll { it.getSubprojects().isEmpty()}
.collect { it.configurations.matching { it.name.endsWith('untimeClasspath')
&& !it.name.startsWith('test') && !it.name.startsWith('jaxb')
} }
}
}
}
sourceDistZip.archiveFileName.set(
"${application.applicationName}_${project.version}${omtVersion.beta}_Source.zip")
}
}
def hunspellJar = configurations.runtimeClasspath.files.find {
it.name.startsWith('hunspell')
}
tasks.register('hunspellJarSignedContents', Sync) {
onlyIf {
// Set this in e.g. local.properties
conditions([project.hasProperty('macCodesignIdentity'), 'Code signing property not set'],
[exePresent('codesign'), 'codesign command is not present in system.'])
}
from zipTree(hunspellJar)
destinationDir file(layout.buildDirectory.file("hunspell"))
doLast {
def dylibs = fileTree(dir: destinationDir, include: '**/*.dylib').files
exec {
commandLine('codesign', '--deep', '--force',
'--sign', project.property('macCodesignIdentity'),
'--timestamp',
'--options', 'runtime',
'--entitlements', file('release/mac-specific/java.entitlements'),
*dylibs.toList())
}
}
}
tasks.register('hunspellSignedJar', Jar) {
from hunspellJarSignedContents.outputs
archiveFileName.set(hunspellJar.name)
}
tasks.register('mac') {
description = 'Build the Mac distributions.'
group = 'omegat distribution'
}
ext.makeMacTask = { args ->
def installTaskName = 'install' + args.name.capitalize() + "Dist"
def signedInstallTaskName = 'install' + args.name.capitalize() + "SignedDist"
def distZipTaskName = args.name + "DistZip"
def signedZipTaskName = args.name + "Signed"
def notarizeTaskName = args.name + "Notarize"
def stapledNotarizedDistZipTaskName = args.name + "StapledNotarized"
tasks.register(distZipTaskName, Zip) {
description = "Create Mac distribution for ${args.name}"
// mac specific contents
from(genMac.outputs) {
exclude '**/MacOS/OmegaT', '**/Info.plist', '**/java.entitlements'
}
from(genMac.outputs) {
include '**/MacOS/OmegaT'
fileMode 0755
}
from(genMac.outputs) {
include '**/Info.plist'
expand(version: project.version,
jvmRequired: '11+',
// when bundled JRE, path 'jre.bundle', otherwise 'default'
jreRuntime: args.jrePath ? 'jre.bundle' : 'default',
// $APP_ROOT is expanded at runtime by the launcher binary
configfile: '$APP_ROOT/Contents/Resources/Configuration.properties')
}
into('OmegaT.app/Contents/Java') {
with distributions.main.contents
exclude '*.sh', '*.kaptn', 'OmegaT', 'OmegaT.bat', 'omegat.desktop', '*.exe'
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName.set("${application.applicationName}_${project.version}${omtVersion.beta}_${args.suffix}.zip")
if (args.jrePath && !args.jrePath.empty) {
from(tarTree(args.jrePath.singleFile)) {
into 'OmegaT.app/Contents/PlugIns'
includeEmptyDirs = false
eachFile {
replaceRelativePathSegment(it, /jdk.*-jre/, 'jre.bundle')
}
}
}
outputs.upToDateWhen {
// detect up-to-date when OmegaT.jar exists and newer than libs/OmegaT.jar
def f1 = base.distsDirectory.file(archiveFileName).get().asFile
def f2 = base.libsDirectory.file('OmegaT.jar').get().asFile
f1.exists() && f2.exists() && f1.lastModified() > f2.lastModified()
}
onlyIf {
condition(!args.jrePath || !args.jrePath.empty, 'JRE not found')
}
group = 'omegat distribution'
}
mac.dependsOn distZipTaskName
assemble.dependsOn distZipTaskName
tasks.register(installTaskName, Sync) {
description = 'Build a Mac distribution.'
onlyIf {
condition(!args.jrePath || !args.jrePath.empty, 'JRE not found')
}
// mac specific contents
from(genMac.outputs) {
exclude '**/MacOS/OmegaT', '**/Info.plist', '**/java.entitlements'
}
from(genMac.outputs) {
include '**/MacOS/OmegaT'
fileMode 0755
}
from(genMac.outputs) {
include '**/Info.plist'
expand(version: project.version,
jvmRequired: '11+',
// $APP_ROOT is expanded at runtime by the launcher binary
configfile: '$APP_ROOT/Contents/Resources/Configuration.properties')
}
into('OmegaT.app/Contents/Java') {
with distributions.main.contents
exclude '*.sh', '*.kaptn', 'OmegaT', 'OmegaT.bat', 'omegat.desktop', '*.exe'
}
if (args.jrePath && !args.jrePath.empty) {
from(tarTree(args.jrePath.singleFile)) {
into 'OmegaT.app/Contents/PlugIns'
includeEmptyDirs = false
eachFile {
replaceRelativePathSegment(it, /jdk.*-jre/, 'jre.bundle')
}
}
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
destinationDir file(layout.buildDirectory.file("install/${application.applicationName}-${args.suffix}"))
outputs.upToDateWhen {
// detect up-to-date when OmegaT.jar exists and newer than libs/OmegaT.jar
def f1 = file("$destinationDir/OmegaT.app/Contents/Java/OmegaT.jar")
def f2 = base.libsDirectory.file('OmegaT.jar').get().asFile
f1.exists() && f2.exists() && f1.lastModified() > f2.lastModified()
}
doFirst {
delete "$destinationDir/OmegaT.app/Contents/PlugIns/jre.bundle"
}
group = 'distribution'
dependsOn hunspellSignedJar
}
tasks.register(signedInstallTaskName, Sync) {
description = 'Build a signed Mac distribution. Requires an Apple Developer Account.'
onlyIf {
// Set this in e.g. local.properties
conditions([project.hasProperty('macCodesignIdentity'), 'Code signing property not set'],
[args.jrePath && !args.jrePath.empty, 'JRE not found'],
[exePresent('codesign'), 'codesign command is not present in system.'])
}
from(tasks.getByName(installTaskName).outputs)
from(hunspellSignedJar.outputs) {
into 'OmegaT.app/Contents/Java/lib'
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
destinationDir file(layout.buildDirectory.file("install/${application.applicationName}-${args.suffix}_Signed"))
doFirst {
delete "$destinationDir/OmegaT.app/Contents/PlugIns/jre.bundle"
}
doLast {
exec {
commandLine 'codesign', '--deep', '--force',
'--sign', project.property('macCodesignIdentity'),
'--timestamp',
'--options', 'runtime',
'--entitlements', file('release/mac-specific/java.entitlements'),
file("${destinationDir}/OmegaT.app")
}
}
group = 'distribution'
dependsOn hunspellSignedJar
}
tasks.register(signedZipTaskName, Zip) {
def zipRoot = "${application.applicationName}_${project.version}${omtVersion.beta}_${args.suffix}_Signed"
from tasks.getByName(signedInstallTaskName).outputs
into zipRoot
archiveFileName.set("${zipRoot}.zip")
group = 'omegat distribution'
dependsOn signedInstallTaskName
}
tasks.register(notarizeTaskName, Exec) {
onlyIf {
conditions([project.hasProperty('macNotarizationUsername'), 'Username for notarization not set'],
[exePresent('xcrun'), 'XCode is not present in system.'])
}
inputs.files tasks.getByName(signedZipTaskName).outputs.files
doLast {
exec {
// Assuming setup per instructions at
// https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution/customizing_the_notarization_workflow#3087734
commandLine 'xcrun', 'altool', '--notarize-app',
'--primary-bundle-id', "org.omegat.$version",
'--username', project.property('macNotarizationUsername'),
'--password', '@keychain:AC_PASSWORD',
'--file', inputs.files.singleFile
}
}
dependsOn signedZipTaskName
}
tasks.register(stapledNotarizedDistZipTaskName, Zip) {
def zipRoot = "${application.applicationName}_${project.version}${omtVersion.beta}_${args.suffix}_Notarized"
from tasks.getByName(signedInstallTaskName).outputs
into zipRoot
onlyIf {
condition(exePresent('xcrun'), 'XCode is not present in system.')
}
doFirst {
if (args.name.equals("mac")) {
exec {
commandLine 'xcrun', 'stapler', 'staple', "${macInstallSignedDist.destinationDir}/OmegaT.app"
}
} else {
exec {
commandLine 'xcrun', 'stapler', 'staple', "${armMacInstallSignedDist.destinationDir}/OmegaT.app"
}
}
}
archiveFileName.set("${zipRoot}.zip")
dependsOn signedInstallTaskName
}
}
makeMacTask(name: 'macX64', suffix: 'Mac_x64', jrePath: macJRE)
makeMacTask(name: 'macArm', suffix: 'Mac_arm', jrePath: armMacJRE)
tasks.register('linux') {
description = 'Build the Linux distributions.'
group = 'omegat distribution'
}