2014-09-10 22:54:21 +08:00
|
|
|
/*
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
or more contributor license agreements. See the NOTICE file
|
|
|
|
distributed with this work for additional information
|
|
|
|
regarding copyright ownership. The ASF licenses this file
|
|
|
|
to you under the Apache License, Version 2.0 (the
|
|
|
|
"License"); you may not use this file except in compliance
|
|
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
|
|
software distributed under the License is distributed on an
|
|
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
KIND, either express or implied. See the License for the
|
|
|
|
specific language governing permissions and limitations
|
|
|
|
under the License.
|
|
|
|
*/
|
|
|
|
|
2014-08-18 21:40:33 +08:00
|
|
|
import java.util.regex.Pattern
|
|
|
|
|
2014-09-10 22:57:43 +08:00
|
|
|
ext.cordova = {}
|
|
|
|
apply from: 'cordova.gradle', to: ext.cordova
|
2014-08-18 21:40:33 +08:00
|
|
|
apply plugin: 'android'
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2014-09-17 01:00:27 +08:00
|
|
|
classpath 'com.android.tools.build:gradle:0.12.0+'
|
2014-08-18 21:40:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.multiarch=false
|
|
|
|
|
|
|
|
dependencies {
|
2014-08-28 23:26:35 +08:00
|
|
|
compile fileTree(dir: 'libs', include: '*.jar')
|
2014-08-20 22:44:48 +08:00
|
|
|
for (subproject in getProjectList()) {
|
|
|
|
compile project(subproject)
|
|
|
|
}
|
2014-08-18 21:40:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
android {
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
|
|
java.srcDirs = ['src']
|
|
|
|
resources.srcDirs = ['src']
|
|
|
|
aidl.srcDirs = ['src']
|
|
|
|
renderscript.srcDirs = ['src']
|
|
|
|
res.srcDirs = ['res']
|
|
|
|
assets.srcDirs = ['assets']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0")
|
|
|
|
}
|
|
|
|
|
2014-09-10 22:57:43 +08:00
|
|
|
compileSdkVersion cordova.cordovaSdkVersion
|
|
|
|
buildToolsVersion cordova.cordovaBuildToolsVersion
|
2014-08-18 21:40:33 +08:00
|
|
|
|
2014-08-29 04:17:54 +08:00
|
|
|
if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
|
2014-08-18 21:40:33 +08:00
|
|
|
productFlavors {
|
|
|
|
armv7 {
|
|
|
|
versionCode defaultConfig.versionCode + 2
|
|
|
|
ndk {
|
|
|
|
abiFilters "armeabi-v7a", ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x86 {
|
|
|
|
versionCode defaultConfig.versionCode + 4
|
|
|
|
ndk {
|
|
|
|
abiFilters "x86", ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
all {
|
|
|
|
ndk {
|
|
|
|
abiFilters "all", ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_7
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_7
|
|
|
|
}
|
|
|
|
|
2014-09-17 01:01:25 +08:00
|
|
|
if (System.env.RELEASE_SIGNING_PROPERTIES_FILE) {
|
|
|
|
signingConfigs {
|
|
|
|
release {
|
|
|
|
// These must be set or Gradle will complain (even if they are overridden).
|
|
|
|
keyAlias = ""
|
|
|
|
keyPassword = ""
|
|
|
|
storeFile = null
|
|
|
|
storePassword = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
signingConfig signingConfigs.release
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addSigningProps(System.env.RELEASE_SIGNING_PROPERTIES_FILE, signingConfigs.release)
|
|
|
|
}
|
|
|
|
if (System.env.DEBUG_SIGNING_PROPERTIES_FILE) {
|
|
|
|
addSigningProps(System.env.DEBUG_SIGNING_PROPERTIES_FILE, signingConfigs.debug)
|
|
|
|
}
|
2014-08-18 21:40:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
task wrapper(type: Wrapper) {
|
|
|
|
gradleVersion = '1.12'
|
|
|
|
}
|
|
|
|
|
|
|
|
def getVersionCodeFromManifest() {
|
|
|
|
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
|
|
|
|
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
|
|
|
|
def matcher = pattern.matcher(manifestFile.getText())
|
|
|
|
matcher.find()
|
|
|
|
return Integer.parseInt(matcher.group(1))
|
|
|
|
}
|
2014-08-20 22:44:48 +08:00
|
|
|
|
|
|
|
def getProjectList() {
|
|
|
|
def manifestFile = file("project.properties")
|
|
|
|
def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)")
|
|
|
|
def matcher = pattern.matcher(manifestFile.getText())
|
|
|
|
def projects = []
|
|
|
|
while (matcher.find()) {
|
2014-09-17 01:00:27 +08:00
|
|
|
projects.add(":" + matcher.group(2).replace("/",":"))
|
2014-08-20 22:44:48 +08:00
|
|
|
}
|
|
|
|
return projects
|
|
|
|
}
|
2014-09-17 01:01:25 +08:00
|
|
|
|
|
|
|
def ensureValueExists(filePath, props, key) {
|
|
|
|
if (props.get(key) == null) {
|
|
|
|
throw new GradleException(filePath + ': Missing key required "' + key + '"')
|
|
|
|
}
|
|
|
|
return props.get(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
def addSigningProps(propsFilePath, signingConfig) {
|
|
|
|
def propsFile = file(propsFilePath)
|
|
|
|
propsFile.withReader { reader ->
|
|
|
|
def props = new Properties()
|
|
|
|
props.load(reader)
|
|
|
|
signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias')
|
|
|
|
signingConfig.keyPassword = ensureValueExists(propsFilePath, props, 'keyPassword')
|
|
|
|
signingConfig.storeFile = RelativePath.parse(true, ensureValueExists(propsFilePath, props, 'storeFile')).getFile(propsFile.getParentFile())
|
|
|
|
signingConfig.storePassword = ensureValueExists(propsFilePath, props, 'storePassword')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|