From f2f2369db80fe9042e9fd5591bebf4e039720aab Mon Sep 17 00:00:00 2001 From: Ramesh Mani Maran Date: Mon, 6 Mar 2017 15:34:21 +0530 Subject: [PATCH] android: adding classpath and gradle plugins (cherry picked from commit 27c7d253aa1f2125e37344d7829b5b87a4b9a901) --- SConstruct | 4 ++++ methods.py | 5 +++++ platform/android/SCsub | 10 +++++++++- platform/android/build.gradle.template | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index c43797b2e83..90007c83bff 100644 --- a/SConstruct +++ b/SConstruct @@ -74,6 +74,8 @@ env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) env_base.global_defaults = global_defaults env_base.android_maven_repos = [] env_base.android_dependencies = [] +env_base.android_gradle_plugins = [] +env_base.android_gradle_classpath = [] env_base.android_java_dirs = [] env_base.android_res_dirs = [] env_base.android_aidl_dirs = [] @@ -97,6 +99,8 @@ env_base.__class__.android_add_default_config = methods.android_add_default_conf env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes +env_base.__class__.android_add_gradle_plugin = methods.android_add_gradle_plugin +env_base.__class__.android_add_gradle_classpath = methods.android_add_gradle_classpath env_base.__class__.disable_module = methods.disable_module env_base.__class__.add_source_files = methods.add_source_files diff --git a/methods.py b/methods.py index 8431532df91..d6646697ba1 100755 --- a/methods.py +++ b/methods.py @@ -1307,6 +1307,11 @@ def android_add_jni_dir(self, subpath): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath self.android_jni_dirs.append(base_path) +def android_add_gradle_plugin(self, plugin): + self.android_gradle_plugins.append(plugin) + +def android_add_gradle_classpath(self, classpath): + self.android_gradle_classpath.append(classpath) def android_add_default_config(self, config): self.android_default_config.append(config) diff --git a/platform/android/SCsub b/platform/android/SCsub index 64dd44af85b..50b371a66b5 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -64,7 +64,14 @@ gradle_java_dirs_text = "" for x in env.android_java_dirs: gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'" +gradle_plugins = "" +for x in env.android_gradle_plugins: + gradle_plugins += "apply plugin: \"" + x + "\"\n" +gradle_classpath = "" +for x in env.android_gradle_classpath: + gradle_classpath += "\t\tclasspath \"" + x + "\"\n" + gradle_res_dirs_text = "" for x in env.android_res_dirs: @@ -95,7 +102,8 @@ gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_tex gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text) gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text) gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text) - +gradle_text = gradle_text.replace("$$GRADLE_PLUGINS$$", gradle_plugins) +gradle_text = gradle_text.replace("$$GRADLE_CLASSPATH$$", gradle_classpath) gradle_baseout.write(gradle_text) gradle_baseout.close() diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index c46a15bd125..24aab8e01fa 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -4,6 +4,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' + $$GRADLE_CLASSPATH$$ } } @@ -83,3 +84,5 @@ android { variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk")) } } + +$$GRADLE_PLUGINS$$