Gradle 格拉德尔+;弹簧靴筒';无法处理超过65535个文件的JAR

Gradle 格拉德尔+;弹簧靴筒';无法处理超过65535个文件的JAR,gradle,spring-boot,jar,build.gradle,executable-jar,Gradle,Spring Boot,Jar,Build.gradle,Executable Jar,使用zip64 true不会创建可用的jar文件。虽然Manifest.mf的文件、结构和位置与以前的构建完全相同,但它无法在该jar中找到主类 真正的问题是:在我的最终构建中,我不需要sonarqube或gatling(它们与测试相关),但是AFAIK没有办法排除插件 “fatJar”-任务用于创建jar 非常感谢您的任何帮助 plugins { id "org.sonarqube" version "2.2.1" id "com.github.lkishalmi.gatlin

使用
zip64 true
不会创建可用的jar文件。虽然Manifest.mf的文件、结构和位置与以前的构建完全相同,但它无法在该jar中找到主类

真正的问题是:在我的最终构建中,我不需要sonarqube或gatling(它们与测试相关),但是AFAIK没有办法排除插件

“fatJar”-任务用于创建jar

非常感谢您的任何帮助

plugins {
    id "org.sonarqube" version "2.2.1"
    id "com.github.lkishalmi.gatling" version "0.4.1"
}

// Run in terminal with "gradle sonarqube"
sonarqube {
    properties {
        property "sonar.projectName", "asd"
        property "sonar.projectKey", "org.sonarqube:java-gradle-simple"
        property "sonar.host.url", "http://asd"
        property "sonar.login", "asd"
        property "sonar.password", "asd"
    }
}

// Run in terminal with "gradle gatlingrun", start the application before.
gatling {
    logLevel 'ERROR'
    simulations = {
        include "**/LoginAndSync.scala"
    }
}

group 'asd'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

task fatJar(type: Jar) {
    //zip64 true
    manifest {
        attributes 'Implementation-Title': 'Gradle Jar File Example',
                'Implementation-Version': version,
                'Main-Class': 'application.Asd'
    }
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.1.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.4.1.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.4.1.RELEASE'
    compile group: 'org.springframework', name: 'spring-orm', version: '4.3.3.RELEASE'
    compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
    compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.80'
    compile group: 'io.gatling.highcharts', name: 'gatling-charts-highcharts', version: '2.2.3'

    testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.4.1.RELEASE'
    testCompile group: 'com.h2database', name: 'h2', version: '1.4.193'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '4.0.0.RELEASE'
}
这是我得到的例外:

xecution failed for task ':fatJar'.
> archive contains more than 65535 entries.

  To build this archive, please enable the zip64 extension.
  See: https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.bundling.Zip.html#org.gradle.api.tasks.bundling.Zip:zip64

多亏了M.Deinum,我采用了一种新的方法:

我在
build.gradle

plugins {
    id 'org.springframework.boot' version '1.5.1.RELEASE'
}

现在可以在控制台中使用
gradlebuild
来获得一个正在运行的jar,可以在
/build/libs/

中找到。您正在使用Spring Boot,为什么要创建自己的胖jar?使用Spring启动插件并删除您自己的fat jar任务。@M.Deinum我们还使用gradle运行测试。都在docker脚本中。我不确定,但我认为“在命令行上”这样做并不容易?这与使用spring引导插件有什么关系。按照建议,在使用合适的插件之前删除fat jar任务。@M.Deinum我这样做了,它成功了。谢谢!:)