From 9fdb12671519e97e78c36f4d68025246334f7c04 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 30 Oct 2017 10:39:59 -0700 Subject: [PATCH] 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 }