@@ -48,6 +48,7 @@ const plugins = [
4848] ;
4949const coreVersion = '^4.0.0' ;
5050const pluginVersion = '^4.0.0' ;
51+ const gradleVersion = '7.4.2' ;
5152
5253export async function migrateCommand ( config : Config ) : Promise < void > {
5354 if ( config === null ) {
@@ -246,7 +247,7 @@ export async function migrateCommand(config: Config): Promise<void> {
246247
247248 // Update gradle-wrapper.properties
248249 await runTask (
249- `Migrating gradle-wrapper.properties by updating gradle version from 7.0 to 7.4.2 .` ,
250+ `Migrating gradle-wrapper.properties by updating gradle version from 7.0 to ${ gradleVersion } .` ,
250251 ( ) => {
251252 return updateGradleWrapper (
252253 join (
@@ -348,6 +349,24 @@ export async function migrateCommand(config: Config): Promise<void> {
348349 return getCommandOutput ( 'npx' , [ 'cap' , 'sync' ] ) ;
349350 } ) ;
350351
352+ try {
353+ await runTask ( `Upgrading gradle wrapper files` , ( ) => {
354+ return updateGradleWrapperFiles ( config . android . platformDirAbs ) ;
355+ } ) ;
356+ } catch ( e ) {
357+ if ( e . includes ( 'EACCES' ) ) {
358+ logger . error (
359+ `gradlew file does not have executable permissions. This can happen if the Android platform was added on a Windows machine. Please run ${ c . input (
360+ `chmod +x ./${ config . android . platformDir } /gradlew` ,
361+ ) } and ${ c . input (
362+ `cd ${ config . android . platformDir } && ./gradlew wrapper --distribution-type all --gradle-version ${ gradleVersion } --warning-mode all` ,
363+ ) } to update the files manually`,
364+ ) ;
365+ } else {
366+ logger . error ( `gradle wrapper files were not updated` ) ;
367+ }
368+ }
369+
351370 // Write all breaking changes
352371 await runTask ( `Writing breaking changes.` , ( ) => {
353372 return writeBreakingChanges ( ) ;
@@ -661,11 +680,29 @@ async function updateGradleWrapper(filename: string) {
661680 'distributionUrl=' ,
662681 '\n' ,
663682 // eslint-disable-next-line no-useless-escape
664- `https\\://services.gradle.org/distributions/gradle-7.4.2 -all.zip` ,
683+ `https\\://services.gradle.org/distributions/gradle-${ gradleVersion } -all.zip` ,
665684 ) ;
666685 writeFileSync ( filename , replaced , 'utf-8' ) ;
667686}
668687
688+ async function updateGradleWrapperFiles ( platformDir : string ) {
689+ await runCommand (
690+ `./gradlew` ,
691+ [
692+ 'wrapper' ,
693+ '--distribution-type' ,
694+ 'all' ,
695+ '--gradle-version' ,
696+ gradleVersion ,
697+ '--warning-mode' ,
698+ 'all' ,
699+ ] ,
700+ {
701+ cwd : platformDir ,
702+ } ,
703+ ) ;
704+ }
705+
669706async function updateFile (
670707 config : Config ,
671708 filename : string ,
0 commit comments