Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .classpath

This file was deleted.

8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.DS_Store
/.vscode/
/bin/
.vscode/
bin/
lib/javapm.jar
/dist/
dist/
build/
.gradle/
28 changes: 0 additions & 28 deletions .project

This file was deleted.

19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ You can download compressed binary packages for Windows, macOS and Linux from [h

## Convert .properties to XLIFF

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

```text
Usage:

createxliff.bat [-help] -src sourceFolder -xliff xliffFile -srcLang sourceLanguage [-tgtLang targetLanguage] [-reuse] [-2.0]
createxliff.sh [-help] -src sourceFolder -xliff xliffFile -srcLang sourceLanguage [-enc characterSet]
[-tgtLang targetLanguage] [-reuse] [-2.0] [-2.0] [-2.2]

Where:

Expand All @@ -33,11 +34,13 @@ Where:
-tgtLang: (optional) target language code
-reuse: (optional) reuse existing translations
-2.0: (optional) generate XLIFF 2.0
-2.1: (optional) generate XLIFF 2.1
-2.2: (optional) generate XLIFF 2.2
```

## Import translated XLIFF

Running `.\mergexliff.bat` or `./mergexliff.sh` without parameters displays help for importing translated XLIFF files.
Running `.\mergexliff.cmd` or `./mergexliff.sh` without parameters displays help for importing translated XLIFF files.

```text
Usage:
Expand All @@ -55,23 +58,23 @@ Where:

## Build Requirements

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

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

## Building

- Checkout this repository.
- Point your JAVA_HOME variable to JDK 17
- Run `ant` to generate a binary distribution in `./dist`
- Point your JAVA_HOME variable to JDK 21
- Run `gradle` to generate a binary distribution in `./dist`

### Steps for building

``` bash
git clone https://github.com/rmraya/JavaPM.git
cd JavaPM
ant
gradle
```

A binary distribution will be created in `/dist` folder.
225 changes: 225 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
plugins {
id 'java'
}

defaultTasks 'dist'

// Disable all caching to ensure clean builds
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.incremental = false
outputs.upToDateWhen { false }
}
}

// Disable caching globally
gradle.taskGraph.whenReady { taskGraph ->
taskGraph.allTasks.each { task ->
task.outputs.upToDateWhen { false }
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
modularity.inferModulePath = true
}

// Source sets configuration
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
exclude '**/*.java'
}
}
}

tasks.withType(JavaCompile).configureEach {
options.release = 21
options.encoding = 'UTF-8'
}


dependencies {
implementation files('lib/bcp47j.jar')
implementation files('lib/json.jar')
implementation files('lib/jsoup.jar')
implementation files('lib/mapdb.jar')
implementation files('lib/xmljava.jar')
implementation files('lib/openxliff.jar')
}

// Configure JAR task
jar {
archiveFileName = 'javapm.jar'
destinationDirectory = file('lib')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

// Disable caching for JAR task
outputs.upToDateWhen { false }
}

// Task to create jlink image
task jlinkImage(type: Exec) {
description = 'Create modular runtime image with jlink'
group = 'distribution'
dependsOn jar

// Disable caching for jlink task
outputs.upToDateWhen { false }

doFirst {
// Only clean dist directory before jlink
delete 'dist'
}

def modulePath = "lib${File.pathSeparator}${System.getProperty('java.home')}${File.separator}jmods"

commandLine 'jlink',
'--module-path', modulePath,
'--add-modules', 'javapm',
'--output', 'dist',
'--no-man-pages',
'--no-header-files'

doLast {
// Remove javapm.jar and jrt-fs.jar
delete 'lib/javapm.jar'
delete 'dist/lib/jrt-fs.jar'
}
}

// Task to copy batch files (Windows)
task copyBats {
description = 'Copy .cmd files to /dist'
group = 'distribution'

doLast {
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
copy {
from fileTree('.') { include '*.cmd' }
into 'dist'
}
}
}
}

// Task to copy shell scripts (Unix/Linux/macOS)
task copyShells {
description = 'Copy .sh files to /dist'
group = 'distribution'

doLast {
if (!System.getProperty('os.name').toLowerCase().contains('windows')) {
copy {
from fileTree('.') { include '*.sh' }
into 'dist'
}

// Make shell scripts executable
fileTree('dist').matching { include '**/*.sh' }.each { file ->
file.setExecutable(true, false)
}
}
}
}

// Task to copy additional resources
task copyResources {
description = 'Copy additional resources to /dist/'
group = 'distribution'

doLast {
copy {
from 'catalog'
into 'dist/catalog'
}

copy {
from 'srx'
into 'dist/srx'
}

copy {
from 'LICENSE'
into 'dist'
}
}
}

// Main distribution task
task dist {
description = 'Prepare distribution'
group = 'distribution'

dependsOn clean, jlinkImage, copyBats, copyShells, copyResources

// Ensure clean runs first, then jlink, then copy tasks
jlinkImage.mustRunAfter clean
copyBats.mustRunAfter jlinkImage
copyShells.mustRunAfter jlinkImage
copyResources.mustRunAfter jlinkImage
}

// Task to clean up build artifacts after distribution
task cleanupAfterDist {
description = 'Clean up build artifacts after distribution is complete'
group = 'build'

doLast {
delete 'build'
// Remove empty bin directory if it exists
if (file('bin').exists() && file('bin').list().length == 0) {
file('bin').deleteDir()
}
}
}

// Make cleanup run after dist
dist.finalizedBy cleanupAfterDist

// Clean task to remove dist directory
task distclean {
description = 'Remove dist directory'
group = 'distribution'

doLast {
delete 'dist'
}
}

// Configure clean task to remove all build artifacts
clean {
delete 'lib/javapm.jar'
delete 'bin'
delete 'dist'
delete 'build'

doLast {
// Ensure bin directory is completely removed
file('bin').deleteDir()
}
}

// Configure compiler options for clean builds
compileJava {
options.encoding = 'UTF-8'
options.incremental = false
options.fork = true
options.compilerArgs += [
'--module-path', classpath.asPath
]

// Disable caching for compilation
outputs.upToDateWhen { false }

// Always clean destination before compilation
doFirst {
delete destinationDirectory
}
}
9 changes: 5 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<property name="source" value="17" />
<property name="build.compiler" value="javac10+" />
<path id="JavaPM.classpath">
<pathelement location="lib/dtd.jar" />
<pathelement location="lib/bcp47j.jar" />
<pathelement location="lib/json.jar" />
<pathelement location="lib/jsoup.jar" />
<pathelement location="lib/mapdb.jar" />
Expand Down Expand Up @@ -40,12 +40,13 @@
<link destDir="dist" modulepath="lib:${java.home}/jmods">
<module name="javapm" />
</link>
<delete file="lib/javapm.jar" />
<delete file="dist/lib/jrt-fs.jar" />
</target>
<target name="copyBats" if="isWindows">
<description>Copy .bat to /dist</description>
<copy file="createxliff.bat" todir="dist" />
<copy file="mergexliff.bat" todir="dist" />
<description>Copy .cmd to /dist</description>
<copy file="createxliff.cmd" todir="dist" />
<copy file="mergexliff.cmd" todir="dist" />
</target>
<target name="copyShells" unless="isWindows">
<description>Copy .sh to /dist</description>
Expand Down
Loading