diff --git a/ant_build.xml b/ant_build.xml new file mode 100644 index 0000000..15c436f --- /dev/null +++ b/ant_build.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 836f58c..ae4b2de 100644 --- a/build.gradle +++ b/build.gradle @@ -4,18 +4,55 @@ dependencies { //使用本地jar implementation fileTree(dir: 'lib', include: ['*.jar']) } +ant.importBuild("ant_build.xml") +//定义ant变量 +ant.projectDir = projectDir +//定义ant中的path标签 +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(ant加密) -> 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" + include "**/*.class" + doLast(){ + delete file("$projectDir/classes") + } +} +jar.dependsOn("preJar") -//将下面两个文件夹的内容打包成为zip -//这个不可以使用form /libs/*.*的通配符, -//可以使用from指定具体的文件名 -//将生成的zip输出到$buildDir下 -task zip(type:Zip,dependsOn:["build"]){ +task makeJar(type: Jar,dependsOn: preJar){ + from fileTree(dir:"$buildDir/classes/java/main") + destinationDir = file("$buildDir/libs") +} + +task copyFile(type: Copy,dependsOn: ["jar"]){ from "$buildDir/libs" + from "$projectDir/lib" from "$projectDir/plugin.xml" - destinationDir file("$buildDir") + into file("$buildDir/temp/fr-"+"$project.name"+"-$project.version") } -//先清理再build -build.mustRunAfter clean + +task zip(type:Zip,dependsOn:["copyFile"]){ + from "$buildDir/temp" + destinationDir file("$buildDir/install") + //生成的文件名: baseName-appendix-0.0.1.zip +// baseName 'baseName' +// appendix 'appendix' +// version '0.0.1' +} + //控制build时包含哪些文件,排除哪些文件 processResources { // exclude everything