Home > Software design >  Gradle cannot find javafxplugin
Gradle cannot find javafxplugin

Time:05-21

This is my first attempt at implementing JavaFX using Gradle. My build never completes, getting the following error:

Plugin [id: 'org.openjfx.javafxplugin', version: '0.0.9'] was not found in any of the following resources

I've been out to the Maven repositories we use internally here and have found the JavaFX plugin, albeit with just a pom file, no jar or other executable code. Here is my Gradle set up.

plugins {
    id 'java-library'
    id 'maven'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.9'
}

apply plugin: 'org.springframework.boot'
apply plugin: 'java'

sourceCompatibility = 11.0
targetCompatibility = 11.0

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

repositories {
    mavenLocal()

    maven {
        url "https://local.repository.1/content/groups/public-maven"
    }
    maven {
        url "https://local.repository.2/content/groups/public-maven"
    }
    maven {
        url "https://local.repository.3/service/local/repositories/onewaymirror/content"
    }
    maven {
        url "https://local.repository.4/content/groups/public_maven_release_snapshots_dev/"
    }
}

dependencies {
    implementation "org.openjfx:javafx-plugin:0.0.9"
    testImplementation group: 'junit', name: 'junit', version '4.12'
}

Any assistance you can provide would be greatly appreciated. Thanks in advance.

Edit: It seems that even if I comment out the JavaFX plugin and the JavaFX section of the script, other parts of the build get the same "not found" condition with other dependencies that I know are in the repositories. This seems to be a generalized Gradle issue, not specific to JavaFX.

CodePudding user response:

I followed the idea new JavaFX project wizard to create a new project, choosing Gradle as the build tool and OpenJDK 18.

The generated project worked fine.

The generated build.gradle file, included the following line in the plugins block:

id 'org.openjfx.javafxplugin' version '0.0.10'` 

Your repositories setup is strange.

The generated build file repositories block has only:

mavenCentral()

Likely, your local repository setup is misconfigured and does not include the javafxplugin or does not proxy access to the maven central repository to fetch it from there.

build.gradle

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.10'
    id 'org.beryx.jlink' version '2.24.1'
}

group 'com.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

ext {
    junitVersion = '5.8.2'
}

sourceCompatibility = '18'
targetCompatibility = '18'

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

application {
    mainModule = 'com.example.gradlecheck'
    mainClass = 'com.example.gradlecheck.HelloApplication'
}

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

CodePudding user response:

The following added to settings.gradle got me past the problem:

pluginManagement {
    repositories {
        maven {
            url "https://local.repository1/content/groups/public-maven.dev/"
        }
    }
}

Thanks to all who replied and helped.

  • Related