gradle - 如何使用 Kotlin DSL 将 JavaFX 添加到 gradle 构建文件?
问题描述
如何通过 gradle 添加 javafx 依赖项?
thufir@dur:~/NetBeansProjects/helloWorldJavaFX$
thufir@dur:~/NetBeansProjects/helloWorldJavaFX$ gradle clean
> Configure project :
e: /home/thufir/NetBeansProjects/helloWorldJavaFX/build.gradle.kts:13:7: Unresolved reference: openjfx
FAILURE: Build failed with an exception.
* Where:
Build file '/home/thufir/NetBeansProjects/helloWorldJavaFX/build.gradle.kts' line: 13
* What went wrong:
Script compilation error:
Line 13: org.openjfx.javafxplugin
^ Unresolved reference: openjfx
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$
手册说:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
我的构建文件有:
plugins {
// Apply the java plugin to add support for Java
java
org.openjfx.javafxplugin
// Apply the application plugin to add support for building an application
application
}
这是产生上述错误。
解决方案
在 - 部分plugins
你必须把
id("org.openjfx.javafxplugin") version "0.0.8"
而不仅仅是org.openjfx.javafxplugin
.
之后你可以放一个javafx
-section 像
javafx {
modules("javafx.controls", "javafx.fxml")
}
某处(我更喜欢把它放在 - 部分旁边dependency
)。在这里您可以放入您需要的任何模块。
有关更多配置选项,请查看JavaFX Gradle Plugin。
推荐阅读
- image - 为什么 GetImageCTM pdf 中图像的 X/Y 坐标总是为零?
- scala - 无法将 11,000 列数据从一个表插入到另一个表
- c++ - 使用 C++ 自动单击
- html - 如何在输入字段之间留出小空间?
- node.js - 如何在 ndoe js 中设置可以在所有树枝页面中访问的全局变量
- c# - Resources.UpdateConfiguration 已过时
- mysql - 将用户名存储到mysql sql文件中的变量中
- c - 静态与外部内在函数
- mongodb - Mongo Query 检索好友
- r - 如何在 data.table 中的多个列中使用 ifelse?