Browse Source

打的jar包以及zip,名称完全和ant打包一致,版本号来自plugin.xml,jar名字来自gradle定义的属性

master
tianxx7 5 years ago
parent
commit
c79ff4b3e6
  1. 25
      build.gradle

25
build.gradle

@ -10,8 +10,20 @@ ext{
// jar的路径 // jar的路径
// jar需要打包到zip中,/lib目录下 // jar需要打包到zip中,/lib目录下
libPath = "$projectDir/webroot/WEB-INF/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 { repositories {
mavenLocal() mavenLocal()
maven { maven {
@ -67,25 +79,28 @@ jar.dependsOn("preJar")
task makeJar(type: Jar,dependsOn: preJar){ task makeJar(type: Jar,dependsOn: preJar){
from fileTree(dir:"$buildDir/classes/java/main") from fileTree(dir:"$buildDir/classes/java/main")
baseName pluginPre
appendix pluginName
version pluginVersion
destinationDir = file("$buildDir/libs") destinationDir = file("$buildDir/libs")
} }
task copyFile(type: Copy,dependsOn: ["jar"]){ task copyFile(type: Copy,dependsOn: ["makeJar"]){
from "$buildDir/libs" from "$buildDir/libs"
from("$projectDir/lib") { from("$projectDir/lib") {
include "*.jar" include "*.jar"
} }
from "$projectDir/plugin.xml" 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"]){ task zip(type:Zip,dependsOn:["copyFile"]){
from "$buildDir/temp" from "$buildDir/temp"
destinationDir file("$buildDir/install") destinationDir file("$buildDir/install")
//: baseName-appendix-0.0.1.zip //: baseName-appendix-0.0.1.zip
// baseName 'baseName' baseName pluginPre
// appendix 'appendix' appendix pluginName
// version '0.0.1' version pluginVersion
} }
//build时包含哪些文件, //build时包含哪些文件,

Loading…
Cancel
Save