![](/img/trans.png)
[英]com.gluonhq.charm.glisten.control.TextField does not exist
[英]Error modularizing a project with gluon Charm: The package com.gluonhq.charm.down.plugins is accessible from more than one module
我正在模塊化我自己的項目。 我的一門課程使用以下導入:
import com.gluonhq.charm.down.Services;
import com.gluonhq.charm.down.plugins.StorageService; // error here on "com.gluonhq.charm.down.plugins"
import com.gluonhq.charm.glisten.application.MobileApplication;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.control.Dialog;
import com.gluonhq.charm.glisten.control.SettingsPane;
import com.gluonhq.charm.glisten.control.settings.DefaultOption;
import com.gluonhq.charm.glisten.control.settings.Option;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
在我的module-info.java
我已經聲明:
requires charm.glisten;
requires charm.down.core;
requires charm.down.plugin.storage;
根據 Eclipse 的自動修復建議。 但是,我收到為上述行指定的錯誤:
The package com.gluonhq.charm.down.plugins is accessible from more than one module:
charm.down.plugin.device,
charm.down.plugin.display,
charm.down.plugin.in.app.billing,
charm.down.plugin.lifecycle,
charm.down.plugin.push.notifications,
charm.down.plugin.runtime.args,
charm.down.plugin.statusbar,
charm.down.plugin.storage
charm
模塊會自動命名,因為它們顯然不是 Java 模塊。 這可能與問題有關。 在模塊化我的項目之前,沒有這樣的問題。 我該如何解決這個問題?
build.gradle
:
buildscript {
repositories {
jcenter()
google()
mavenCentral()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.gluonhq:client-gradle-plugin:0.1.30'
}
}
plugins {
id 'org.openjfx.javafxplugin' version '0.0.9'
id 'org.beryx.jlink' version '2.21.2'
id 'com.google.osdetector' version '1.6.2'
id 'eclipse'
id 'org.kordamp.gradle.jdeps' version '0.11.0'
}
apply plugin: 'com.gluonhq.client-gradle-plugin'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
sourceCompatibility = 14
targetCompatibility = 14
ext.platform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
dependencies {
compile "org.openjfx:javafx-base:14:$platform"
compile "org.openjfx:javafx-graphics:14:$platform"
compile "org.openjfx:javafx-controls:14:$platform"
compile "org.openjfx:javafx-fxml:14:$platform"
runtimeOnly "org.openjfx:javafx-graphics:14:win"
runtimeOnly "org.openjfx:javafx-graphics:14:mac"
runtimeOnly "org.openjfx:javafx-graphics:14:linux"
compile 'com.gluonhq:charm:5.0.0-jdk9'
compile 'org.reactfx:reactfx:2.0-M5'
compileOnly "org.projectlombok:lombok:1.18.12"
annotationProcessor 'org.projectlombok:lombok:1.18.12'
}
javafx {
version = "14"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
mainClassName = 'com.my.app.MainClass'
jar {
manifest {
attributes 'Main-Class': 'com.my.app.Launcher'
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
wrapper {
gradleVersion = '6.5.1'
}
JDK 14
Eclipse 4.16
buid.gradle
聲明依賴'com.gluonhq:charm:5.0.0-jdk9'
(我看到版本 6 存在,我應該升級嗎?)
用於使用 Java 1.8 或 Java 9 創建移動應用程序的舊jfxmobile
插件已停產。
為了能夠使用 Java/JavaFX 11+ 運行這些移動應用程序,您必須將該插件替換為新的 Gluon 客戶端插件。
更多細節:
一個主要區別是,新插件使用 Maven 而不是 Gradle。 但是,感謝社區,還有一個 Gradle 的客戶端插件版本,可能比 maven 對應版本稍稍落后)。
為了將您的項目遷移到 Java 11+ 並用另一個插件替換一個插件,您必須修改您的構建文件。
plugins {
// new client plugin
id 'com.gluonhq.client-gradle-plugin' version '0.1.30'
id 'org.openjfx.javafxplugin' version '0.0.9'
id 'org.beryx.jlink' version '2.21.2'
id 'com.google.osdetector' version '1.6.2'
id 'eclipse'
id 'org.kordamp.gradle.jdeps' version '0.11.0'
}
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
sourceCompatibility = 14
targetCompatibility = 14
dependencies {
compile 'com.gluonhq:charm:6.0.5'
compile 'org.reactfx:reactfx:2.0-M5'
compileOnly "org.projectlombok:lombok:1.18.12"
annotationProcessor 'org.projectlombok:lombok:1.18.12'
}
javafx {
version = "14"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
gluonClient {
// target = "ios" // uncomment to deploy on iOS
// target = "android" // uncomment to deploy on Android
attachConfig {
version = "4.0.8"
services 'display', 'lifecycle', 'statusbar', 'storage'
}
}
您會注意到主要變化:
com.gluonhq.charm.down.plugins.StorageService
to com.gluonhq.attach.storage.StorageService
). 您仍然可以使用 JDK 運行項目,使用./gradlew run
(使用 JavaFX 插件)。
使用新的客戶端插件,您還可以使用 GraalVM 創建一個本機映像,該映像將在桌面(Windows、Linux、MacOS)和移動設備(Android、iOS)上運行。
按照客戶端要求,從這里為您的主機下載 GraalVM,設置GRAALVM_HOME
,您將能夠運行:
// build the native image, it takes some time:
./gradlew clean nativeBuild
// run the native image
./gradlew nativeRun
如果您手頭有移動設備,只有在您的構建中啟用target
iOS 或 Android 才能構建本機映像並將其部署到該移動平台。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.