bryan-hunter commented on code in PR #1678:
URL: https://github.com/apache/cordova-android/pull/1678#discussion_r1545883119


##########
lib/builders/ProjectBuilder.js:
##########
@@ -116,16 +114,17 @@ class ProjectBuilder {
         return args;
     }
 
-    /*
-    * This returns a promise
-    */
-    runGradleWrapper (gradle_cmd) {
-        const gradlePath = path.join(this.root, 'gradlew');
-        const wrapperGradle = path.join(this.root, 'wrapper.gradle');
-        if (fs.existsSync(gradlePath)) {
-            // Literally do nothing, for some reason this works, while 
!fs.existsSync didn't on Windows
+    /**
+     * Installs/updates the gradle wrapper
+     * @param {string} gradleVersion The gradle version to install. Ignored if 
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL environment variable is defined
+     * @returns {Promise<void>}
+     */
+    async installGradleWrapper (gradleVersion) {
+        if (process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL) {
+            events.emit('verbose', `Overriding Gradle Version via 
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL 
(${process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL})`);
+            await execa('gradle', ['-p', this.root, 'wrapper', 
'--gradle-distribution-url', 
process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL], { stdio: 'inherit' });
         } else {
-            return execa(gradle_cmd, ['-p', this.root, 'wrapper', '-b', 
wrapperGradle], { stdio: 'inherit' });
+            await execa('gradle', ['-p', this.root, 'wrapper', 
'--gradle-version', gradleVersion], { stdio: 'inherit' });

Review Comment:
   was upgrading some stuff myself and used this as reference.
   
   I was getting this error:
   
   ```
   FAILURE: Build failed with an exception.
   
   * What went wrong:
   A problem was found with the configuration of task ':app:wrapper' (type 
'Wrapper').
     - In plugin 'org.gradle.buildinit.plugins.BuildInitPlugin$Inject' type 
'org.gradle.api.tasks.wrapper.Wrapper' property 'validateDistributionUrl' 
doesn't have a configured value.
       
       Reason: This property isn't marked as optional and no value has been 
configured.
       
       Possible solutions:
         1. Assign a value to 'validateDistributionUrl'.
         2. Mark property 'validateDistributionUrl' as optional.
       
       For more information, please refer to 
https://docs.gradle.org/8.7/userguide/validation_problems.html#value_not_set in 
the Gradle documentation.
       ```
       
       I added `'--validate-url'` to both of these gradle wrapper commands and 
the error went away.  There may be a better way, but figured I'd help if it 
comes up for anyone else



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to