@@ -263,8 +263,6 @@ if (hasProperty('postBuildExtras')) {
263263
264264export async function handleCordovaPluginsGradle ( config : Config , cordovaPlugins : Plugin [ ] ) : Promise < void > {
265265 const pluginsGradlePath = join ( config . android . cordovaPluginsDirAbs , 'build.gradle' ) ;
266- const kotlinNeeded = await kotlinNeededCheck ( config , cordovaPlugins ) ;
267- const kotlinVersionString = config . app . extConfig . cordova ?. preferences ?. GradlePluginKotlinVersion ?? '2.4.0' ;
268266 const frameworksArray : any [ ] = [ ] ;
269267 let prefsArray : any [ ] = [ ] ;
270268 const applyArray : any [ ] = [ ] ;
@@ -296,10 +294,6 @@ export async function handleCordovaPluginsGradle(config: Config, cordovaPlugins:
296294 } )
297295 . join ( '\n' ) ;
298296 frameworkString = await replaceFrameworkVariables ( config , prefsArray , frameworkString ) ;
299- if ( kotlinNeeded ) {
300- frameworkString += `\n implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"` ;
301- frameworkString += `\n implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"` ;
302- }
303297 const applyString = applyArray . join ( '\n' ) ;
304298 let buildGradle = await readFile ( pluginsGradlePath , { encoding : 'utf-8' } ) ;
305299 buildGradle = buildGradle . replace (
@@ -310,28 +304,6 @@ export async function handleCordovaPluginsGradle(config: Config, cordovaPlugins:
310304 / ( P L U G I N G R A D L E E X T E N S I O N S S T A R T ) [ \s \S ] * ( \/ \/ P L U G I N G R A D L E E X T E N S I O N S E N D ) / ,
311305 '$1\n' + applyString . concat ( '\n' ) + '$2' ,
312306 ) ;
313- if ( kotlinNeeded ) {
314- buildGradle = buildGradle . replace (
315- / ( b u i l d s c r i p t \s { \n ( \t | \s { 4 } ) r e p o s i t o r i e s \s { \n ( ( \t { 2 } | \s { 8 } ) .+ \n ) + ( \t | \s { 4 } ) } \n ( \t | \s { 4 } ) d e p e n d e n c i e s \s { \n ( \t { 2 } | \s { 8 } ) .+ ) \n ( ( \t | \s { 4 } ) } \n } \n ) / ,
316- `$1\n classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n$8` ,
317- ) ;
318- buildGradle = buildGradle . replace (
319- / ( e x t \s { ) / ,
320- `$1\n androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.8.0'` ,
321- ) ;
322- buildGradle = buildGradle . replace (
323- / ( b u i l d s c r i p t \s { ) / ,
324- `$1\n ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '${ kotlinVersionString } '` ,
325- ) ;
326- buildGradle = buildGradle . replace (
327- / ( a p p l y \s p l u g i n : \s ' c o m \. a n d r o i d \. l i b r a r y ' ) / ,
328- `$1\napply plugin: 'kotlin-android'` ,
329- ) ;
330- buildGradle = buildGradle . replace (
331- / ( c o m p i l e O p t i o n s \s { \n ( ( \t { 2 } | \s { 8 } ) .+ \n ) + ( \t | \s { 4 } ) } ) \n ( } ) / ,
332- `$1\n sourceSets {\n main.java.srcDirs += 'src/main/kotlin'\n }\n$5` ,
333- ) ;
334- }
335307 await writeFile ( pluginsGradlePath , buildGradle ) ;
336308 const cordovaVariables = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
337309ext {
@@ -343,25 +315,6 @@ ext {
343315 await writeFile ( join ( config . android . cordovaPluginsDirAbs , 'cordova.variables.gradle' ) , cordovaVariables ) ;
344316}
345317
346- async function kotlinNeededCheck ( config : Config , cordovaPlugins : Plugin [ ] ) {
347- if ( config . app . extConfig . cordova ?. preferences ?. GradlePluginKotlinEnabled !== 'true' ) {
348- for ( const plugin of cordovaPlugins ) {
349- const androidPlatform = getPluginPlatform ( plugin , platform ) ;
350- const sourceFiles = androidPlatform [ 'source-file' ] ;
351- if ( sourceFiles ) {
352- for ( const srcFile of sourceFiles ) {
353- if ( / ^ .* \. k t $ / . test ( srcFile [ '$' ] . src ) ) {
354- return true ;
355- }
356- }
357- }
358- }
359- return false ;
360- } else {
361- return true ;
362- }
363- }
364-
365318async function copyPluginsNativeFiles ( config : Config , cordovaPlugins : Plugin [ ] ) {
366319 const pluginsPath = join ( config . android . cordovaPluginsDirAbs , 'src' , 'main' ) ;
367320 for ( const p of cordovaPlugins ) {
0 commit comments