From d73108cc13eb21c62ab0de5200f62aa096a5a46c Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 25 Oct 2017 11:38:07 -0700 Subject: [PATCH 1/6] CB-13289: Fix test to work with new Google Android Gradle DSL --- test/app/build.gradle | 21 +++++++++---------- test/build.gradle | 4 +++- test/gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test/app/build.gradle b/test/app/build.gradle index 7f587ac8..a5310b24 100644 --- a/test/app/build.gradle +++ b/test/app/build.gradle @@ -19,12 +19,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.2" defaultConfig { applicationId "org.apache.cordova.unittests" minSdkVersion 16 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -38,16 +38,15 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - debugCompile project(path: ":CordovaLib", configuration: "debug") - releaseCompile project(path: ":CordovaLib", configuration: "release") - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(path: ":CordovaLib") + androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 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' }) - compile 'com.android.support:appcompat-v7:25.1.1' - testCompile 'junit:junit:4.12' - testCompile 'org.json:json:20140107' + implementation 'com.android.support:appcompat-v7:26.1.0' + testImplementation 'junit:junit:4.12' + testImplementation 'org.json:json:20140107' } diff --git a/test/build.gradle b/test/build.gradle index b5decb14..319ac2f3 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -21,9 +21,10 @@ buildscript { repositories { jcenter() + google() } 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 // in the individual module build.gradle files @@ -33,6 +34,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/test/gradle/wrapper/gradle-wrapper.properties b/test/gradle/wrapper/gradle-wrapper.properties index 14ab6f93..c83ef6ea 100644 --- a/test/gradle/wrapper/gradle-wrapper.properties +++ b/test/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Mar 22 10:51:47 PDT 2017 +#Wed Oct 25 11:17:25 PDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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 From 04fa5d3febe69d7adc91d1e603118f3d33af2606 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Thu, 26 Oct 2017 22:28:38 +0200 Subject: [PATCH 2/6] CB-13499: Remove duplicate "setting" in error strings --- bin/templates/cordova/lib/check_reqs.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/templates/cordova/lib/check_reqs.js b/bin/templates/cordova/lib/check_reqs.js index 2c3f291d..630c300a 100644 --- a/bin/templates/cordova/lib/check_reqs.js +++ b/bin/templates/cordova/lib/check_reqs.js @@ -176,7 +176,7 @@ module.exports.check_java = function () { if (javacPath) { // OS X has a command for finding 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)) { return superspawn.spawn(find_java).then(function (stdout) { process.env['JAVA_HOME'] = stdout.trim(); @@ -281,7 +281,7 @@ module.exports.check_android = function () { if (path.basename(parentDir) === 'tools' || fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) { maybeSetAndroidHome(grandParentDir); } 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' + 'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'tools directory.'); } @@ -292,7 +292,7 @@ module.exports.check_android = function () { if (path.basename(parentDir) === 'platform-tools') { maybeSetAndroidHome(grandParentDir); } 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' + 'Try reinstall Android SDK or update your PATH to include valid path to SDK' + path.sep + 'platform-tools directory.'); } @@ -303,14 +303,14 @@ module.exports.check_android = function () { if (path.basename(parentDir) === 'bin' && path.basename(grandParentDir) === 'tools') { maybeSetAndroidHome(path.dirname(grandParentDir)); } 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' + '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']) { - 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.'); } if (!fs.existsSync(process.env['ANDROID_HOME'])) { From b2a81c09ec89164d083244903ca990292032363c Mon Sep 17 00:00:00 2001 From: Audrey So Date: Mon, 30 Oct 2017 10:01:50 -0700 Subject: [PATCH 3/6] :CB-13501 : update appveyor node versions to support node 8 --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 907d0c43..3a78f414 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ environment: matrix: - nodejs_version: "4" - nodejs_version: "6" + - nodejs_version: "8" init: - mkdir "%ANDROID_HOME% From 9fdb12671519e97e78c36f4d68025246334f7c04 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 30 Oct 2017 10:39:59 -0700 Subject: [PATCH 4/6] CB-13289: Fixing build problems with Studio Three, but keeping Windows Gradle fix for now, will be deprecated --- bin/templates/cordova/lib/builders/GradleBuilder.js | 6 ++---- bin/templates/cordova/lib/check_reqs.js | 12 ++---------- bin/templates/project/build.gradle | 6 +++--- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/bin/templates/cordova/lib/builders/GradleBuilder.js b/bin/templates/cordova/lib/builders/GradleBuilder.js index 256df80e..53b4e337 100644 --- a/bin/templates/cordova/lib/builders/GradleBuilder.js +++ b/bin/templates/cordova/lib/builders/GradleBuilder.js @@ -133,9 +133,7 @@ GradleBuilder.prototype.prepBuildFiles = function () { subProjects.forEach(function (p) { console.log('Subproject Path: ' + p); var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); - depsList += ' debugCompile(project(path: "' + libName + '", configuration: "debug"))'; - insertExclude(p); - depsList += ' releaseCompile(project(path: "' + libName + '", configuration: "release"))'; + depsList += ' implementation(project(path: "' + libName + '"))'; insertExclude(p); }); // For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390 @@ -198,7 +196,7 @@ GradleBuilder.prototype.prepEnv = function (opts) { // For some reason, using ^ and $ don't work. This does the job, though. var distributionUrlRegex = /distributionUrl.*zip/; /* 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 */ var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties'); shell.chmod('u+w', gradleWrapperPropertiesPath); diff --git a/bin/templates/cordova/lib/check_reqs.js b/bin/templates/cordova/lib/check_reqs.js index 2c3f291d..be2ca9a3 100644 --- a/bin/templates/cordova/lib/check_reqs.js +++ b/bin/templates/cordova/lib/check_reqs.js @@ -99,16 +99,8 @@ module.exports.get_gradle_wrapper = function () { var i = 0; var foundStudio = false; var program_dir; - if (module.exports.isDarwin()) { - program_dir = fs.readdirSync('/Applications'); - 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()) { + //OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually! + if (module.exports.isWindows()) { var result = child_process.spawnSync(path.join(__dirname, 'getASPath.bat')); // console.log('result.stdout =' + result.stdout.toString()); diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index 6ce8695b..76496b7f 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -32,7 +32,7 @@ buildscript { // http://tools.android.com/tech-docs/new-build-system/version-compatibility // and https://issues.apache.org/jira/browse/CB-8143 dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.0.0' } } @@ -47,7 +47,7 @@ allprojects { } task wrapper(type: Wrapper) { - gradleVersion = '2.14.1' + gradleVersion = '4.1.0' } // Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties. @@ -249,7 +249,7 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: '*.jar') + implementation fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START // SUB-PROJECT DEPENDENCIES END } From a2618dcde5d18629b8e871de4ffe1ae19ec0fd47 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 30 Oct 2017 13:17:18 -0700 Subject: [PATCH 5/6] CB-13289: eslint fix --- bin/templates/cordova/lib/check_reqs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/templates/cordova/lib/check_reqs.js b/bin/templates/cordova/lib/check_reqs.js index be2ca9a3..03bfe912 100644 --- a/bin/templates/cordova/lib/check_reqs.js +++ b/bin/templates/cordova/lib/check_reqs.js @@ -99,7 +99,7 @@ module.exports.get_gradle_wrapper = function () { var i = 0; var foundStudio = false; var program_dir; - //OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually! + // OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually! if (module.exports.isWindows()) { var result = child_process.spawnSync(path.join(__dirname, 'getASPath.bat')); From 47e20da631da33cf473f6aaf706296bdc99e2679 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Tue, 31 Oct 2017 10:48:19 -0700 Subject: [PATCH 6/6] CB-13289: Updating Travis and appveyor --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94be6423..e0b89287 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 - node --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: components: - tools diff --git a/appveyor.yml b/appveyor.yml index 907d0c43..b73aa21c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ init: install: - choco install gradle -version 3.4.1 - 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, # 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