gpt4 book ai didi

kotlin - jlink:在合并模块和 kotlin.stdlib 中打包 kotlin.*

转载 作者:行者123 更新时间:2023-12-03 08:00:31 27 4
gpt4 key购买 nike

通过 gradle (7.5.1) 构建 Kotlin JavaFX 应用程序,并尝试使用 jlink/jpackage 进行打包/安装。该应用程序有一个module-info.java:

module com.foo.bar {
requires javafx.controls;
requires javafx.fxml;
requires de.jensd.fx.glyphs.fontawesome;
requires kotlin.stdlib;
requires com.github.ajalt.clikt;
requires com.google.gson;
requires java.sql;

opens com.foo.bar to javafx.fxml, com.google.gson;
exports com.foo.bar;
}

gradle jlink 运行没有任何问题,但在执行脚本时,出现以下错误:

Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package kotlin.* in both module com.foo.merged.module and module kotlin.stdlib

其中*是某个库(它每次都会改变)。 build.gradle如下:

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.20'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
id 'application'
}

group 'com.foo'
version '1.0'

repositories {
mavenCentral()
}

dependencies {
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

implementation 'com.github.ajalt.clikt:clikt:3.5.0'
implementation 'com.google.code.gson:gson:2.10'
implementation 'de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2'
implementation 'org.postgresql:postgresql:42.5.0'
implementation 'org.xerial:sqlite-jdbc:3.39.3.0'

testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}

application {
mainModule = 'com.foo.bar'
mainClass = 'com.foo.bar.MainKt'
}

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

jlink {
imageZip = project.file("${buildDir}/distributions/bar-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'bar'
}

jpackage {
outputDir = 'packages'
installerType = 'dmg'
}
}

查看建议的合并模块 (gradle suggestMergedModuleInfo) 时,没有提及任何 kotlin

> Task :suggestMergedModuleInfo
mergedModule {
requires 'java.management';
requires 'java.naming';
requires 'java.logging';
requires 'java.security.sasl';
requires 'java.sql';
requires 'java.xml';
requires 'java.desktop';
requires 'java.transaction.xa';
requires 'java.security.jgss';
provides 'java.sql.Driver' with 'org.postgresql.Driver',
'org.sqlite.JDBC';
}

编辑:因此实际合并的模块似乎没有对任何 kotlin 库的任何引用:

open module com.foo.merged.module {
exports com.github.ajalt.clikt.completion;
exports com.github.ajalt.clikt.core;
exports com.github.ajalt.clikt.internal;
exports com.github.ajalt.clikt.mpp;
exports com.github.ajalt.clikt.output;
exports com.github.ajalt.clikt.parameters.arguments;
exports com.github.ajalt.clikt.parameters.groups;
exports com.github.ajalt.clikt.parameters.internal;
exports com.github.ajalt.clikt.parameters.options;
exports com.github.ajalt.clikt.parameters.types;
exports com.github.ajalt.clikt.parsers;
exports com.github.ajalt.clikt.sources;
exports org.checkerframework.checker.compilermsgs.qual;
exports org.checkerframework.checker.fenum.qual;
exports org.checkerframework.checker.formatter;
exports org.checkerframework.checker.formatter.qual;
exports org.checkerframework.checker.guieffect.qual;
exports org.checkerframework.checker.i18n.qual;
exports org.checkerframework.checker.i18nformatter;
exports org.checkerframework.checker.i18nformatter.qual;
exports org.checkerframework.checker.index.qual;
exports org.checkerframework.checker.initialization.qual;
exports org.checkerframework.checker.interning.qual;
exports org.checkerframework.checker.lock.qual;
exports org.checkerframework.checker.nullness;
exports org.checkerframework.checker.nullness.qual;
exports org.checkerframework.checker.optional.qual;
exports org.checkerframework.checker.propkey.qual;
exports org.checkerframework.checker.regex;
exports org.checkerframework.checker.regex.qual;
exports org.checkerframework.checker.signature.qual;
exports org.checkerframework.checker.signedness;
exports org.checkerframework.checker.signedness.qual;
exports org.checkerframework.checker.tainting.qual;
exports org.checkerframework.checker.units;
exports org.checkerframework.checker.units.qual;
exports org.checkerframework.common.aliasing.qual;
exports org.checkerframework.common.reflection.qual;
exports org.checkerframework.common.returnsreceiver.qual;
exports org.checkerframework.common.subtyping.qual;
exports org.checkerframework.common.util.report.qual;
exports org.checkerframework.common.value.qual;
exports org.checkerframework.dataflow.qual;
exports org.checkerframework.framework.qual;
exports org.checkerframework.framework.util;
exports org.intellij.lang.annotations;
exports org.jetbrains.annotations;
exports org.postgresql;
exports org.postgresql.copy;
exports org.postgresql.core;
exports org.postgresql.core.v3;
exports org.postgresql.core.v3.adaptivefetch;
exports org.postgresql.core.v3.replication;
exports org.postgresql.ds;
exports org.postgresql.ds.common;
exports org.postgresql.fastpath;
exports org.postgresql.geometric;
exports org.postgresql.gss;
exports org.postgresql.hostchooser;
exports org.postgresql.jdbc;
exports org.postgresql.jdbc2;
exports org.postgresql.jdbc2.optional;
exports org.postgresql.jdbc3;
exports org.postgresql.jre7.sasl;
exports org.postgresql.largeobject;
exports org.postgresql.osgi;
exports org.postgresql.plugin;
exports org.postgresql.replication;
exports org.postgresql.replication.fluent;
exports org.postgresql.replication.fluent.logical;
exports org.postgresql.replication.fluent.physical;
exports org.postgresql.shaded.com.ongres.saslprep;
exports org.postgresql.shaded.com.ongres.scram.client;
exports org.postgresql.shaded.com.ongres.scram.common;
exports org.postgresql.shaded.com.ongres.scram.common.bouncycastle.base64;
exports org.postgresql.shaded.com.ongres.scram.common.bouncycastle.pbkdf2;
exports org.postgresql.shaded.com.ongres.scram.common.exception;
exports org.postgresql.shaded.com.ongres.scram.common.gssapi;
exports org.postgresql.shaded.com.ongres.scram.common.message;
exports org.postgresql.shaded.com.ongres.scram.common.stringprep;
exports org.postgresql.shaded.com.ongres.scram.common.util;
exports org.postgresql.shaded.com.ongres.stringprep;
exports org.postgresql.ssl;
exports org.postgresql.ssl.jdbc4;
exports org.postgresql.sspi;
exports org.postgresql.translation;
exports org.postgresql.util;
exports org.postgresql.util.internal;
exports org.postgresql.xa;
exports org.postgresql.xml;
exports org.sqlite;
exports org.sqlite.core;
exports org.sqlite.date;
exports org.sqlite.javax;
exports org.sqlite.jdbc3;
exports org.sqlite.jdbc4;
exports org.sqlite.util;
requires java.management;
requires java.naming;
requires java.logging;
requires java.security.sasl;
requires java.sql;
requires java.xml;
requires java.desktop;
requires java.transaction.xa;
requires java.security.jgss;
provides java.sql.Driver with org.postgresql.Driver, org.sqlite.JDBC;
}

最佳答案

不确定为什么需要这样做,但在 jlink block 中指定 forceMerge 'kotlin' 可以解决该问题。请参阅https://badass-jlink-plugin.beryx.org/releases/latest/#_methods

关于kotlin - jlink:在合并模块和 kotlin.stdlib 中打包 kotlin.*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74453018/

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