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包