From ecd2e068834d128cd61c47153830e55d01e2c7d9 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 30 Dec 2014 22:56:43 -0500 Subject: [PATCH] CB-8229 Gradle: Add CordovaLib as a dependency to all plugin sub-projects --- bin/templates/cordova/lib/build.js | 4 ++- bin/templates/cordova/lib/plugin-build.gradle | 20 ++++++++++++-- framework/build.gradle | 27 ++++++++++++------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index b507c5ef..3a08c3d9 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -227,7 +227,9 @@ var builders = { var pluginBuildGradle = path.join(projectPath, 'cordova', 'lib', 'plugin-build.gradle'); var subProjects = extractSubProjectPaths(); for (var i = 0; i < subProjects.length; ++i) { - shell.cp('-f', pluginBuildGradle, path.join(ROOT, subProjects[i], 'build.gradle')); + if (subProjects[i] !== 'CordovaLib') { + shell.cp('-f', pluginBuildGradle, path.join(ROOT, subProjects[i], 'build.gradle')); + } } var subProjectsAsGradlePaths = subProjects.map(function(p) { return ':' + p.replace(/[/\\]/g, ':') }); diff --git a/bin/templates/cordova/lib/plugin-build.gradle b/bin/templates/cordova/lib/plugin-build.gradle index fd4d8556..f062588c 100644 --- a/bin/templates/cordova/lib/plugin-build.gradle +++ b/bin/templates/cordova/lib/plugin-build.gradle @@ -23,8 +23,22 @@ buildscript { mavenCentral() } - dependencies { - classpath 'com.android.tools.build:gradle:0.12.+' + // Switch the Android Gradle plugin version requirement depending on the + // installed version of Gradle. This dependency is documented at + // http://tools.android.com/tech-docs/new-build-system/version-compatibility + // and https://issues.apache.org/jira/browse/CB-8143 + if (gradle.gradleVersion >= "2.2") { + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0+' + } + } else if (gradle.gradleVersion >= "2.1") { + dependencies { + classpath 'com.android.tools.build:gradle:0.14.0+' + } + } else { + dependencies { + classpath 'com.android.tools.build:gradle:0.12.0+' + } } } @@ -32,6 +46,8 @@ apply plugin: 'android-library' dependencies { compile fileTree(dir: 'libs', include: '*.jar') + debugCompile project(path: ":CordovaLib", configuration: "debug") + releaseCompile project(path: ":CordovaLib", configuration: "release") } android { diff --git a/framework/build.gradle b/framework/build.gradle index e048edd9..f1585d3a 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -24,16 +24,23 @@ buildscript { } dependencies { - // 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). - // Make sure the value is the same in all locations: - // * framework/build.gradle - // * bin/templates/project/cordova.gradle - // * bin/templates/cordova/lib/plugin-build.gradle - // * distributionUrl within bin/templates/cordova/lib/build.js. - classpath 'com.android.tools.build:gradle:0.12.+' + // Switch the Android Gradle plugin version requirement depending on the + // installed version of Gradle. This dependency is documented at + // http://tools.android.com/tech-docs/new-build-system/version-compatibility + // and https://issues.apache.org/jira/browse/CB-8143 + if (gradle.gradleVersion >= "2.2") { + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0+' + } + } else if (gradle.gradleVersion >= "2.1") { + dependencies { + classpath 'com.android.tools.build:gradle:0.14.0+' + } + } else { + dependencies { + classpath 'com.android.tools.build:gradle:0.12.0+' + } + } } }