diff --git a/plugins/withHuaweiPush.js b/plugins/withHuaweiPush.js index a4af2bd..f49d1f4 100644 --- a/plugins/withHuaweiPush.js +++ b/plugins/withHuaweiPush.js @@ -43,31 +43,14 @@ const withHuaweiPush = (config, options = {}) => { } } - // Add Jiguang Maven repo for dependency resolution (jcore/jpush SDK) + // Add Jiguang Maven repo to dependencyResolutionManagement (for jcore/jpush SDK) if (!contents.includes('developer.jiguang.cn/maven')) { const depMgmtPattern = /dependencyResolutionManagement\s*\{[\s\S]*?repositories\s*\{/; if (depMgmtPattern.test(config.modResults.contents)) { config.modResults.contents = config.modResults.contents.replace( depMgmtPattern, - ` if (!contents.includes('developer.huawei.com/repo')) { - const repoLine = ` maven { url 'https://developer.huawei.com/repo/' }`; - const hasPluginManagement = contents.includes('pluginManagement'); - const hasRepositoriesInPM = /pluginManagement\s*\{[\s\S]*?repositories\s*\{/.test(contents); - - if (hasRepositoriesInPM) { - config.modResults.contents = contents.replace( - /(pluginManagement\s*\{[\s\S]*?repositories\s*\{)/, - `$1\n ${repoLine}` + `$&\n maven { url 'https://developer.jiguang.cn/maven' }` ); - } else if (hasPluginManagement) { - config.modResults.contents = contents.replace( - /(pluginManagement\s*\{)/, - `$1\n repositories {\n gradlePluginPortal()\n google()\n mavenCentral()\n ${repoLine}\n }` - ); - } else { - config.modResults.contents = - `pluginManagement {\n repositories {\n ${repoLine}\n }\n}\n\n` + - config.modResults.contents; } } @@ -80,9 +63,6 @@ const withHuaweiPush = (config, options = {}) => { `$&\n maven { url 'https://developer.huawei.com/repo/' }` ); } - }\n maven { url 'https://developer.jiguang.cn/maven' }` - ); - } } return config;