forked from omegat-org/omegat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
887 lines (806 loc) · 28.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
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'application'
id 'maven-publish'
id 'eclipse'
id 'findbugs'
id 'checkstyle'
id 'de.gliderpilot.jnlp' version '1.2.2'
id 'com.jfrog.bintray' version '1.7.3'
id 'org.hidetake.ssh' version '2.9.0'
// Uncomment and run `dependencyUpdates` task to check for updates to dependencies
//id 'com.github.ben-manes.versions' version '0.15.0'
}
applicationName = 'OmegaT'
mainClassName = 'org.omegat.Main'
ext {
javaVersion = '1.8'
omtVersion = loadProperties file('src/org/omegat/Version.properties')
envIsCi = project.hasProperty('envIsCi')
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
version = omtVersion.version + getUpdateSuffix(omtVersion.update)
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test/src'
}
resources {
srcDir 'test/src'
srcDir 'test/data'
}
}
testIntegration {
java {
srcDir 'test-integration/src'
}
}
}
repositories {
jcenter()
maven {
url 'http://dl.bintray.com/omegat-org/maven'
}
}
task webstartDocsJar(type: Jar) {
description = 'Bundle documents for Java WebStart.'
baseName = 'docs'
from('release') {
include 'changes.txt', 'OmegaT-license.txt'
into 'docs'
}
from('docs') {
include '**/instantStartGuideNoTOC.html', '**/OmegaT.css', '**/images/InstantGuide_*.png'
into 'docs'
}
}
configurations {
all {
// Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/813/
exclude group: 'org.apache.lucene', module: 'lucene-core'
}
[testRuntime, testCompile]*.exclude group: 'org.languagetool', module: 'language-all'
}
ext {
providedLibsDir = file('lib/provided')
languageToolVersion = '3.5'
luceneVersion = '5.2.1'
}
dependencies {
// Libs are provided in the "source" distribution only
if (providedLibsDir.directory) {
compile fileTree(dir: providedLibsDir, include: '**/*.jar')
} else {
compile 'commons-io:commons-io:2.5'
compile 'commons-lang:commons-lang:2.6'
compile 'org.slf4j:slf4j-jdk14:1.7.25'
// PDF Filter
compile 'org.apache.pdfbox:pdfbox:2.0.7'
// Aligner
compile 'net.loomchild:maligna:3.0.0'
// Dictionary
compile 'org.dict.zip:dictzip-lib:0.8.2'
compile 'com.github.takawitter:trie4j:0.9.6'
// Encoding dectection
compile 'com.github.albfernandez:juniversalchardet:2.0.0'
// Legacy projects re-hosted on GitHub + Bintray
compile 'org.omegat:vldocking:3.0.5'
compile 'org.omegat:htmlparser:1.5'
compile 'org.omegat:gnudiff4j:1.15'
compile 'org.omegat:lib-mnemonics:1.0'
compile 'org.omegat:jmyspell-core:1.0.0-beta-2'
// LanguageTool
compile "org.languagetool:languagetool-core:${languageToolVersion}"
runtime("org.languagetool:language-all:${languageToolVersion}") {
// Temporary exclusion; see https://sourceforge.net/p/omegat/bugs/814/
exclude module: 'lucene-gosen-ipadic'
}
runtime 'org.omegat.lucene:lucene-gosen:5.0.0:ipadic'
runtime 'org.languagetool:hunspell-native-libs:2.9'
// Lucene for tokenizers
// Temporary use of custom lucene-core; see https://sourceforge.net/p/omegat/bugs/813/
compile "org.omegat.lucene:lucene-core:${luceneVersion}-1"
compile "org.apache.lucene:lucene-analyzers-common:${luceneVersion}"
compile "org.apache.lucene:lucene-analyzers-kuromoji:${luceneVersion}"
compile "org.apache.lucene:lucene-analyzers-smartcn:${luceneVersion}"
compile "org.apache.lucene:lucene-analyzers-stempel:${luceneVersion}"
// Team project server support
compile 'org.eclipse.jgit:org.eclipse.jgit:4.8.0.201706111038-r'
compile 'com.jcraft:jsch.agentproxy.jsch:0.0.9'
// Specify the following two here just to make sure all jsch.agentproxy libs are the same version.
compile 'com.jcraft:jsch.agentproxy.connector-factory:0.0.9'
compile 'com.jcraft:jsch.agentproxy.svnkit-trilead-ssh2:0.0.9'
compile 'org.tmatesoft.svnkit:svnkit:1.8.14'
// Team project conflict resolution
compile 'org.madlonkay.supertmxmerge:supertmxmerge:2.0.1'
// Credentials encryption
compile 'org.jasypt:jasypt:1.9.2'
// Groovy used for (runtime) scripts, tests only
runtime 'org.codehaus.groovy:groovy-all:2.4.12'
// Script editor
compile 'com.fifesoft:rsyntaxtextarea:2.5.8'
compile 'com.fifesoft:rstaui:2.5.7'
compile ('com.fifesoft:languagesupport:2.5.8') {
exclude module: 'rhino'
}
compile 'com.fifesoft:autocomplete:2.5.8'
}
// Test dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.xmlunit:xmlunit-legacy:2.4.0'
testCompile("org.languagetool:languagetool-server:${languageToolVersion}") {
exclude group: 'org.slf4j'
}
// LanguageTool unit tests exercise these languages
['be', 'en', 'fr'].each {
testCompile "org.languagetool:language-${it}:${languageToolVersion}"
}
testRuntime "org.languagetool:language-pl:${languageToolVersion}"
// WebStart-only
jnlp webstartDocsJar.outputs.files
testIntegrationCompile sourceSets.main.output, sourceSets.test.output, configurations.compile
}
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-Plugins': omtPlugins.plugin,
'OmegaT-Plugin': 'true',
'Main-Class': mainClassName)
omtPlugins.each { key, val ->
if (key != 'plugin') {
val.tokenize().each { cls ->
attributes('OmegaT-Plugin': key, cls)
}
}
}
}
doFirst {
// Set this attribute at execution time because accessing configurations.runtime as an
// instance forces configuration blocks to be evaluated and this causes problems like
// introducing ordering dependencies on various definitions in this file.
manifest.attributes 'Class-Path': configurations.runtime.collect { "lib/${it.name}" }.join(' ')
}
// Don't include extra stuff like version number in JAR name
archiveName = "${jar.baseName}.${jar.extension}"
}
ext {
assetDir = findProperty('assetDir') ?: '../'
macExecutable = file("${assetDir}/JavaAppLauncher")
macJRE = file("${assetDir}/jre-mac-root")
macDistEnabled = macExecutable.file && macJRE.directory
linuxJRE = file("${assetDir}/jre-linux")
linux64JRE = file("${assetDir}/jre-linux-64")
windowsJRE = file("${assetDir}/jre")
windowsJRE64 = file("${assetDir}/jre-64")
}
task genDocIndex(type: Copy) {
description = 'Generate the docs index file'
def docPropsFiles = fileTree(dir: 'docs', include: '*/version.properties')
inputs.files docPropsFiles
from('doc_src') {
include 'index_template.html'
}
into 'docs'
rename('index_template.html', 'index.html')
doFirst {
def langNameExceptions = loadProperties file('doc_src/lang_exceptions.properties')
def langInfos = docPropsFiles.collect { props ->
def code = props.parentFile.name
def locale = Locale.forLanguageTag(code.replace('_', '-'))
def name = langNameExceptions[code] ?: locale.getDisplayName(locale)
def docVersion = loadProperties(props).version
def status = docVersion == omtVersion.version ? 'up-to-date' : 'out-of-date'
['code': code, 'name': name, 'version': docVersion, 'status': status]
}
expand('languages': langInfos)
filteringCharset = 'UTF-8'
}
}
task webManual(type: Sync) {
description = 'Generate the HTML manual'
dependsOn genDocIndex
destinationDir = file("${buildDir}/docs/manual")
from 'docs'
from('release') {
include 'doc-license.txt'
}
}
distributions {
main {
contents {
from('docs') {
into 'docs'
}
from(genDocIndex.outputs) {
include 'index.html'
}
from('release') {
into 'docs'
include 'changes.txt', 'doc-license.txt', 'OmegaT-license.txt', 'contributors.txt'
}
from('scripts') {
into 'scripts'
}
from('images') {
into 'images'
}
from('release') {
include '*.txt', '*.html'
exclude 'readme.txt'
}
from('release') {
include 'readme.txt'
expand(translationNotice: '')
}
from('release/plugins-specific') {
into 'plugins'
}
from('release/linux-specific') {
filter(ReplaceTokens, tokens:
['VERSION_NUMBER_SUBST': project.version,
'JAR_SUBST': jar.archiveName])
fileMode 0755
}
from('release/win32-specific') {
include 'OmegaT.bat'
filter(ReplaceTokens, tokens: ['JAR_SUBST': jar.archiveName])
}
from('lib/licenses') {
into 'lib'
}
eachFile {
// Move main JAR up one level from lib.
if (it.name == jar.archiveName) {
it.relativePath = it.relativePath.parent.parent.append(true, jar.archiveName)
}
}
}
distZip.archiveName = "${applicationName}_${version}${omtVersion.beta}_Without_JRE.zip"
}
source {
contents {
from(rootDir) {
include 'docs/**', 'images/**', 'lib/**', 'release/**',
'src/**', 'test/**', 'doc_src/**', 'docs_devel/**', 'scripts/**',
'gradle/**', 'gradlew*', '*.gradle', 'README.md', '*.properties'
exclude '**/build/**', 'doc_src/**/pdf/**'
}
into('lib/provided') {
from configurations.runtime
}
}
sourceDistZip.archiveName = "${applicationName}_${version}${omtVersion.beta}_Source.zip"
}
if (macDistEnabled) {
mac {
contents {
from('release/mac-specific') {
include '**/Info.plist'
expand(version: project.version,
configfile: '$APP_ROOT/Contents/Resources/Configuration.properties')
}
from('release/mac-specific') {
exclude '**/Info.plist'
}
into('OmegaT.app/Contents/Java') {
with main.contents
exclude '*.sh', '*.kaptn', 'OmegaT', 'OmegaT.bat'
}
from(macExecutable) {
into 'OmegaT.app/Contents/MacOS'
fileMode 0755
}
from(macJRE) {
into 'OmegaT.app/Contents/PlugIns/jre.bundle'
fileMode 0755
}
}
macDistZip.archiveName = "${applicationName}_${version}${omtVersion.beta}_Mac.zip"
}
}
[linux: linuxJRE, linux64: linux64JRE].each { distName, jrePath ->
create(distName) {
contents {
with main.contents
exclude 'OmegaT.bat'
from(jrePath) {
into 'jre'
fileMode 0755
}
}
}
}
l10nMinimal {
contents {
from 'release/l10n-project'
from('doc_src') {
include 'en/InstantStartGuide.xml',
'en/images/InstantGuide_1.png',
'en/images/InstantGuide_2.png'
into 'source/doc_src'
}
from('src') {
include 'org/omegat/Bundle.properties'
into 'source/src'
}
from('release') {
include 'win32-specific/CustomMessages.ini'
into 'source/release'
}
from('scripts') {
include 'properties/check_rules.properties',
'properties/spellcheck.properties',
'properties/svn_cleanup_selected.properties',
'properties/search_replace.properties',
'properties/replace_strip_tags.properties',
'properties/strip_bidi_marks.properties',
'properties/nbsp.properties',
'extract_text_content.properties'
into 'source/scripts'
}
from('release') {
include 'mac-specific/OmegaT.app/Contents/Resources/en.lproj/Localizable.strings'
into 'source/release'
}
from('release') {
include 'readme.txt'
into 'source'
expand(translationNotice: 'This translation is the work of [insert your name], copyright© [insert year].')
rename '.txt$', '.utf8'
}
}
l10nMinimalDistZip.archiveName = "${applicationName}_${version}${omtVersion.beta}_L10N_Minimal.zip"
}
l10nFull {
contents {
with l10nMinimal.contents
from('doc_src') {
include 'en/**'
exclude 'en/html/**', 'en/pdf/**'
into 'source/doc_src'
}
}
l10nFullDistZip.archiveName = "${applicationName}_${version}${omtVersion.beta}_L10N_Full.zip"
}
}
if (macDistEnabled) {
task installMacSignedDist(type: Sync) {
onlyIf {
// Set this in e.g. gradle.properties
project.hasProperty('codesignIdentity')
}
with distributions.mac.contents
destinationDir = file("${buildDir}/install/${applicationName}-macSigned")
doLast {
exec {
commandLine 'codesign', '--deep', '-s', project.property('codesignIdentity'), file("${destinationDir}/OmegaT.app")
}
}
}
task macSignedDistZip(type: Zip) {
def zipRoot = "${applicationName}_${version}${omtVersion.beta}_Mac_Signed"
from(installMacSignedDist.outputs) {
into zipRoot
}
archiveName = "${zipRoot}.zip"
}
task mac(dependsOn: [macDistZip, macSignedDistZip]) {
description = 'Build the Mac distributions.'
}
}
task linux(dependsOn: [linuxDistTar, linux64DistTar]) {
description = 'Build the Linux distributions.'
}
[(linuxDistTar): linuxJRE, (linux64DistTar): linux64JRE].each { task, requirement ->
task.onlyIf {
requirement.directory
}
def suffix = task.name.contains('64') ? 'Linux_64' : 'Linux'
task.archiveName = "${applicationName}_${version}${omtVersion.beta}_${suffix}.tar.bz2"
task.compression = Compression.BZIP2
task.extension = 'tar.bz2'
}
task l10n(dependsOn: [l10nMinimalDistZip, l10nFullDistZip]) {
description = 'Build the L10N distributions.'
}
// We bundle our startup scripts separately, so disable startScripts.
startScripts.enabled = false
// installDist insists on installing a script. Trick it with a dummy script.
installDist.doFirst {
startScripts.outputDir.mkdirs()
file("${startScripts.outputDir}/${applicationName}").createNewFile()
if (destinationDir.directory) {
file("${destinationDir}/bin").mkdirs()
}
}
// Delete dummy afterwards.
installDist.doLast {
delete "${destinationDir}/bin"
delete startScripts.outputDir
}
ext.haveInnoSetup = {
try {
def findIscc = 'where iscc'.execute()
findIscc.waitForProcessOutput()
return findIscc.exitValue() == 0
} catch (any) {
return false
}
}
// Read in all our custom messages and massage them for inclusion in the .iss
ext.getInnoSetupCustomMessages = {
// Don't include languages that InnoSetup doesn't have strings for
def blacklist = ['cy', 'ia']
def iniFiles = fileTree(dir: 'release/win32-specific', include: 'CustomMessages*.ini')
def result = new StringBuilder()
iniFiles.each { f ->
def match = f.name =~ /CustomMessages_?([^\.]*).ini/
if (match) {
def lang = match.group(1)
if (!blacklist.contains(lang)) {
result << f.text.replaceAll(/(?m)^([^=]+)/) {
lang.empty ? it[0] : "${lang}.${it[0]}"
}
result << System.lineSeparator()
}
}
}
return result.toString()
}
task win {
description = 'Build the Windows distributions.'
}
ext.makeWinTask = { args ->
task(type: Sync, args.name) {
description = "Create a Windows installer for ${args.name} distro. " +
'Requires Inno Setup (http://www.jrsoftware.org/isinfo.php).'
with distributions.main.contents
from ('release/win32-specific') {
include 'OmegaT.exe', 'OmegaT.l4J.ini'
}
destinationDir = file("${buildDir}/innosetup/${args.name}")
def fullVersion = project.version + omtVersion.beta
def installerBasename = "OmegaT_${fullVersion}_${args.suffix}"
outputs.file "${distsDir}/${installerBasename}.exe"
onlyIf {
(!args.jrePath || args.jrePath.directory) && haveInnoSetup()
}
doLast {
project.copy {
from('release/win32-specific') {
include 'OmegaT.iss'
}
into(destinationDir)
filter(ReplaceTokens, tokens: [VERSION_NUMBER_SUBST: fullVersion,
OUTPUT_DIR_SUBST: distsDir.path,
OUTPUT_BASENAME_SUBST: installerBasename.toString(),
JRE_COMMENT_SUBST: args.jrePath ? '' : ';',
JRE_PATH_SUBST: args.jrePath ? args.jrePath.path : '',
CUSTOM_MESSAGES_SUBST: getInnoSetupCustomMessages(),
ARCHITECTURE_SUBST: args.arch ?: ''])
filteringCharset = 'UTF-8'
}
exec {
commandLine 'iscc', "${destinationDir}/OmegaT.iss"
}
}
}
assemble.dependsOn args.name
win.dependsOn args.name
}
makeWinTask name: 'winNoJRE', suffix: 'Windows_without_JRE'
makeWinTask name: 'winJRE', suffix: 'Windows', jrePath: windowsJRE
makeWinTask name: 'winJRE64', suffix: 'Windows_64', jrePath: windowsJRE64, arch: 'x64'
// Disable .tar distributions for everyone but Linux
tasks.findAll { it.name =~ /[dD]istTar$/ && !it.name.contains('linux') }.each { it.enabled = false }
// Disable .zip distributions for Linux
tasks.findAll { it.name =~ /[dD]istZip$/ && it.name.contains('linux') }.each { it.enabled = false }
ext.webstartProps = loadProperties file("${assetDir}/webstart.properties")
jnlp {
href "${applicationName}.jnlp"
if (webstartProps.codebase) {
codebase webstartProps.codebase
}
withXml {
information {
title applicationName
vendor "${applicationName} Development Team"
homepage href: 'https://omegat.org'
shortcut(online: false) {
desktop()
menu submenu: "${applicationName} from WebStart"
}
}
'offline-allowed'()
association 'mime-type': 'application/x-omegat-project', extensions: 'project'
security {
'all-permissions'()
}
resources {
property name: 'javaws.cfg.jauthenticator', value: true
}
}
if (webstartProps.keystore) {
signJarAddedManifestEntries = ['Codebase': webstartProps.codebase,
'Permissions': 'all-permissions',
'Application-Name': applicationName]
signJarParams = webstartProps.subMap('keystore', 'alias', 'storepass', 'keypass', 'tsaurl')
}
}
ext.detectRevision = { ->
/* Set the revision number included in version strings. The value is chosen from the first valid value in:
0. Provided as the Gradle property 'repo.revision'
1. src/org/omegat/Version.properties (only if not "dev", i.e. this is a source package not under VCS)
2. This svn checkout's revision
3. This git clone's SHA-1
4. If none of the above, the value "unknown"
*/
def provided = findProperty('repoRevision') ?: ''
def git = file('.git').directory ? doCmd('git rev-parse --short HEAD') : ''
def svn = file('.svn').directory ? doCmd('svnversion') : ''
[provided, omtVersion.revision, git, svn, 'unknown'].find {
it != 'dev' && !it.empty
}
}
processResources {
def revision = detectRevision()
inputs.property 'revision', revision
doLast {
logger.lifecycle("Detected revision ${revision}")
def versionFile = file("${sourceSets.main.output.resourcesDir}/org/omegat/Version.properties")
ant.propertyfile(file: versionFile) {
entry(key: 'revision', value: revision)
}
}
}
task checksums {
def algos = ['SHA-512', 'MD5']
description = "Generate ${algos.join(', ')} checksums for distribution files"
inputs.files fileTree(dir: distsDir, exclude: 'checksums')
def checksumsDir = file("${distsDir}/checksums")
outputs.dir checksumsDir
onlyIf {
distsDir.directory
}
doLast {
distsDir.listFiles().findAll { it.file }.each { f ->
algos.each { algo ->
ant.checksum file: f, algorithm: algo, todir: checksumsDir
}
}
}
}
task genJAXB {
description = 'Generate classes for loading and manipulating XML formats'
outputs.dir 'src/gen'
doLast {
['gen.core.segmentation': 'src/schemas/srx20.xsd',
'gen.core.filters': 'src/schemas/filters.xsd',
'gen.core.tbx': 'src/schemas/tbx.xsd',
'gen.core.project': 'src/schemas/project_properties.xsd'].each { pkg, xsd ->
exec {
commandLine 'xjc', '-no-header', '-d', 'src', '-p', pkg, xsd
}
}
[[p: 'gen.core.tmx14', b: 'src/schemas/tmx14.xjb', xsd: 'src/schemas/tmx14.xsd'],
[p: 'gen.taas', b: 'src/schemas/taas.xjb', xsd: 'src/schemas/taas.xsd']].each { cfg ->
exec {
commandLine 'xjc', '-no-header', '-d', 'src', '-p', cfg.p, '-b', cfg.b, cfg.xsd
}
}
}
}
task genMac {
description = 'Generate the Mac .app skeleton. Requires AppBundler (https://bitbucket.org/infinitekind/appbundler) ' +
'to be available in ~/.ant/lib'
outputs.dir file('release/mac-specific')
def appbundlerJar = file("${System.getProperty('user.home')}/.ant/lib/appbundler-1.0ea.jar")
onlyIf {
appbundlerJar.file
}
doLast {
ant.taskdef(name: 'appbundler', classname: 'com.oracle.appbundler.AppBundlerTask',
classpath: appbundlerJar)
ant.appbundler(outputdirectory: 'release/mac-specific',
name: applicationName,
displayname: applicationName,
identifier: 'org.omegat.OmegaT',
icon: 'images/OmegaT.icns',
version: '${version}',
jvmrequired: javaVersion,
shortversion: '${version}',
mainclassname: mainClassName) {
option(value: "-Xdock:name=${applicationName}")
argument(value: '--config-file=${configfile}')
bundledocument(extensions: 'project',
name: "${applicationName} Project",
role: 'editor',
icon: 'images/OmegaT.icns')
bundledocument(extensions: '*',
name: 'All Files',
role: 'none')
plistentry(key: 'JVMRuntime', value: 'jre.bundle')
}
}
}
allprojects {
javadoc {
failOnError = false
}
tasks.withType(JavaCompile) {
options.compilerArgs.addAll '-Xlint', '-Werror'
}
}
findbugs {
reportLevel = 'high'
}
tasks.withType(FindBugs) {
reports {
xml {
enabled envIsCi
withMessages true
}
html.enabled !envIsCi
}
}
checkstyleMain.exclude '**/gen/**'
task jar2(type: Sync) {
description = 'Create minimal executable output for debugging.'
destinationDir = file("${buildDir}/install/jar2")
from jar
from(configurations.runtime) {
into 'lib'
}
from('scripts') {
into 'scripts'
}
}
task debug(type: JavaExec) {
description = 'Launch app for debugging.' // Special debug task for NetBeans
main = mainClassName
classpath = sourceSets.main.runtimeClasspath
debug true
}
ext.repoHasChanges = {
if (file('.git').directory) {
!doCmd('git status -s').empty
} else if (file('.svn').directory) {
!doCmd('svn status -q').empty
} else {
false
}
}
task releaseCheck {
description = 'Check that the repository is in the right condition for a release'
doLast {
if (repoHasChanges()) {
throw new GradleException('Repository has uncommitted changes. Please commit before releasing.')
}
}
}
task release {
description = 'Create distribution packages for release.'
dependsOn clean, genDocIndex, releaseCheck, build
build.mustRunAfter clean, genDocIndex, releaseCheck
releaseCheck.mustRunAfter genDocIndex
}
task testIntegration(type: JavaExec) {
description = 'Run integration tests. Pass repo URL as -Domegat.test.repo=<repo>'
main = 'org.omegat.core.data.TestTeamIntegration'
classpath = sourceSets.testIntegration.runtimeClasspath
systemProperties = System.properties
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
from javadoc.outputs
}
ext.mavenStyleVersion = version.replace('_', '-')
publishing {
publications {
bintray(MavenPublication) {
groupId 'org.omegat'
artifactId 'omegat'
version mavenStyleVersion
from components.java
artifact sourceJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
}
}
}
bintray {
user = findProperty('bintrayUser')
key = findProperty('bintrayKey')
pkg {
repo = 'maven'
name = 'OmegaT'
userOrg = 'omegat-org'
version {
name = mavenStyleVersion
}
}
publications = ['bintray']
}
remotes {
sourceforgeWeb {
host = 'web.sourceforge.net'
user = findProperty('sourceforgeWebUser')
password = findProperty('sourceforgeWebPassword')
agent = true
if (envIsCi) {
knownHosts = file("${assetDir}/known_hosts")
}
}
}
task publishManual {
description = 'Copy the manual to SourceForge web.'
dependsOn webManual
doLast {
ssh.run {
session(remotes.sourceforgeWeb) {
def root = '/home/project-web/omegat/htdocs'
def timestamp = new Date().format('yyyyMMddHHmmss')
def tempDir = "manual-temp-${timestamp}"
def manualDir = "manual-${omtVersion.beta.empty ? 'standard' : 'latest'}"
sftp {
cd root
mkdir tempDir
}
put from: webManual.outputs.files, into: "${root}/${tempDir}"
sftp {
cd root
try { rename manualDir, "${manualDir}-old-${timestamp}" }
catch (ignored) {}
rename "${tempDir}/${webManual.destinationDir.name}", manualDir
rmdir tempDir
}
}
}
}
}
// Allow setting the max heap size for the run task from the command line, e.g.
// `gradle -PrunMaxHeapSize=1024M run`
run.maxHeapSize = findProperty('runMaxHeapSize')
def Properties loadProperties(File propFile) {
def config = new Properties()
if (propFile.canRead()) {
config.load(new FileInputStream(propFile))
}
return config
}
def doCmd(String cmd) {
StringBuilder output = new StringBuilder()
cmd.execute().waitForProcessOutput(output, null)
return output.toString().trim()
}
def getUpdateSuffix(String update) {
if (!update || update == '0') {
return ''
}
if (update.length() == 1) {
return "_0${update}"
}
return "_${update}"
}
eclipse {
classpath {
plusConfigurations << configurations.runtime
}
}