mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
enabled versioning from environment variable
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
import groovy.json.JsonSlurper //used to parse package.json
|
||||||
|
import groovy.json.JsonBuilder
|
||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
|
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
@@ -57,6 +61,16 @@ task cleanDistDir (type: Delete) {
|
|||||||
delete "../dist/"
|
delete "../dist/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task fixVersion << {
|
||||||
|
if(project.hasProperty("PACKAGE_VERSION")) {
|
||||||
|
def inputFile = new File("./package.json")
|
||||||
|
def json = new JsonSlurper().parseText(inputFile.text)
|
||||||
|
json.version = json.version + "-" + PACKAGE_VERSION
|
||||||
|
def jb = new JsonBuilder(json);
|
||||||
|
inputFile.text = JsonOutput.prettyPrint(jb.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
task copyAar << {
|
task copyAar << {
|
||||||
copy {
|
copy {
|
||||||
from "../package.json"
|
from "../package.json"
|
||||||
@@ -68,6 +82,15 @@ task copyAar << {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task revertPackageJson (type: Exec) {
|
||||||
|
if(isWinOs) {
|
||||||
|
commandLine "cmd", "/c", "git", "checkout", "--", "../package.json"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
commandLine "git", "checkout", "--", "../package.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
task packFramework (type: Exec) {
|
task packFramework (type: Exec) {
|
||||||
workingDir "../dist"
|
workingDir "../dist"
|
||||||
|
|
||||||
@@ -79,6 +102,9 @@ task packFramework (type: Exec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
assembleRelease.dependsOn(cleanDistDir)
|
assembleRelease.dependsOn(cleanDistDir)
|
||||||
copyAar.dependsOn(assembleRelease)
|
fixVersion.dependsOn(assembleRelease)
|
||||||
packFramework.dependsOn(copyAar)
|
copyAar.dependsOn(fixVersion)
|
||||||
|
revertPackageJson.dependsOn(copyAar)
|
||||||
|
packFramework.dependsOn(revertPackageJson)
|
||||||
|
|||||||
Reference in New Issue
Block a user