From 724d8878fcad12ec212658ccbd5cac9cd638cb6e Mon Sep 17 00:00:00 2001 From: YorkShen Date: Fri, 20 Sep 2019 18:46:09 +0800 Subject: [PATCH] * [Android] Change JNI string in cpp/h file (#2928) --- android/sdk/build.gradle | 13 +++++++++++-- android/sdk/buildSrc/packageName.gradle | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle index d14f25c409..6b7559ae63 100755 --- a/android/sdk/build.gradle +++ b/android/sdk/build.gradle @@ -170,7 +170,16 @@ android { externalNativeBuild { cmake { - path '../../weex_core/CMakeLists.txt' + if(project.useApachePackageName) { + path '../../weex_core/CMakeLists.txt' + } + else{ + copy{ + from new File('../../weex_core/CMakeLists.txt') + into new File('src/legacyRelease/cpp') + } + path 'src/legacyRelease/cpp/CMakeLists.txt' + } } } @@ -256,4 +265,4 @@ task weex_core_license(type: com.hierynomus.gradle.license.tasks.LicenseFormat) 'Source/include/JavaScriptCore/**/*.cpp']) } -preBuild.dependsOn copyAndRenamePackage, copyManifest, copyASanLib, checkNdkVersion, licenseFormat \ No newline at end of file +preBuild.dependsOn copyAndRenameCppSourceFile, copyAndRenamePackage, copyManifest, copyASanLib, checkNdkVersion, licenseFormat \ No newline at end of file diff --git a/android/sdk/buildSrc/packageName.gradle b/android/sdk/buildSrc/packageName.gradle index 81e9b801dc..94b2ddc0ab 100644 --- a/android/sdk/buildSrc/packageName.gradle +++ b/android/sdk/buildSrc/packageName.gradle @@ -31,3 +31,28 @@ task copyManifest(type: Copy){ } } } + +task copyOtherCppFile(type: Copy){ + if(!project.useApachePackageName) { + doFirst { + delete new File('src/legacyRelease/cpp') + } + from new File('../../weex_core') + into new File('src/legacyRelease/cpp') + exclude '**/*.cpp', '**/*.cc', '**/*.c', '**/*.h', '**/*.hpp' + } +} + +task copyAndRenameCppSourceFile(type: Copy, dependsOn: copyOtherCppFile){ + if(!project.useApachePackageName) { + from new File('../../weex_core') + into new File('src/legacyRelease/cpp') + include '**/*.cpp', '**/*.cc', '**/*.c', '**/*.h', '**/*.hpp' + filter { String line -> + line.replaceAll('(.*".*)(com/taobao/weex)(.*".*)', { _, prefix, packageName, suffix -> + logger.info("Content substation in .cpp/.h files happpened, \n Input: ${line}, \n Output: ${prefix}org/apache/weex${suffix}") + "${prefix}org/apache/weex${suffix}" + }) + } + } +} \ No newline at end of file