Gradle wont build my project

I recently changed my project from maven to gradle. I followed this guid Migrating Builds From Apache Maven and then my first error occurred. So I got something along a deprecated exception. I fixed that but then the next problem happened. A really long exception. I tried to fix it for 3 hours but now I just feel like giving up.
I hope anyone can help me.
Here the scan: Build Scan® | Gradle Cloud Services
Here my build.gradle

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.0.1'
}

dependencies {
    // https://mvnrepository.com/artifact/com.google.code.gson/gson
    implementation("com.google.code.gson:gson:2.10.1")
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    implementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
    implementation("com.fasterxml.jackson.core:jackson-core:2.17.0")
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
    implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.0")

}

group 'net.jchad'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

ext {
    junitVersion = '5.10.0'
}


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

application {
    mainModule = 'net.jchad.net'
    mainClass = 'net.jchad.net.jchad.installer.mainclass.Main'
}

javafx {
    version = '21'
    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") <-- This is deprecated
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'app'
    }
}

jlinkZip {
    group = 'distribution'
}

I guess your problem is that you use org.javamodularity.moduleplugin - which I would step away from completely - while not following its documentation that tells to disable module path inferring from the built-in JPMS support, so most probably the built-in support interfers with what that plugin does and breaks things.

Also when working with JPMS but also depending on legacy dependencies, you might end up needing GitHub - gradlex-org/extra-java-module-info: A Gradle 6.8+ plugin to use legacy Java libraries as Java Modules in a modular Java project, and for convenience maybe some of its sibling plugins.

Btw., I strongly recommend switching to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.

Btw. 2, don’t use tasks.withType(...) { ... }, but tasks.withType(...).configureEach { ... }, for more info see Avoiding Unnecessary Task Configuration.

Btw. 3, never use ext / extra properties, they are practically always a work-around for doing something not properly. If you just want a local variable in the script, use a local variable (def in Groovy, val in Kotlin). If it is about versions / dependencies / plugins, better use a version catalog, for more info see Sharing dependency versions between projects.

The build.gradle was generated by executing the gradle initcommand on my Maven project. So I wasn’t really aware that maybe it imports wrong dependencies.

I guess your problem is that you use org.javamodularity.moduleplugin - which I would step away from completely

How would I do that? Should I just delete the dependency or should I use an alternative.
Thank you for helping me. It really brings back the hope to use gradle in my project!

I highly doubt the init task generated it like that.
If it does, it really should be improved as it violates several best-practices as noted.
And I really highly doubt it put the org.javamodularity.moduleplugin there.
If I search through the Gradle sources it also does not occur anywhere.
The Maven-migration part of the init plugin is really just a very rough starter that in almost no case produces a ready-made end result except maybe for extremely simple cases.

I just generated a new JavaFX project with gradle in IntelliJ


This is the default build.gradle IntelliJ 2024.1 generated. So if intelliJ generates code that doesn’t use best practice gradle features what should I do?

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

group 'net.test'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

ext {
    junitVersion = '5.10.0'
}

sourceCompatibility = '21'
targetCompatibility = '21'

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

application {
    mainModule = 'net.test.test'
    mainClass = 'net.test.test.HelloApplication'
}

javafx {
    version = '21'
    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'
}

Tell them that what they produce is rather bad.
They should not apply that plugin, they should use version catalogs, they should use JVM toolchains, they should adhere to task-configuration avoidance, …
That they don’t is not a Gradle topic, but something you have to complain in YouTrack about. :slight_smile:

And they should definitely not use JavaFX Gradle plugin older than 0.1.0 as it does very bad things that were at least significantly improved in 0.1.0