java 8至11;用eclipse导出jar问题

mf98qq94  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(394)

我最近开始在游戏中使用jdk11,当我导出到一个可运行的jar时,jar中没有我放在build.gradle文件中的依赖项。切换回jdk8解决了这个问题。我怎样才能解决这个问题?另外,当您通过eclipse导出时,为什么它适用于8而不是11?
我的项目是一个gradle项目,手动添加依赖项到项目设置,因为外部jar似乎可以工作,但我不想这样做。
当前正在使用eclipse 2020-09版本
内部版本.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)
  }
}
mbskvtky

mbskvtky1#

试着在你的等级中包含maven汇编插件的等价物。默认打包只打包已编译的类文件。

相关问题