mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
119 lines
2.6 KiB
Groovy
119 lines
2.6 KiB
Groovy
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')
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
def computeCompuleSdkVersion () {
|
|
if(project.hasProperty("compileSdk")) {
|
|
return compileSdk
|
|
}
|
|
else {
|
|
return 23
|
|
}
|
|
}
|
|
|
|
def computeBuildToolsVersion() {
|
|
if(project.hasProperty("buildToolsVersion")) {
|
|
return buildToolsVersion
|
|
}
|
|
else {
|
|
return "22.0.1"
|
|
}
|
|
}
|
|
|
|
def computeTargetSdkVersion() {
|
|
if(project.hasProperty("targetSdk")) {
|
|
return targetSdk
|
|
}
|
|
else {
|
|
return 23
|
|
}
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion computeCompuleSdkVersion()
|
|
buildToolsVersion computeBuildToolsVersion()
|
|
|
|
defaultConfig {
|
|
minSdkVersion 17
|
|
targetSdkVersion computeTargetSdkVersion()
|
|
versionCode 1
|
|
versionName "1.0"
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
}
|
|
|
|
android.libraryVariants.all { variant ->
|
|
variant.outputs.each { output ->
|
|
output.packageLibrary.exclude('libs/android-runtime.jar')
|
|
output.packageLibrary.exclude('libs/android-binding-generator.jar')
|
|
}
|
|
}
|
|
dependencies {
|
|
compile fileTree(include: ['*.jar'], dir: 'libs')
|
|
testCompile 'junit:junit:4.12'
|
|
compile 'com.android.support:support-v4:+'
|
|
compile files('extlibs/android-binding-generator.jar')
|
|
compile files('extlibs/android-runtime.jar')
|
|
}
|
|
|
|
task cleanDistDir (type: Delete) {
|
|
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 << {
|
|
copy {
|
|
from "../package.json"
|
|
into "../dist"
|
|
}
|
|
copy {
|
|
from "build/outputs/aar/widgets-release.aar"
|
|
into "../dist/platforms/android/"
|
|
}
|
|
}
|
|
|
|
task revertPackageJson (type: Exec) {
|
|
if(isWinOs) {
|
|
commandLine "cmd", "/c", "git", "checkout", "--", "../package.json"
|
|
}
|
|
else {
|
|
commandLine "git", "checkout", "--", "../package.json"
|
|
}
|
|
}
|
|
|
|
task packFramework (type: Exec) {
|
|
workingDir "../dist"
|
|
|
|
if(isWinOs) {
|
|
commandLine "cmd", "/c", "npm", "pack"
|
|
}
|
|
else {
|
|
commandLine "npm", "pack"
|
|
}
|
|
}
|
|
|
|
|
|
assembleRelease.dependsOn(cleanDistDir)
|
|
fixVersion.dependsOn(assembleRelease)
|
|
copyAar.dependsOn(fixVersion)
|
|
revertPackageJson.dependsOn(copyAar)
|
|
packFramework.dependsOn(revertPackageJson)
|