Java 使用gluon Charm模块化项目时出错:可以从多个模块访问包com.gluonhq.Charm.down.plugins
我正在把自己的项目模块化。我的一个类使用以下导入:Java 使用gluon Charm模块化项目时出错:可以从多个模块访问包com.gluonhq.Charm.down.plugins,java,eclipse,java-module,gluon-mobile,java-platform-module-system,Java,Eclipse,Java Module,Gluon Mobile,Java Platform Module System,我正在把自己的项目模块化。我的一个类使用以下导入: 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
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;
在我的模块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 14Eclipse 4.16
buid.gradle
声明了依赖关系'com.gloonhq:charm:5.0.0-jdk9'
(我看到版本6已经存在,我应该升级吗?旧的gloonjfxmobile
插件是EOL,用于用Java 1.8或Java 9创建移动应用程序
为了能够使用Java/JavaFX11+运行这些移动应用程序,您必须将该插件替换为新的Glion客户端插件
更多详情:
- ,
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'
}
}
您将注意到主要的变化:
- 魅力(Glion Mobile)现在是6.0+
- Charm Down已重命名为,当前版本为4.0.8(您必须重构包名,如
到com.gloonhq.Charm.Down.plugins.StorageService
)com.gloonhq.attach.storage.StorageService
/gradlew run
(使用JavaFX插件)
使用新的客户端插件,您还可以创建一个本地映像,该映像将在桌面(Windows、Linux、MacOS)和移动(Android、iOS)上运行,并利用GraalVM
按照,从下载主机的GraalVM,设置GraalVM\u HOME
,您将能够运行:
// build the native image, it takes some time:
./gradlew clean nativeBuild
// run the native image
./gradlew nativeRun
如果你手头有一台移动设备,只有在你的构建中启用iOS或Android上的
目标
,才能将本机映像构建并部署到该移动平台。你使用的是哪个JDK版本?@JoséPereda 14,忘了提一下。要运行Java/JavaFX 11+,你需要从jfxmobile插件开始(仅适用于Java 8和9)到新的客户端插件,请参阅和。@JoséPereda我已经在使用它。我在问题中添加了构建文件。您需要将Charm向下迁移到(应该很简单),请参阅完整性一个应该补充的是,您只能从Linux为Android和macOS为iOS构建。只是为了避免在错误的操作系统上失望。