Merge branch 'master' into 4.0.x (gradle fixes)

This commit is contained in:
Andrew Grieve 2014-09-16 13:02:55 -04:00
commit 8f27b2ab56
6 changed files with 61 additions and 9 deletions

View File

@ -110,10 +110,13 @@ module.exports.check_java = function() {
}
} else if (isWindows) {
// Try to auto-detect java in the default install paths.
var oldSilent = shelljs.config.silent;
shelljs.config.silent = true;
var firstJdkDir =
shelljs.ls(process.env['ProgramFiles'] + '\\java\\jdk*')[0] ||
shelljs.ls('C:\\Program Files\\java\\jdk*')[0] ||
shelljs.ls('C:\\Program Files (x86)\\java\\jdk*')[0];
shelljs.config.silent = oldSilent;
if (firstJdkDir) {
// shelljs always uses / in paths.
firstJdkDir = firstJdkDir.replace(/\//g, path.sep);
@ -195,7 +198,7 @@ module.exports.check_android = function() {
};
module.exports.getAbsoluteAndroidCmd = function() {
return forgivingWhichSync('android').replace(/([ \\])/g, '\\$1');
return forgivingWhichSync('android').replace(/(\s)/g, '\\$1');
};
module.exports.check_android_target = function(valid_target) {
@ -209,9 +212,12 @@ module.exports.check_android_target = function(valid_target) {
.then(function(output) {
if (output.split('\n').indexOf(valid_target) == -1) {
var androidCmd = module.exports.getAbsoluteAndroidCmd();
throw new Error('Please install Android target: "' + valid_target + '".\n' +
throw new Error('Please install Android target: "' + valid_target + '".\n\n' +
'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +
'Or install directly via: ' + androidCmd + ' update sdk --no-ui --all --filter "' + valid_target + '"');
'You will require:\n' +
'1. "SDK Platform" for ' + valid_target + '\n' +
'2. "Android SDK Platform-tools (latest)\n' +
'3. "Android SDK Build-tools" (latest)');
}
});
};

View File

@ -236,7 +236,7 @@ var builders = {
// Find the recently-generated output APK files
// Gradle can generate multiple output files; return all of them.
getOutputFiles: function(build_type) {
var binDir = path.join(ROOT, 'build', 'apk');
var binDir = path.join(ROOT, 'build', 'outputs', 'apk');
var candidates = find_files(binDir, function(candidate) {
// Need to choose between release and debug .apk.
if (build_type === 'debug') {

View File

@ -33,7 +33,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true">
android:hardwareAccelerated="true" android:supportsRtl="true">
<activity android:name="__ACTIVITY__"
android:label="@string/activity_name"
android:launchMode="singleTop"

View File

@ -29,7 +29,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.android.tools.build:gradle:0.12.0+'
}
}
@ -89,6 +89,26 @@ android {
targetCompatibility JavaVersion.VERSION_1_7
}
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)
}
}
task wrapper(type: Wrapper) {
@ -109,7 +129,28 @@ def getProjectList() {
def matcher = pattern.matcher(manifestFile.getText())
def projects = []
while (matcher.find()) {
projects.add(":" + matcher.group(2).replace("/",":"))
projects.add(":" + matcher.group(2).replace("/",":"))
}
return projects
}
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')
}
}

View File

@ -116,5 +116,5 @@ String getAndroidSdkDir() {
}
cordovaSdkVersion = getProjectTarget("android-19")
cordovaBuildToolsVersion = latestBuildToolsAvailable("19.0.0")
cordovaBuildToolsVersion = latestBuildToolsAvailable("19.1.0")

View File

@ -25,7 +25,12 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
// This should be updated with each cordova-android release.
// It can affect things like where the .apk is generated.
// It also dictates what the minimum android build-tools version
// that you need (Set in bin/templates/project/cordova.gradle).
// Be sure to also update the value in bin/templates/project.
classpath 'com.android.tools.build:gradle:0.12.+'
}
}