Gradle项目打包

本文章包含springboot项目以及普通项目打包

Springboot打包配置

plugins {
    id 'org.springframework.boot' version '2.3.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}
//省略group version configurations repositories dependencies
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}
jar {
    manifest{
        attributes "Manifest-Version": 1.0,
        "Main-Class": '你的启动类'
    }
}
//省略test

打包执行 gradle clean jar即可

普通项目打包

plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow' version '4.0.1'
}
//省略group version configurations repositories dependencies
apply plugin: 'idea'
apply plugin: 'java'
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}
jar {
    manifest{
        attributes "Manifest-Version": 1.0,
                "Main-Class": '你的启动类'
    }
}

打包执行 gradle clean shadowJar

上一篇
下一篇