Building a uberjar with Gradle

后端 未结 4 2045
耶瑟儿~
耶瑟儿~ 2020-11-27 04:28

I am a Gradle novice. I want to build a uberjar (AKA fatjar) that includes all the transitive dependencies of the project. What lines do I need to add to my \"build.gradle\"

4条回答
  •  轮回少年
    2020-11-27 05:16

    I found this project very useful. Using it as a reference, my Gradle uberjar task would be

    task uberjar(type: Jar, dependsOn: [':compileJava', ':processResources']) {
        from files(sourceSets.main.output.classesDir)
        from configurations.runtime.asFileTree.files.collect { zipTree(it) }
    
        manifest {
            attributes 'Main-Class': 'SomeClass'
        }
    }
    

提交回复
热议问题