Completing merge which includes the fix for Android Studio 3.0

This commit is contained in:
Joe Bowser 2017-11-01 13:46:23 -07:00
commit 8ba0109e55
9 changed files with 29 additions and 43 deletions

View File

@ -14,7 +14,7 @@ before_install:
- export PATH=${GRADLE_HOME}/bin:${ANDROID_HOME}:${ANDROID_HOME}/emulator:${ANDROID_TOOLS}:${ANDROID_TOOLS}/bin:${ANDROID_HOME}/platform-tools:$PATH - export PATH=${GRADLE_HOME}/bin:${ANDROID_HOME}:${ANDROID_HOME}/emulator:${ANDROID_TOOLS}:${ANDROID_TOOLS}/bin:${ANDROID_HOME}/platform-tools:$PATH
- node --version - node --version
- gradle --version - gradle --version
- echo y | android --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.0,android-26,android-25,extra-google-m2repository,extra-android-m2repository - echo y | android --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
android: android:
components: components:
- tools - tools

View File

@ -6,6 +6,7 @@ environment:
matrix: matrix:
- nodejs_version: "4" - nodejs_version: "4"
- nodejs_version: "6" - nodejs_version: "6"
- nodejs_version: "8"
init: init:
- mkdir "%ANDROID_HOME% - mkdir "%ANDROID_HOME%
@ -17,7 +18,7 @@ init:
install: install:
- choco install gradle -version 3.4.1 - choco install gradle -version 3.4.1
- gradle -version - gradle -version
- echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.0,android-26,android-25,extra-google-m2repository,extra-android-m2repository - echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
# on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number, # on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number,
# but should be the maximum number of licenses we explicitly need to type "Y ENTER" for. # but should be the maximum number of licenses we explicitly need to type "Y ENTER" for.
# also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell # also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell

View File

@ -180,9 +180,7 @@ GradleBuilder.prototype.prepBuildFiles = function () {
subProjects.forEach(function (p) { subProjects.forEach(function (p) {
console.log('Subproject Path: ' + p); console.log('Subproject Path: ' + p);
var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
depsList += ' debugCompile(project(path: "' + libName + '", configuration: "debug"))'; depsList += ' implementation(project(path: "' + libName + '"))';
insertExclude(p);
depsList += ' releaseCompile(project(path: "' + libName + '", configuration: "release"))';
insertExclude(p); insertExclude(p);
}); });
@ -249,7 +247,7 @@ GradleBuilder.prototype.prepEnv = function (opts) {
// For some reason, using ^ and $ don't work. This does the job, though. // For some reason, using ^ and $ don't work. This does the job, though.
var distributionUrlRegex = /distributionUrl.*zip/; var distributionUrlRegex = /distributionUrl.*zip/;
/* jshint -W069 */ /* jshint -W069 */
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-3.3-all.zip'; var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
/* jshint +W069 */ /* jshint +W069 */
var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties'); var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
shell.chmod('u+w', gradleWrapperPropertiesPath); shell.chmod('u+w', gradleWrapperPropertiesPath);

View File

@ -170,9 +170,7 @@ StudioBuilder.prototype.prepBuildFiles = function () {
subProjects.forEach(function (p) { subProjects.forEach(function (p) {
console.log('Subproject Path: ' + p); console.log('Subproject Path: ' + p);
var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
depsList += ' debugCompile(project(path: "' + libName + '", configuration: "debug"))'; depsList += ' implementation(project(path: "' + libName + '", configuration: "release"))';
insertExclude(p);
depsList += ' releaseCompile(project(path: "' + libName + '", configuration: "release"))';
insertExclude(p); insertExclude(p);
}); });
// For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390 // For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
@ -201,9 +199,6 @@ StudioBuilder.prototype.prepBuildFiles = function () {
depsList += ' compile "' + mavenRef + '"\n'; depsList += ' compile "' + mavenRef + '"\n';
}); });
console.log("Dependency list");
console.log(depsList);
buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + ' $2'); buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + ' $2');
var includeList = ''; var includeList = '';

View File

@ -99,16 +99,8 @@ module.exports.get_gradle_wrapper = function () {
var i = 0; var i = 0;
var foundStudio = false; var foundStudio = false;
var program_dir; var program_dir;
if (module.exports.isDarwin()) { // OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually!
program_dir = fs.readdirSync('/Applications'); if (module.exports.isWindows()) {
while (i < program_dir.length && !foundStudio) {
if (program_dir[i].startsWith('Android Studio')) {
// TODO: Check for a specific Android Studio version, make sure it's not Canary
androidStudioPath = path.join('/Applications', program_dir[i], 'Contents', 'gradle');
foundStudio = true;
} else { ++i; }
}
} else if (module.exports.isWindows()) {
var result = child_process.spawnSync(path.join(__dirname, 'getASPath.bat')); var result = child_process.spawnSync(path.join(__dirname, 'getASPath.bat'));
// console.log('result.stdout =' + result.stdout.toString()); // console.log('result.stdout =' + result.stdout.toString());
@ -176,7 +168,7 @@ module.exports.check_java = function () {
if (javacPath) { if (javacPath) {
// OS X has a command for finding JAVA_HOME. // OS X has a command for finding JAVA_HOME.
var find_java = '/usr/libexec/java_home'; var find_java = '/usr/libexec/java_home';
var default_java_error_msg = 'Failed to find \'JAVA_HOME\' environment variable. Try setting setting it manually.'; var default_java_error_msg = 'Failed to find \'JAVA_HOME\' environment variable. Try setting it manually.';
if (fs.existsSync(find_java)) { if (fs.existsSync(find_java)) {
return superspawn.spawn(find_java).then(function (stdout) { return superspawn.spawn(find_java).then(function (stdout) {
process.env['JAVA_HOME'] = stdout.trim(); process.env['JAVA_HOME'] = stdout.trim();
@ -281,7 +273,7 @@ module.exports.check_android = function () {
if (path.basename(parentDir) === 'tools' || fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) { if (path.basename(parentDir) === 'tools' || fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) {
maybeSetAndroidHome(grandParentDir); maybeSetAndroidHome(grandParentDir);
} else { } else {
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' + throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting it manually.\n' +
'Detected \'android\' command at ' + parentDir + ' but no \'tools\' directory found near.\n' + 'Detected \'android\' command at ' + parentDir + ' but no \'tools\' directory found near.\n' +
'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'tools directory.'); 'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'tools directory.');
} }
@ -292,7 +284,7 @@ module.exports.check_android = function () {
if (path.basename(parentDir) === 'platform-tools') { if (path.basename(parentDir) === 'platform-tools') {
maybeSetAndroidHome(grandParentDir); maybeSetAndroidHome(grandParentDir);
} else { } else {
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' + throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting it manually.\n' +
'Detected \'adb\' command at ' + parentDir + ' but no \'platform-tools\' directory found near.\n' + 'Detected \'adb\' command at ' + parentDir + ' but no \'platform-tools\' directory found near.\n' +
'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'platform-tools directory.'); 'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'platform-tools directory.');
} }
@ -303,14 +295,14 @@ module.exports.check_android = function () {
if (path.basename(parentDir) === 'bin' && path.basename(grandParentDir) === 'tools') { if (path.basename(parentDir) === 'bin' && path.basename(grandParentDir) === 'tools') {
maybeSetAndroidHome(path.dirname(grandParentDir)); maybeSetAndroidHome(path.dirname(grandParentDir));
} else { } else {
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' + throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting it manually.\n' +
'Detected \'avdmanager\' command at ' + parentDir + ' but no \'tools' + path.sep + 'bin\' directory found near.\n' + 'Detected \'avdmanager\' command at ' + parentDir + ' but no \'tools' + path.sep + 'bin\' directory found near.\n' +
'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'tools' + path.sep + 'bin directory.'); 'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'tools' + path.sep + 'bin directory.');
} }
} }
} }
if (!process.env['ANDROID_HOME']) { if (!process.env['ANDROID_HOME']) {
throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting setting it manually.\n' + throw new CordovaError('Failed to find \'ANDROID_HOME\' environment variable. Try setting it manually.\n' +
'Failed to find \'android\' command in your \'PATH\'. Try update your \'PATH\' to include path to valid SDK directory.'); 'Failed to find \'android\' command in your \'PATH\'. Try update your \'PATH\' to include path to valid SDK directory.');
} }
if (!fs.existsSync(process.env['ANDROID_HOME'])) { if (!fs.existsSync(process.env['ANDROID_HOME'])) {

View File

@ -26,10 +26,10 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.0.0'
} }
} }
@ -40,7 +40,6 @@ allprojects {
url "https://maven.google.com" url "https://maven.google.com"
} }
} }
//This replaces project.properties w.r.t. build settings //This replaces project.properties w.r.t. build settings
project.ext { project.ext {
defaultBuildToolsVersion="25.0.2" //String defaultBuildToolsVersion="25.0.2" //String

View File

@ -19,12 +19,12 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 25 compileSdkVersion 26
buildToolsVersion "25.0.2" buildToolsVersion "26.0.2"
defaultConfig { defaultConfig {
applicationId "org.apache.cordova.unittests" applicationId "org.apache.cordova.unittests"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 26
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -38,16 +38,15 @@ android {
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
debugCompile project(path: ":CordovaLib", configuration: "debug") implementation project(path: ":CordovaLib")
releaseCompile project(path: ":CordovaLib", configuration: "release") androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2', { androidTestImplementation ('com.android.support.test.espresso:espresso-web:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
compile 'com.android.support:appcompat-v7:25.1.1' implementation 'com.android.support:appcompat-v7:26.1.0'
testCompile 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testCompile 'org.json:json:20140107' testImplementation 'org.json:json:20140107'
} }

View File

@ -21,9 +21,10 @@
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -33,6 +34,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
google()
} }
} }

View File

@ -1,6 +1,6 @@
#Wed Mar 22 10:51:47 PDT 2017 #Wed Oct 25 11:17:25 PDT 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip