1

Solution: Thanks to jewelsea's comment here I switched the project to Maven and won't be using Gradle anymore.

I try to include Saxon-HE within a modular Gradle project, based on the autogenerated JavaFX project within intellij. The error message I get when running in Intellij is:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module Saxon.HE not found, required by org.proj.xslgui

Dependencies in build.gradle:

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.13'
    id 'org.beryx.jlink' version '2.25.0'
}

group 'org.proj'
version '1.0'

repositories {
    mavenCentral()
}

ext {
    junitVersion = '5.9.1'
}

sourceCompatibility = '17'
targetCompatibility = '17'

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

application {
    mainModule = 'org.proj.xslgui'
    mainClass = 'org.proj.xslgui.HelloApplication'
}

javafx {
    version = '17.0.2'
    modules = ['javafx.controls', 'javafx.fxml']
}

dependencies {
    implementation("net.sf.saxon:Saxon-HE:11.4")
    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'
}

The main part of the build.gradle is autogenerated by intellij.

My settings.gradle:

rootProject.name = "XSLGui"

My module-info.java:

module org.proj.xslgui {
    requires javafx.controls;
    requires javafx.fxml;
    requires java.xml;
    requires Saxon.HE;

    opens org.proj.xslgui to javafx.fxml;
    exports org.proj.xslgui;
}

The Saxon.jar shows up in the external libraries. And within the classes everything gets resolved just fine. I have no idea why it can't find the modul, ... intellij itself autogenerated the require Saxon.HE in the module-info.java... I think Saxon just isn't a module at all (can't find a module-info.java), so maybe that's where the problem starts...

I expected that adding the dependency in the build.gradle and adding the require in the module-info.java would suffice for the library to be available in order to run the program. I read the Gradle documentation and googled/stackoverflowed, I didn't find a solution for this problem though.

  • See: [JavaFX with Gradle error module not found](https://stackoverflow.com/questions/71562138/javafx-with-gradle-error-module-not-found/71564960#71564960) – jewelsea Jan 09 '23 at 18:15
  • 1
    @jewelsea Thank you very much for your help! I switched to Maven and am now able to package my app into a standalone jar file. Do you think it's worthwhile putting this forward at Saxonica as a bug (or maybe a feature request)? Because as I understand it, what is holding me off from using Saxon-HE in modular Gradle setup is the lack of a `module-info.java` and/or property `Automatic-Module-Name` in its manifest file within the Saxon dependency. So when Saxonica would provide these, the incorporation in Gradle should work? – Max Grüntgens Jan 10 '23 at 11:54
  • It would be a feature request. It isn't a bug not to support the module system by providing a `module-info.java`. You can log it with them if you like, check to see that it is not already logged. Could be that the project isn't actively developed, which might be why it is not modular yet. If you changed the Gradle build script it could be made to work the way Maven defaults to (I just don't know how to do that), but yes, it is easier and better to work with Gradle when all of the modules are properly defined, especially if you want a modular project yourself. – jewelsea Jan 10 '23 at 13:32
  • The project is certainly actively maintained, but we haven't got around to supporting Java modules yet. I've put it on the list for consideration at https://saxonica.plan.io/issues/5813 – Michael Kay Jan 13 '23 at 15:12

0 Answers0