springboot gradle配置文件,生成jar包

4 篇文章 0 订阅
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

archivesBaseName="ems"
group 'tower'
version '2.0-SNAPSHOT'

tasks.withType(JavaCompile) { 
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
    options.encoding="UTF-8"
}

javadoc { options.encoding = "UTF-8" }

repositories {
        mavenLocal()
        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
}
configurations {
    // 编译排除掉内嵌默认的tomcat,使用undertow
    compile.exclude module: 'spring-boot-starter-tomcat'
}

dependencies {
		compile 'org.springframework.boot:spring-boot-starter-web:2.2.5.RELEASE'
        compile 'org.springframework.boot:spring-boot-starter-aop:2.2.5.RELEASE'
        compile 'org.springframework.boot:spring-boot-starter-security:2.2.5.RELEASE'
        compile 'org.springframework.boot:spring-boot-starter-undertow:2.2.5.RELEASE'
        compile 'org.springframework.boot:spring-boot-starter-jdbc:2.2.5.RELEASE'
        
		compile 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1'
		compile 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13'
        compile 'com.google.guava:guava:20.0'
        compile 'io.jsonwebtoken:jjwt:0.9.1'
        compile 'cn.hutool:hutool-all:5.1.2'
		compile 'org.mariadb.jdbc:mariadb-java-client:2.4.0'
}


//生成本应用jar并去除配置文件
task makeJar(type:org.gradle.api.tasks.bundling.Jar) {
    from('build/classes/java/main')
    exclude('*.properties', '*.xml')
}

task deploy(type: Copy) {
    description = 'copy all the binary and config files to deploy dir '
    def destFold='./deploy'
    into(destFold)
    from(configurations.runtime){//本应用依赖jar复制到libs下
        into("libs")
    }
    from("$buildDir/libs"){//本应用代码jar复制到libs下
        into("libs")
    }
    from("$buildDir/sh"){
        into("sh")
    }
    from("$buildDir/resources/main"){
        into("conf")
    }
    doFirst{
        logger.lifecycle("deploy files to : $destFold")
    }
    doLast{
        logger.lifecycle("deploy success!")
    }
}

build.dependsOn([makeJar])
deploy.dependsOn([build])

执行gradle build命令,则在工程目录/build/libs中生成本工程的jar包,并且jar中不含配置文件;

执行gradle deploy命令,则工程目录/deploy目录下生成 conf, libs目录,其中分别是配置文件,jar包

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值