From c79ff4b3e692ecf0ad30c79fea9a47f767064a74 Mon Sep 17 00:00:00 2001 From: tianxx7 <1729549607@qq.com> Date: Thu, 28 May 2020 15:18:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=89=93=E7=9A=84jar=E5=8C=85=E4=BB=A5?= =?UTF-8?q?=E5=8F=8Azip,=E5=90=8D=E7=A7=B0=E5=AE=8C=E5=85=A8=E5=92=8Cant?= =?UTF-8?q?=E6=89=93=E5=8C=85=E4=B8=80=E8=87=B4,=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E6=9D=A5=E8=87=AAplugin.xml,jar=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E6=9D=A5=E8=87=AAgradle=E5=AE=9A=E4=B9=89=E7=9A=84=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index b8a7532..5b7e506 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,20 @@ ext{ // 项目中依赖的jar的路径 // 如果依赖的jar需要打包到zip中,放置在/lib目录下 libPath = "$projectDir/webroot/WEB-INF/lib" + pluginPre = "fr-plugin" + pluginName = "extendedCharts" + pluginVersion = getVersion() } +/*读取plugin.xml中的version*/ +def getVersion(){ + def xmlFile = "./plugin.xml" + def plugin = new XmlParser().parse(xmlFile) + return plugin.version[0].text() +} + + + repositories { mavenLocal() maven { @@ -67,25 +79,28 @@ jar.dependsOn("preJar") task makeJar(type: Jar,dependsOn: preJar){ from fileTree(dir:"$buildDir/classes/java/main") + baseName pluginPre + appendix pluginName + version pluginVersion destinationDir = file("$buildDir/libs") } -task copyFile(type: Copy,dependsOn: ["jar"]){ +task copyFile(type: Copy,dependsOn: ["makeJar"]){ from "$buildDir/libs" from("$projectDir/lib") { include "*.jar" } from "$projectDir/plugin.xml" - into file("$buildDir/temp/fr-"+"$project.name"+"-$project.version") + into file("$buildDir/temp/fr-plugin-"+"$pluginName"+"-$pluginVersion") } 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' + baseName pluginPre + appendix pluginName + version pluginVersion } //控制build时包含哪些文件,排除哪些文件 From 522d6f5c70e5cc6c55d5cfbdf7650e12dbdc91cd Mon Sep 17 00:00:00 2001 From: tianxx7 <1729549607@qq.com> Date: Thu, 28 May 2020 15:46:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=90=8D=E5=8F=96plugin.?= =?UTF-8?q?xml=E7=9A=84id=E5=92=8Cversion=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 5b7e506..b6731d3 100644 --- a/build.gradle +++ b/build.gradle @@ -10,16 +10,19 @@ ext{ // 项目中依赖的jar的路径 // 如果依赖的jar需要打包到zip中,放置在/lib目录下 libPath = "$projectDir/webroot/WEB-INF/lib" + def pluginInfo = getPluginInfo() pluginPre = "fr-plugin" - pluginName = "extendedCharts" - pluginVersion = getVersion() + pluginName = pluginInfo.id + pluginVersion = pluginInfo.version } /*读取plugin.xml中的version*/ -def getVersion(){ +def getPluginInfo(){ def xmlFile = "./plugin.xml" def plugin = new XmlParser().parse(xmlFile) - return plugin.version[0].text() + def version = plugin.version[0].text() + def id = plugin.id[0].text() + return ["id":id,"version":version] }