Copilot commented on code in PR #16250:
URL: https://github.com/apache/grails-core/pull/16250#discussion_r3882683818


##########
grails-forge/grails-forge-web-netty/build.gradle:
##########
@@ -73,20 +73,23 @@ tasks.named('dockerBuild') {
     images = [findProperty('dockerImageName') ?: 'grailsforge']
 }
 
-TaskProvider<ShadowJar> shadowJarTask = tasks.named('shadowJar', ShadowJar)
-shadowJarTask.configure {
-    reproducibleFileOrder = true
-    preserveFileTimestamps = false
+['com.gradleup.shadow', 'com.github.johnrengelman.shadow'].each { pluginId ->
+    pluginManager.withPlugin(pluginId) {
+        tasks.named('shadowJar', ShadowJar).configure {
+            reproducibleFileOrder = true
+            preserveFileTimestamps = false
+        }
+    }
 }
 
 TaskProvider<Zip> awsElasticBeanstalk = tasks.register('awsElasticBeanstalk', 
Zip) {
-    dependsOn(shadowJarTask)
+    dependsOn('shadowJar')

Review Comment:
   `awsElasticBeanstalk` now hard-depends on a task named `shadowJar` and also 
resolves it via `tasks.named('shadowJar')`. If neither `com.gradleup.shadow` 
nor `com.github.johnrengelman.shadow` is applied to this project, 
configuration/task graph resolution will fail because `shadowJar` won’t exist. 
To make this robust, register/configure `awsElasticBeanstalk` only within 
`pluginManager.withPlugin(...)` (or apply the plugin explicitly for this 
module), so the task is only wired when `shadowJar` is present.



##########
grails-forge/grails-forge-web-netty/build.gradle:
##########
@@ -73,20 +73,23 @@ tasks.named('dockerBuild') {
     images = [findProperty('dockerImageName') ?: 'grailsforge']
 }
 
-TaskProvider<ShadowJar> shadowJarTask = tasks.named('shadowJar', ShadowJar)
-shadowJarTask.configure {
-    reproducibleFileOrder = true
-    preserveFileTimestamps = false
+['com.gradleup.shadow', 'com.github.johnrengelman.shadow'].each { pluginId ->
+    pluginManager.withPlugin(pluginId) {
+        tasks.named('shadowJar', ShadowJar).configure {
+            reproducibleFileOrder = true
+            preserveFileTimestamps = false
+        }
+    }
 }
 
 TaskProvider<Zip> awsElasticBeanstalk = tasks.register('awsElasticBeanstalk', 
Zip) {
-    dependsOn(shadowJarTask)
+    dependsOn('shadowJar')
     archiveFileName.set('grails-forge-web-netty-aws.zip')
     destinationDirectory.set(layout.buildDirectory.dir('distributions'))
     reproducibleFileOrder = true
     preserveFileTimestamps = false
 
-    from(shadowJarTask.flatMap { it.archiveFile }) {
+    from({ tasks.named('shadowJar').get().archiveFile.get() }) {

Review Comment:
   `awsElasticBeanstalk` now hard-depends on a task named `shadowJar` and also 
resolves it via `tasks.named('shadowJar')`. If neither `com.gradleup.shadow` 
nor `com.github.johnrengelman.shadow` is applied to this project, 
configuration/task graph resolution will fail because `shadowJar` won’t exist. 
To make this robust, register/configure `awsElasticBeanstalk` only within 
`pluginManager.withPlugin(...)` (or apply the plugin explicitly for this 
module), so the task is only wired when `shadowJar` is present.



##########
grails-forge/grails-forge-web-netty/build.gradle:
##########
@@ -73,20 +73,23 @@ tasks.named('dockerBuild') {
     images = [findProperty('dockerImageName') ?: 'grailsforge']
 }
 
-TaskProvider<ShadowJar> shadowJarTask = tasks.named('shadowJar', ShadowJar)
-shadowJarTask.configure {
-    reproducibleFileOrder = true
-    preserveFileTimestamps = false
+['com.gradleup.shadow', 'com.github.johnrengelman.shadow'].each { pluginId ->
+    pluginManager.withPlugin(pluginId) {
+        tasks.named('shadowJar', ShadowJar).configure {
+            reproducibleFileOrder = true
+            preserveFileTimestamps = false
+        }
+    }
 }
 
 TaskProvider<Zip> awsElasticBeanstalk = tasks.register('awsElasticBeanstalk', 
Zip) {
-    dependsOn(shadowJarTask)
+    dependsOn('shadowJar')
     archiveFileName.set('grails-forge-web-netty-aws.zip')
     destinationDirectory.set(layout.buildDirectory.dir('distributions'))
     reproducibleFileOrder = true
     preserveFileTimestamps = false
 
-    from(shadowJarTask.flatMap { it.archiveFile }) {
+    from({ tasks.named('shadowJar').get().archiveFile.get() }) {

Review Comment:
   This uses eager task realization (`.get()`) and eager provider resolution 
(`archiveFile.get()`), which undermines configuration avoidance and can 
break/limit Gradle configuration caching. Prefer wiring `from(...)` using a 
lazy `Provider` (e.g., `tasks.named('shadowJar', ShadowJar).flatMap { 
it.archiveFile }`) so the task and its outputs are only realized when needed.



##########
.github/workflows/forge-deploy-aws.yml:
##########
@@ -276,14 +183,8 @@ jobs:
             local exit_code=$?
             trap - ERR
             if [[ "${update_started}" == true && "${rollback_available}" == 
true ]]; then
-              echo "Deployment failed. Rolling back ${ENVIRONMENT_NAME} to its 
previous application version."
-              if aws elasticbeanstalk update-environment --environment-name 
"${ENVIRONMENT_NAME}" --version-label "${previous_version}" >/dev/null && 
wait_for_ready_green 'Rollback' "${previous_version}"; then
-                echo "Rollback completed."
-              else
-                echo "Rollback did not reach Status=Ready and Health=Green. 
Manual intervention is required." >&2
-              fi
-            elif [[ "${update_started}" == true ]]; then
-              echo "Deployment failed, but no prior application version is 
available for rollback." >&2
+              echo "Deployment failed. Rolling back ${ENVIRONMENT_NAME}."
+              aws elasticbeanstalk update-environment --environment-name 
"${ENVIRONMENT_NAME}" --version-label "${previous_version}" >/dev/null || true

Review Comment:
   Rollback behavior no longer waits for the environment to return to 
`Ready/Green` (and it also ignores rollback failures with `|| true`). This 
reduces operational safety by potentially leaving the environment 
mid-transition without surfacing it in the job output. Consider reusing 
`wait_for_ready_green` for rollback (or at least checking and logging the 
`update-environment` result and the subsequent environment status) so failures 
are observable and the rollback completion is verified.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to