Skip to content

Commit d0210d8

Browse files
authored
Merge pull request #1 from rmraya/gradle
Migrated to graddle and added support for XLIFF 2.1 and 2.2
2 parents 3c31806 + 8a98952 commit d0210d8

267 files changed

Lines changed: 434253 additions & 2130 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.classpath

Lines changed: 0 additions & 40 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.DS_Store
2-
/.vscode/
3-
/bin/
2+
.vscode/
3+
bin/
44
lib/javapm.jar
5-
/dist/
5+
dist/
6+
build/
7+
.gradle/

.project

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ You can download compressed binary packages for Windows, macOS and Linux from [h
1616

1717
## Convert .properties to XLIFF
1818

19-
Running `.\createxliff.bat` or `./createxliff.sh` without parameters displays help for XLIFF generation.
19+
Running `.\createxliff.cmd` or `./createxliff.sh` without parameters displays help for XLIFF generation.
2020

2121
```text
2222
Usage:
2323
24-
createxliff.bat [-help] -src sourceFolder -xliff xliffFile -srcLang sourceLanguage [-tgtLang targetLanguage] [-reuse] [-2.0]
24+
createxliff.sh [-help] -src sourceFolder -xliff xliffFile -srcLang sourceLanguage [-enc characterSet]
25+
[-tgtLang targetLanguage] [-reuse] [-2.0] [-2.0] [-2.2]
2526
2627
Where:
2728
@@ -33,11 +34,13 @@ Where:
3334
-tgtLang: (optional) target language code
3435
-reuse: (optional) reuse existing translations
3536
-2.0: (optional) generate XLIFF 2.0
37+
-2.1: (optional) generate XLIFF 2.1
38+
-2.2: (optional) generate XLIFF 2.2
3639
```
3740

3841
## Import translated XLIFF
3942

40-
Running `.\mergexliff.bat` or `./mergexliff.sh` without parameters displays help for importing translated XLIFF files.
43+
Running `.\mergexliff.cmd` or `./mergexliff.sh` without parameters displays help for importing translated XLIFF files.
4144

4245
```text
4346
Usage:
@@ -55,23 +58,23 @@ Where:
5558

5659
## Build Requirements
5760

58-
- JDK 17 or newer is required for compiling and building.
59-
- Apache Ant 1.10.12 or newer.
61+
- JDK 21 is required for compiling and building. Get it from [https://adoptium.net/](https://adoptium.net/).
62+
- Gradle 9.0. Get it from [https://gradle.org/install/](https://gradle.org/install/).
6063

6164
Pre-built binaries already include everything you need to run all options.
6265

6366
## Building
6467

6568
- Checkout this repository.
66-
- Point your JAVA_HOME variable to JDK 17
67-
- Run `ant` to generate a binary distribution in `./dist`
69+
- Point your JAVA_HOME variable to JDK 21
70+
- Run `gradle` to generate a binary distribution in `./dist`
6871

6972
### Steps for building
7073

7174
``` bash
7275
git clone https://github.com/rmraya/JavaPM.git
7376
cd JavaPM
74-
ant
77+
gradle
7578
```
7679

7780
A binary distribution will be created in `/dist` folder.

build.gradle

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
defaultTasks 'dist'
6+
7+
// Disable all caching to ensure clean builds
8+
gradle.projectsEvaluated {
9+
tasks.withType(JavaCompile) {
10+
options.incremental = false
11+
outputs.upToDateWhen { false }
12+
}
13+
}
14+
15+
// Disable caching globally
16+
gradle.taskGraph.whenReady { taskGraph ->
17+
taskGraph.allTasks.each { task ->
18+
task.outputs.upToDateWhen { false }
19+
}
20+
}
21+
22+
java {
23+
toolchain {
24+
languageVersion = JavaLanguageVersion.of(21)
25+
}
26+
modularity.inferModulePath = true
27+
}
28+
29+
// Source sets configuration
30+
sourceSets {
31+
main {
32+
java {
33+
srcDirs = ['src']
34+
}
35+
resources {
36+
srcDirs = ['src']
37+
exclude '**/*.java'
38+
}
39+
}
40+
}
41+
42+
tasks.withType(JavaCompile).configureEach {
43+
options.release = 21
44+
options.encoding = 'UTF-8'
45+
}
46+
47+
48+
dependencies {
49+
implementation files('lib/bcp47j.jar')
50+
implementation files('lib/json.jar')
51+
implementation files('lib/jsoup.jar')
52+
implementation files('lib/mapdb.jar')
53+
implementation files('lib/xmljava.jar')
54+
implementation files('lib/openxliff.jar')
55+
}
56+
57+
// Configure JAR task
58+
jar {
59+
archiveFileName = 'javapm.jar'
60+
destinationDirectory = file('lib')
61+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
62+
63+
// Disable caching for JAR task
64+
outputs.upToDateWhen { false }
65+
}
66+
67+
// Task to create jlink image
68+
task jlinkImage(type: Exec) {
69+
description = 'Create modular runtime image with jlink'
70+
group = 'distribution'
71+
dependsOn jar
72+
73+
// Disable caching for jlink task
74+
outputs.upToDateWhen { false }
75+
76+
doFirst {
77+
// Only clean dist directory before jlink
78+
delete 'dist'
79+
}
80+
81+
def modulePath = "lib${File.pathSeparator}${System.getProperty('java.home')}${File.separator}jmods"
82+
83+
commandLine 'jlink',
84+
'--module-path', modulePath,
85+
'--add-modules', 'javapm',
86+
'--output', 'dist',
87+
'--no-man-pages',
88+
'--no-header-files'
89+
90+
doLast {
91+
// Remove javapm.jar and jrt-fs.jar
92+
delete 'lib/javapm.jar'
93+
delete 'dist/lib/jrt-fs.jar'
94+
}
95+
}
96+
97+
// Task to copy batch files (Windows)
98+
task copyBats {
99+
description = 'Copy .cmd files to /dist'
100+
group = 'distribution'
101+
102+
doLast {
103+
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
104+
copy {
105+
from fileTree('.') { include '*.cmd' }
106+
into 'dist'
107+
}
108+
}
109+
}
110+
}
111+
112+
// Task to copy shell scripts (Unix/Linux/macOS)
113+
task copyShells {
114+
description = 'Copy .sh files to /dist'
115+
group = 'distribution'
116+
117+
doLast {
118+
if (!System.getProperty('os.name').toLowerCase().contains('windows')) {
119+
copy {
120+
from fileTree('.') { include '*.sh' }
121+
into 'dist'
122+
}
123+
124+
// Make shell scripts executable
125+
fileTree('dist').matching { include '**/*.sh' }.each { file ->
126+
file.setExecutable(true, false)
127+
}
128+
}
129+
}
130+
}
131+
132+
// Task to copy additional resources
133+
task copyResources {
134+
description = 'Copy additional resources to /dist/'
135+
group = 'distribution'
136+
137+
doLast {
138+
copy {
139+
from 'catalog'
140+
into 'dist/catalog'
141+
}
142+
143+
copy {
144+
from 'srx'
145+
into 'dist/srx'
146+
}
147+
148+
copy {
149+
from 'LICENSE'
150+
into 'dist'
151+
}
152+
}
153+
}
154+
155+
// Main distribution task
156+
task dist {
157+
description = 'Prepare distribution'
158+
group = 'distribution'
159+
160+
dependsOn clean, jlinkImage, copyBats, copyShells, copyResources
161+
162+
// Ensure clean runs first, then jlink, then copy tasks
163+
jlinkImage.mustRunAfter clean
164+
copyBats.mustRunAfter jlinkImage
165+
copyShells.mustRunAfter jlinkImage
166+
copyResources.mustRunAfter jlinkImage
167+
}
168+
169+
// Task to clean up build artifacts after distribution
170+
task cleanupAfterDist {
171+
description = 'Clean up build artifacts after distribution is complete'
172+
group = 'build'
173+
174+
doLast {
175+
delete 'build'
176+
// Remove empty bin directory if it exists
177+
if (file('bin').exists() && file('bin').list().length == 0) {
178+
file('bin').deleteDir()
179+
}
180+
}
181+
}
182+
183+
// Make cleanup run after dist
184+
dist.finalizedBy cleanupAfterDist
185+
186+
// Clean task to remove dist directory
187+
task distclean {
188+
description = 'Remove dist directory'
189+
group = 'distribution'
190+
191+
doLast {
192+
delete 'dist'
193+
}
194+
}
195+
196+
// Configure clean task to remove all build artifacts
197+
clean {
198+
delete 'lib/javapm.jar'
199+
delete 'bin'
200+
delete 'dist'
201+
delete 'build'
202+
203+
doLast {
204+
// Ensure bin directory is completely removed
205+
file('bin').deleteDir()
206+
}
207+
}
208+
209+
// Configure compiler options for clean builds
210+
compileJava {
211+
options.encoding = 'UTF-8'
212+
options.incremental = false
213+
options.fork = true
214+
options.compilerArgs += [
215+
'--module-path', classpath.asPath
216+
]
217+
218+
// Disable caching for compilation
219+
outputs.upToDateWhen { false }
220+
221+
// Always clean destination before compilation
222+
doFirst {
223+
delete destinationDirectory
224+
}
225+
}

build.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<property name="source" value="17" />
55
<property name="build.compiler" value="javac10+" />
66
<path id="JavaPM.classpath">
7-
<pathelement location="lib/dtd.jar" />
7+
<pathelement location="lib/bcp47j.jar" />
88
<pathelement location="lib/json.jar" />
99
<pathelement location="lib/jsoup.jar" />
1010
<pathelement location="lib/mapdb.jar" />
@@ -40,12 +40,13 @@
4040
<link destDir="dist" modulepath="lib:${java.home}/jmods">
4141
<module name="javapm" />
4242
</link>
43+
<delete file="lib/javapm.jar" />
4344
<delete file="dist/lib/jrt-fs.jar" />
4445
</target>
4546
<target name="copyBats" if="isWindows">
46-
<description>Copy .bat to /dist</description>
47-
<copy file="createxliff.bat" todir="dist" />
48-
<copy file="mergexliff.bat" todir="dist" />
47+
<description>Copy .cmd to /dist</description>
48+
<copy file="createxliff.cmd" todir="dist" />
49+
<copy file="mergexliff.cmd" todir="dist" />
4950
</target>
5051
<target name="copyShells" unless="isWindows">
5152
<description>Copy .sh to /dist</description>

0 commit comments

Comments
 (0)