From 4072654f79f34d55804ce53c49dcd05f9fe0d43c Mon Sep 17 00:00:00 2001 From: tianxx7 <1729549607@qq.com> Date: Wed, 20 May 2020 18:09:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=B7=A5=E7=A8=8B=E6=94=B9?= =?UTF-8?q?=E4=B8=BAgradle,=E5=8F=AF=E5=AF=B9=E6=8F=92=E4=BB=B6=E5=8A=A0?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin-function/ant_build.xml | 11 ++++++++++ plugin-function/build.gradle | 38 +++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 plugin-function/ant_build.xml diff --git a/plugin-function/ant_build.xml b/plugin-function/ant_build.xml new file mode 100644 index 0000000..c09b3f4 --- /dev/null +++ b/plugin-function/ant_build.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/plugin-function/build.gradle b/plugin-function/build.gradle index bd1e998..308f0bd 100644 --- a/plugin-function/build.gradle +++ b/plugin-function/build.gradle @@ -1,11 +1,41 @@ /* * This file was generated by the Gradle 'init' task. */ - +//打包直接执行zip命令 Gradle -> Tasks -> other -> zip dependencies { implementation fileTree(dir: 'lib', include: ['*.jar']) } -task copyFile(type:Copy,dependsOn: ["build"]){ +ant.importBuild("ant_build.xml") +//定义ant变量 +ant.projectDir = projectDir +ant.references["compile.classpath"] = ant.path { + fileset(dir: "lib", includes: '*.jar') + fileset(dir: "$rootDir/webroot/WEB-INF/lib", includes: '*.jar') + fileset(dir: ".",includes:"**/*.jar" ) +} +//clean -> classes -> copyFiles -> compile_javas(加密) -> preJar -> makeJar->copyFile->zip +classes.dependsOn('clean') + +task copyFiles(type: Copy,dependsOn: 'classes'){ + from "$buildDir/classes/java/main" + from "$buildDir/resources/main" + into "$projectDir/classes" +} + +task preJar(type:Copy,dependsOn: 'compile_javas'){ + from "$projectDir/classes" + into "$buildDir/classes/java/main" + doLast(){ + delete file("$projectDir/classes") + } +} + +task makeJar(type: Jar,dependsOn: preJar){ + from fileTree(dir:"$buildDir/classes/java/main") //包含assets文件 + destinationDir = file("$buildDir/libs") +} + +task copyFile(type: Copy,dependsOn: ["makeJar"]){ from "$buildDir/libs" from "$projectDir/lib" from "$projectDir/plugin.xml" @@ -20,8 +50,8 @@ task zip(type:Zip,dependsOn:["copyFile"]){ // appendix 'appendix' // version '0.0.1' } -//先清理再build -build.mustRunAfter clean + + //控制build时包含哪些文件,排除哪些文件 processResources { // exclude everything