cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [2/7] android commit: gradle: Write sub-project list explicitly to make Android Studio happy
Date Wed, 24 Sep 2014 01:12:19 GMT
gradle: Write sub-project list explicitly to make Android Studio happy


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0d313a39
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0d313a39
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0d313a39

Branch: refs/heads/master
Commit: 0d313a39645cc4329435eaf70c3ba2c17e18f525
Parents: ddac192
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Sep 23 21:03:00 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Sep 23 21:03:00 2014 -0400

----------------------------------------------------------------------
 bin/lib/create.js                     |  1 -
 bin/templates/cordova/lib/build.js    | 16 ++++++++++++++++
 bin/templates/project/build.gradle    | 20 ++++----------------
 bin/templates/project/settings.gradle | 18 ------------------
 4 files changed, 20 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0d313a39/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index c045819..bfe6b23 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -122,7 +122,6 @@ function copyBuildRules(projectPath) {
     shell.cp('-f', path.join(srcDir, 'custom_rules.xml'), projectPath);
 
     shell.cp('-f', path.join(srcDir, 'build.gradle'), projectPath);
-    shell.cp('-f', path.join(srcDir, 'settings.gradle'), projectPath);
     shell.cp('-f', path.join(srcDir, 'cordova.gradle'), projectPath);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0d313a39/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 89556fe..c5b6b09 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -237,6 +237,22 @@ var builders = {
                 for (var i = 0; i < subProjects.length; ++i) {
                     shell.cp('-f', pluginBuildGradle, path.join(ROOT, subProjects[i], 'build.gradle'));
                 }
+
+                var subProjectsAsGradlePaths = subProjects.map(function(p) { return ':' +
p.replace(/[/\\]/g, ':') });
+                // Write the settings.gradle file.
+                fs.writeFileSync(path.join(projectPath, 'settings.gradle'),
+                    '// GENERATED FILE - DO NOT EDIT\n' +
+                    'include ":"\n' +
+                    'include "' + subProjectsAsGradlePaths.join('"\ninclude "') + '"\n');
+                // Update dependencies within build.gradle.
+                var buildGradle = fs.readFileSync(path.join(projectPath, 'build.gradle'),
'utf8');
+                var depsList = '';
+                subProjectsAsGradlePaths.forEach(function(p) {
+                    depsList += '    debugCompile project(path: "' + p + '", configuration:
"debug")\n';
+                    depsList += '    releaseCompile project(path: "' + p + '", configuration:
"release")\n';
+                });
+                buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/
SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + '    $2');
+                fs.writeFileSync(path.join(projectPath, 'build.gradle'), buildGradle);
             });
         },
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0d313a39/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index 41984fa..ce59e32 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -17,6 +17,8 @@
        under the License.
 */
 
+// GENERATED FILE! DO NOT EDIT!
+
 import java.util.regex.Pattern
 import groovy.swing.SwingBuilder
 
@@ -111,11 +113,8 @@ android {
 
 dependencies {
     compile fileTree(dir: 'libs', include: '*.jar')
-    // https://code.google.com/p/android/issues/detail?id=52962
-    for (subproject in getProjectList()) {
-        releaseCompile project(path: subproject, configuration: 'release')
-        debugCompile project(path: subproject, configuration: 'debug')
-    }
+    // SUB-PROJECT DEPENDENCIES START
+    // SUB-PROJECT DEPENDENCIES END
 }
 
 
@@ -172,17 +171,6 @@ def getVersionCodeFromManifest() {
     return Integer.parseInt(matcher.group(1))
 }
 
-def getProjectList() {
-    def manifestFile = file("project.properties")
-    def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)")
-    def matcher = pattern.matcher(manifestFile.getText())
-    def projects = []
-    while (matcher.find()) {
-        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 + '"')

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0d313a39/bin/templates/project/settings.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/settings.gradle b/bin/templates/project/settings.gradle
deleted file mode 100644
index baa1714..0000000
--- a/bin/templates/project/settings.gradle
+++ /dev/null
@@ -1,18 +0,0 @@
-import java.util.regex.Pattern
-
-def getProjectList() {
-    def manifestFile = file("project.properties")
-    def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)")
-    def matcher = pattern.matcher(manifestFile.getText())
-    def projects = []
-    while (matcher.find()) {
-      projects.add(":" + matcher.group(2).replace("/",":"))
-    }
-    return projects
-}
-
-for (subproject in getProjectList()) {
-    include subproject
-}
-
-include ':'


Mime
View raw message