使用Gradle构建uberjar

使用Gradle构建uberjar

问题描述:

我想构建一个包含项目的所有传递依赖项的uberjar(AKA fatjar).我需要在 build.gradle 中添加哪些行?

I want to build an uberjar (AKA fatjar) that includes all the transitive dependencies of the project. What lines do I need to add to build.gradle?

这是我目前拥有的:

task uberjar(type: Jar) {
    from files(sourceSets.main.output.classesDir)

    manifest {
        attributes 'Implementation-Title': 'Foobar',
                'Implementation-Version': version,
                'Built-By': System.getProperty('user.name'),
                'Built-Date': new Date(),
                'Built-JDK': System.getProperty('java.version'),
                'Main-Class': mainClassName
    }
}

您是否尝试过您正在寻找的是 shadow插件