diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b2cbca2..a494de1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -31,7 +31,7 @@ jobs: java-version: '25' distribution: 'corretto' - uses: gradle/actions/setup-gradle@v4 - - run: ./gradlew jlinkZip + - run: ./gradlew jpackage - name: Upload a Build Artifact uses: actions/upload-artifact@v4 with: diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6dc0852..0000000 --- a/build.gradle +++ /dev/null @@ -1,61 +0,0 @@ -plugins { - id 'java' - id 'application' - id 'org.javamodularity.moduleplugin' version '1.8.15' - id 'org.openjfx.javafxplugin' version '0.1.0' - id 'org.beryx.jlink' version '3.1.4-rc' -} - -group 'org.jabreftest.test' -version '1.0-SNAPSHOT' - -repositories { - mavenCentral() -} - -ext { - junitVersion = '5.13.4' -} - - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(25)) - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' -} - -application { - mainModule = 'org.jabreftest.test.javafxreproducer' - mainClass = 'org.jabreftest.test.javafxreproducer.HelloApplication' -} - -javafx { - version = '25' - modules = ['javafx.controls', 'javafx.fxml'] -} - -dependencies { - - testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}") -} - -test { - useJUnitPlatform() -} - -jlink { - imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip") - options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] - launcher { - name = 'app' - } -} - -jlinkZip { - group = 'distribution' -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..751d3ce --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,111 @@ +plugins { + java + application + id("org.gradlex.extra-java-module-info") version "1.13.1" + id("org.gradlex.jvm-dependency-conflict-resolution") version "2.4" + id("org.gradlex.java-module-dependencies") version "1.10" + id("org.gradlex.java-module-packaging") version "1.1" +} + +group = "org.jabreftest.test" + +// "1.0-SNAPSHOT" cannot be used; otherwise we get +// java.lang.IllegalArgumentException: Version [1.0-SNAPSHOT] contains invalid component [0-SNAPSHOT] +// 0.1.0 cannaot be used; otherwise we get +// Bundler Mac Application Image skipped because of a configuration problem: The first number in an app-version cannot be zero or negative. +version = "1.0.0" + +repositories { + mavenCentral() +} + +val javafx = "25" +val junitVersion = "5.13.4" + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(25)) + } +} + +tasks.withType().configureEach { + options.encoding = "UTF-8" +} + +application { + mainModule.set("javafx.reproducer") + mainClass.set("org.jabreftest.test.javafxreproducer.HelloApplication") +} + +dependencies { + implementation("org.openjfx:javafx-controls:$javafx") + implementation("org.openjfx:javafx-fxml:$javafx") + testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion") +} + +tasks.test { + useJUnitPlatform() +} + +jvmDependencyConflicts.patch { + listOf("base", "controls", "fxml", "graphics").forEach { jfxModule -> + module("org.openjfx:javafx-$jfxModule") { + addTargetPlatformVariant("", "none", "none") // matches the empty Jars: to get better errors + addTargetPlatformVariant("linux", OperatingSystemFamily.LINUX, MachineArchitecture.X86_64) + addTargetPlatformVariant("linux-aarch64", OperatingSystemFamily.LINUX, MachineArchitecture.ARM64) + addTargetPlatformVariant("mac", OperatingSystemFamily.MACOS, MachineArchitecture.X86_64) + addTargetPlatformVariant("mac-aarch64", OperatingSystemFamily.MACOS, MachineArchitecture.ARM64) + addTargetPlatformVariant("win", OperatingSystemFamily.WINDOWS, MachineArchitecture.X86_64) + } + } +} + +extraJavaModuleInfo { + failOnAutomaticModules = true + failOnModifiedDerivedModuleNames = true + skipLocalJars = true +} + +// Source: https://github.com/jjohannes/java-module-system/blob/main/gradle/plugins/src/main/kotlin/targets.gradle.kts +// Configure variants for OS. Target name can be any string, but should match the name used in GitHub actions. +javaModulePackaging { + // Configuration shared by all targets and applications + vendor = "JabRef" + jlinkOptions.addAll( + "--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages" + // "--ignore-signing-information", + // "--compress", "zip-6", + // "--no-header-files", + // "--no-man-pages", + // "--bind-services", + ) + + target("ubuntu-22.04") { + operatingSystem = OperatingSystemFamily.LINUX + architecture = MachineArchitecture.X86_64 + packageTypes = listOf("app-image", "deb", "rpm") + } + target("ubuntu-22.04-arm") { + operatingSystem = OperatingSystemFamily.LINUX + architecture = MachineArchitecture.ARM64 + packageTypes = listOf("app-image", "deb", "rpm") + } + target("macos-13") { + operatingSystem = OperatingSystemFamily.MACOS + architecture = MachineArchitecture.X86_64 + packageTypes = listOf("app-image", "dmg", "pkg") + singleStepPackaging = true + } + target("macos-14") { + operatingSystem = OperatingSystemFamily.MACOS + architecture = MachineArchitecture.ARM64 + packageTypes = listOf("app-image", "dmg", "pkg") + singleStepPackaging = true + } + target("windows-latest") { + operatingSystem = OperatingSystemFamily.WINDOWS + architecture = MachineArchitecture.X86_64 + packageTypes = listOf("app-image", "msi") + } +} diff --git a/settings.gradle b/settings.gradle index 31d953c..81e20aa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,5 @@ -rootProject.name = "javafx-reproducer" \ No newline at end of file +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} + +rootProject.name = "javafx-reproducer" diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index f8238b1..5304b3d 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,6 @@ -module org.jabreftest.test.javafxreproducer { +// "Full name" cannot be used - otherwise, one gets following error message: +// Module name 'org.jabreftest.test.javafxreproducer' does not fit the project and source set names; expected name 'javafx.reproducer'. +module javafx.reproducer { requires javafx.controls; requires javafx.fxml;