( config: Config, capacitorPlugins: Plugin[], cordovaPlugins: Plugin[], )
| 131 | } |
| 132 | |
| 133 | export async function installGradlePlugins( |
| 134 | config: Config, |
| 135 | capacitorPlugins: Plugin[], |
| 136 | cordovaPlugins: Plugin[], |
| 137 | ): Promise<void> { |
| 138 | const capacitorAndroidPackagePath = resolveNode(config.app.rootDir, '@capacitor/android', 'package.json'); |
| 139 | if (!capacitorAndroidPackagePath) { |
| 140 | fatal( |
| 141 | `Unable to find ${c.strong('node_modules/@capacitor/android')}.\n` + |
| 142 | `Are you sure ${c.strong('@capacitor/android')} is installed?`, |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | const capacitorAndroidPath = resolve(dirname(capacitorAndroidPackagePath), 'capacitor'); |
| 147 | |
| 148 | const settingsPath = config.android.platformDirAbs; |
| 149 | const dependencyPath = config.android.appDirAbs; |
| 150 | const relativeCapcitorAndroidPath = convertToUnixPath(relative(settingsPath, capacitorAndroidPath)); |
| 151 | const settingsLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN |
| 152 | include ':capacitor-android' |
| 153 | project(':capacitor-android').projectDir = new File('${relativeCapcitorAndroidPath}') |
| 154 | ${capacitorPlugins |
| 155 | .map((p) => { |
| 156 | if (!p.android) { |
| 157 | return ''; |
| 158 | } |
| 159 | |
| 160 | const relativePluginPath = convertToUnixPath(relative(settingsPath, p.rootPath)); |
| 161 | |
| 162 | return ` |
| 163 | include ':${getGradlePackageName(p.id)}' |
| 164 | project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePluginPath}/${p.android.path}') |
| 165 | `; |
| 166 | }) |
| 167 | .join('')}`; |
| 168 | |
| 169 | const applyArray: any[] = []; |
| 170 | const frameworksArray: any[] = []; |
| 171 | let prefsArray: any[] = []; |
| 172 | cordovaPlugins.map((p) => { |
| 173 | const relativePluginPath = convertToUnixPath(relative(dependencyPath, p.rootPath)); |
| 174 | const frameworks = getPlatformElement(p, platform, 'framework'); |
| 175 | frameworks.map((framework: any) => { |
| 176 | if ( |
| 177 | framework.$.custom && |
| 178 | framework.$.custom === 'true' && |
| 179 | framework.$.type && |
| 180 | framework.$.type === 'gradleReference' |
| 181 | ) { |
| 182 | applyArray.push(`apply from: "${relativePluginPath}/${framework.$.src}"`); |
| 183 | } else if (!framework.$.type && !framework.$.custom) { |
| 184 | if (framework.$.src.startsWith('platform(')) { |
| 185 | frameworksArray.push(` implementation ${framework.$.src}`); |
| 186 | } else { |
| 187 | frameworksArray.push(` implementation "${framework.$.src}"`); |
| 188 | } |
| 189 | } |
| 190 | }); |
no test coverage detected