[英]Java 8 to 11; exporting jar issue with eclipse
I recently switched to using jdk11 for my game and suddenly when i export to a runnable jar, no dependencies that i put in the build.gradle file are present in the jar.我最近切换到在我的游戏中使用 jdk11,突然当我导出到可运行的 jar 时,我放入 build.gradle 文件中的依赖项不存在于 Z68995FCBF432492D15484D04A9D2AC4 中Switching back to jdk8 resolves this issue.切换回 jdk8 可解决此问题。 How can I fix this?我怎样才能解决这个问题? Also why does it work for 8 but not 11 when you export through eclipse?另外,当您通过 eclipse 导出时,为什么它适用于 8 而不是 11?
My project is a gradle project and manually adding dependencies to the project settings as external jars seems to work but I'd rather not do this.我的项目是 gradle 项目并手动将依赖项添加到项目设置中,因为外部 jars 似乎可以工作,但我宁愿不这样做。
Currently using eclipse 2020-09 version目前使用eclipse 2020-09版
build.gradle: build.gradle:
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/", "../client-core/assets/" ]
project.ext.mainClassName = "com.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../client-core/assets");
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(dependsOn: classes, type: Jar) {
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
}
}
// TODO. dist still generates a small jar with "build", and the full jar with "release".
// it should generate no jar unless called directly with release.
eclipse {
project {
name = "client-launcher"
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/client-core/assets'
}
}
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}
Try including equivalent of maven-assembly-plugin in your grade.尝试在您的成绩中包含等效的 maven-assembly-plugin。 The default packaging only packages the complied class files.默认打包只打包编译好的 class 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.