forked from omegat-org/omegat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
507 lines (452 loc) · 19.2 KB
/
build.gradle
File metadata and controls
507 lines (452 loc) · 19.2 KB
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
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'org.omegat.version'
id 'org.omegat.document-conventions'
id 'org.omegat.main-utilities'
id 'org.omegat.java-conventions'
id 'org.omegat.jaxb-conventions'
id 'org.omegat.windows-conventions'
id 'org.omegat.mac-conventions'
id 'org.omegat.linux-conventions'
id 'org.omegat.jpkg-conventions'
id 'org.omegat.publish-conventions'
id 'org.omegat.verification-conventions'
id 'org.omegat.spotless-conventions'
id 'jvm-test-suite'
id 'java-test-fixtures'
id 'com.google.osdetector' version '1.7.3'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}
application {
applicationName = project.property('org.omegat.appName')
mainClass = project.property('org.omegat.mainClassName')
}
def os = osdetector.os
def osArch = osdetector.classifier
// Explicitly specify Gradle wrapper version
tasks.withType(Wrapper.class).configureEach {
distributionType = Wrapper.DistributionType.BIN
gradleVersion = "9.3.1" // set the same version as in gradle/wrapper/gradle-wrapper.properties
}
version = omtVersion.version
// 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')
sourcesJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
sourceSets {
main {
java {
srcDir 'src'
srcDir tasks.genJAXB.outputs
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test/src'
}
resources {
srcDir 'test/src'
srcDir 'test/data'
}
}
testFixtures {
java {
srcDir 'test/fixtures'
}
}
}
configurations {
all
[testRuntime, testCompile]*.exclude group: 'org.languagetool', module: 'language-all'
}
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.text)
implementation(libs.commons.validator)
implementation(libs.commons.codec)
api(libs.slf4j.api)
implementation(libs.slf4j.format.jdk14)
runtimeOnly(libs.slf4j.jdk14)
// jaxb gen compilation
implementation(libs.jaxb4.api)
runtimeOnly(libs.jaxb4.core)
runtimeOnly(libs.jaxb4.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)
implementation(libs.icu4j)
// spellchecker dictionary API
implementation(libs.morfologik.stemming)
// 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)
// JSON parser
implementation(libs.bundles.jackson)
implementation(libs.jetbrains.annotations)
implementation(libs.jspecify)
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'
exclude module: 'jackson-bom'
exclude module: 'jackson-databind'
exclude module: 'jackson-dataformat-yaml'
}
// there is a conflict for jackson
testFixturesApi(libs.bundles.jackson.test)
testFixturesApi(libs.slf4j.api)
testFixturesImplementation sourceSets.main.output
testFixturesImplementation(libs.commons.io)
testFixturesImplementation(libs.omegat.vldocking)
testFixturesImplementation(libs.assertj.swing.junit)
testFixturesImplementation(libs.languagetool.core) {
exclude module: 'guava'
exclude module: 'language-detector'
exclude group: 'com.google.android'
exclude module: 'hunspell'
exclude module: 'json'
exclude module: 'protobuf-java'
}
testFixturesImplementation(libs.jetbrains.annotations)
testFixturesImplementation(libs.jspecify)
testImplementation(libs.junit4)
testImplementation(libs.commons.io)
testImplementation(libs.assertj)
testImplementation(libs.bundles.xmlunit) {
exclude module: 'assertj-core'
}
testImplementation(libs.slf4j.api)
testImplementation(libs.mockito.core)
testImplementation(libs.languagetool.server)
testRuntimeOnly(libs.json)
testRuntimeOnly(libs.protobuf)
testRuntimeOnly(libs.bundles.groovy)
testRuntimeOnly(libs.nashorn.core)
testRuntimeOnly(libs.slf4j.jdk14)
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(libs.bundles.lucene)
testAcceptanceImplementation(project(':aligner'))
testIntegrationImplementation sourceSets.main.output, sourceSets.test.output
testIntegrationImplementation(testFixtures(project.rootProject))
testIntegrationImplementation(libs.slf4j.api)
testIntegrationRuntimeOnly(libs.slf4j.jdk14)
// workdir classifiers are hard-coded in gralde-launch4j plugin
if ("windows".equals(os)) {
launch4jBin 'org.omegat:launch4j:3.55:workdir-win32'
} else if ("osx".equals(os)) {
launch4jBin 'org.omegat:launch4j:3.55:workdir-mac'
} else if ("linux-x86_64".equals(osArch)) {
launch4jBin 'org.omegat:launch4j:3.55:workdir-linux64'
} else if ("linux-aarch_64".equals(osArch)) {
// gradle-launch4j plugin use the classifier
// for architectures other than x86_64 on linux
launch4jBin 'org.omegat:launch4j:3.55:workdir-linux'
}
subprojects.findAll { it.getSubprojects().isEmpty()}.collect {jacocoAggregation it}
}
jar {
def pluginProperties = layout.settingsDirectory.file('Plugins.properties')
def omtPlugins = loadProperties(pluginProperties.asFile)
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 { pluginKey, pluginValue ->
if (pluginKey.startsWith('plugin.desc')) {
def descriptionKey = pluginKey.split('\\.').last()
desc[descriptionKey] = pluginValue
} else if (pluginKey != 'plugin') {
pluginValue.tokenize().each { className ->
attributes('OmegaT-Plugin': pluginKey, className)
}
}
}
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)
}
archiveFileName.set(project.property('org.omegat.omegatJarFilename'))
}
test {
// some test case depends on modules from subproject
dependsOn subprojects.collect {it.tasks.withType(Jar)}
}
distributions {
main {
contents {
// docs targets
// /docs
// ...../greetings/<lang>/first_steps.html
// ...../manuals/<lang>.zip
from(layout.settingsDirectory.dir('release')) {
into 'docs'
include 'doc-license.txt'
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
}
from(layout.settingsDirectory.dir('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'))
}
into('docs/greetings') {
from(tasks.firstSteps)
from(layout.buildDirectory.dir('docs/greetings'))
}
into('docs/manuals') {
from(tasks.manualZips)
from(layout.buildDirectory.dir('docs/manuals'))
}
into('docs/tips') {
from('src_docs/tips')
}
from(layout.settingsDirectory.dir('scripts')) {
into 'scripts'
}
from(layout.settingsDirectory.dir('images')) {
into 'images'
}
from(layout.settingsDirectory.dir('release/plugins-specific')) {
into 'plugins'
}
from(layout.settingsDirectory.dir('release/linux-specific')) {
filter ReplaceTokens, tokens: [
VERSION_NUMBER_SUBST: project.version,
JAR_SUBST : project.property('org.omegat.omegatJarFilename')
]
filePermissions {
unix(0755)
}
}
from(layout.settingsDirectory.dir('release/win32-specific')) {
include 'OmegaT.bat'
filter(ReplaceTokens, tokens: [
JAR_SUBST : project.property('org.omegat.omegatJarFilename')
])
}
from(layout.settingsDirectory.dir('lib/licenses')) {
into 'lib'
}
// system core plugins into modules
into('modules') {
from(subprojects.findAll{!it.name.equals('dummy')}.collect {it.tasks.withType(Jar)})
from(layout.settingsDirectory.dir('releases/modules-specific'))
}
eachFile {
// Move main JAR up one level from lib.
def omegatJarFilename = project.property('org.omegat.omegatJarFilename')
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 'build-logic/**', '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")
}
}
tasks.register('mac') {
description = 'Builds the Mac distributions.'
group = 'omegat distribution'
}
makeHunspellSignTask()
makeMacTask(name: 'macX64', suffix: 'Mac_x64', jrePath: macJRE, parentTaskName: 'mac')
makeMacTask(name: 'macArm', suffix: 'Mac_arm', jrePath: armMacJRE, parentTaskName: 'mac')
tasks.register('linux') {
description = 'Builds the Linux distributions.'
group = 'omegat distribution'
dependsOn linuxDistDeb
dependsOn linuxDistRpm
}
makeLinuxTask(name: "linux64", suffix: "Linux_64", jrePath: linux64JRE, parentTaskName: 'linux')
makeLinuxTask(name: "linuxArm64", suffix: "Linux_ARM64", jrePath: linuxArm64JRE, parentTaskName: 'linux')
// We bundle our startup scripts separately, so disable startScripts.
startScripts.enabled = false
// installDist insists on destination executable directory even when disable start script.
application.executableDir = ""
// Disable .tar distributions for everyone but Linux
tasks.withType(Tar).configureEach {
if (!name.contains('linux')) {
enabled = false
}
}
// Disable .zip distributions for Linux
tasks.withType(Zip).configureEach {
if (name.contains('linux')) {
enabled = false
}
}
def provided = findProperty('repoRevision') ?: ''
def gitArchival = loadProperties(file('.git-archival.properties')).getProperty('node')
def git = file('.git').directory ? providers.exec {commandLine("git", "rev-parse", "--short", "HEAD")}.standardOutput.asText.get().trim() : ''
def revision = [provided, gitArchival, omtVersion.revision, git, 'unknown'].find {
!it.empty && it != '@dev@' && it != '$Format:%H$'
}
processResources {
/*
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 git clone's SHA-1
3. If none of the above, the value "unknown"
*/
inputs.property 'revision', revision
logger.lifecycle("Detected revision " + revision)
filesMatching('**/Version.properties') {
filter ReplaceTokens, tokens:["dev": revision]
}
}
// E.g. when doing `build`, run checks before making distfiles
assemble.mustRunAfter check
allprojects {
afterEvaluate {
tasks.findByName('compileJava')?.configure {
if (project == rootProject) {
options.errorprone.allErrorsAsWarnings = true
}
}
}
}
nexusPublishing.repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : System.getenv('SONATYPE_USER')
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : System.getenv('SONATYPE_PASS')
}
}