From e718f22135a4bbe4fbfcc24d9748915d6d0376cc Mon Sep 17 00:00:00 2001 From: jiahuiwen Date: Sat, 9 Oct 2021 14:10:06 +0800 Subject: [PATCH] =?UTF-8?q?gradle=20=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/build.gradle b/build.gradle index 5ba73d7..b8579ae 100644 --- a/build.gradle +++ b/build.gradle @@ -22,3 +22,32 @@ dependencies { compile("org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE") compile("org.springframework.boot:spring-boot-starter-data-redis:1.5.9.RELEASE") } +//依赖编译,然后打包JAR +task taskJar(type:Jar, dependsOn: compileJava) { + from 'build/classes/main' + destinationDir = file('build/libs') +} + +//清除上次的编译过的文件 +task clearPj(type:Delete){ + delete 'build','target' +} + + +//把JAR复制到目标目录 +task release(type: Copy,dependsOn: [clearPj,taskJar]) { + from('build/libs') { + include '*.jar' + } + into ('target') +} + +//删除lib中的jar +task clearJars(type:Delete){ + delete 'lib' +} + +task copyJars(type: Copy, dependsOn:clearJars) { + from configurations.runtime + into 'lib' // 目标位置 +} \ No newline at end of file