gpt4 book ai didi

java - 如何修复未解析的引用 : javafxplugin?

转载 作者:行者123 更新时间:2023-12-01 14:33:30 24 4
gpt4 key购买 nike

如何应用 JavaFX 的插件使用 Kotlin DSL? manual建议:
apply plugin: 'org.openjfx.javafxplugin'
而我使用的是 Gradle Kotlin DSL,而不是普通的 Gradle。

当前错误:

thufir@dur:~/NetBeansProjects/helloWorldJavaFX$ 
thufir@dur:~/NetBeansProjects/helloWorldJavaFX$ gradle clean

> Configure project :
e: /home/thufir/NetBeansProjects/helloWorldJavaFX/build.gradle.kts:15:5: Unresolved reference: javafxplugin

FAILURE: Build failed with an exception.

* Where:
Build file '/home/thufir/NetBeansProjects/helloWorldJavaFX/build.gradle.kts' line: 15

* What went wrong:
Script compilation error:

Line 15: javafxplugin
^ Unresolved reference: javafxplugin

1 error

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
thufir@dur:~/NetBeansProjects/helloWorldJavaFX$

构建文件:
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/5.0/userguide/tutorial_java_projects.html
*/

plugins {
// Apply the java plugin to add support for Java
java

// org.openjfx.javafxplugin

javafxplugin

// Apply the application plugin to add support for building an application
application
}




//apply plugin: 'org.openjfx.javafxplugin'


repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}

dependencies {
// This dependency is found on compile classpath of this component and consumers.
// implementation("com.google.guava:guava:26.0-jre")

compile (group = "org.openjfx" , name = "javafx" , version = "12.0.1")
compile (group = "org.openjfx" , name = "javafx-base" , version = "12.0.1")
compile (group = "org.openjfx" , name = "javafx-controls" , version = "12.0.1")
compile (group = "com.google.api-client" , name = "google-api-client" , version = "1.29.2")
compile (group = "com.google.maps" , name = "google-maps-services" , version = "0.9.3")
compile (group = "org.slf4j" , name = "slf4j-api" , version = "1.7.21")
compile (group = "org.slf4j" , name = "slf4j-nop" , version = "1.8.0-beta4")
compile (group = "com.google.cloud" , name = "google-cloud-translate" , version = "1.77.0")
compile (group = "com.google.apis" , name = "google-api-services-books" , version = "v1-rev106-1.25.0")


// implementation 'com.google.maps:google-maps-services:(insert latest version)'
// implementation 'org.slf4j:slf4j-simple:1.7.25'


// Use TestNG framework, also requires calling test.useTestNG() below
// testImplementation("org.testng:testng:6.14.3")
}

application {
// Define the main class for the application
mainClassName = "net.bounceme.dur.fx.App"
}

val test by tasks.getting(Test::class) {
// Use TestNG for unit tests
useTestNG()
}

我正在寻找运行 sample来自 JavaFX。

最佳答案

Gradle 插件门户提供了声明 the plugin 的示例在 Groovy 和 Kotlin 中。 GitHub repository 的自述文件还提供每种语言的示例。基本上,应用插件看起来像:

plugins {
application // built-in plugins are declared differently
id("org.openjfx.javafxplugin") version "0.0.7"
}

然后添加您需要的 JavaFX 模块,您可以使用:
javafx {
// will pull in transitive modules
modules("javafx.controls", "javafx.fxml") // replace with what you modules need

// another option is to use:
// modules = listOf("javafx.controls", "javafx.fxml")

version = "12.0.1" // or whatever version you're using
}

repositories {
mavenCentral() // I believe jcenter() should work as well
}

以上将拉入 javafx.base , javafx.graphics , javafx.controls , 和 javafx.fxml运行 Gradle 守护程序的操作系统的模块。它将它们添加到 implementation配置。不要手动声明任何 JavaFX 依赖项。

注: org.openjfx.javafxplugin插件也适用 com.google.osdetector org.javamodularity.moduleplugin 插件;至少,它在版本 0.0.7 中是这样的.

构建文件的其余部分将类似于:
java {
// replace with the Java version you're using
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

application {
mainClassName = /* your main class */
}

dependencies {
// add your other dependencies
}

tasks {
test {
useTestNG()
}
}

Kotlin DSL 的一个很好的起始资源是 Gradle Kotlin DSL Primer页。如果您是 Kotlin 的新手,我建议您阅读 the reference文档。

关于java - 如何修复未解析的引用 : javafxplugin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56519090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com