jamesfredley commented on code in PR #15403:
URL: https://github.com/apache/grails-core/pull/15403#discussion_r2825054824


##########
grails-gradle/plugins/src/test/java/org/grails/gradle/plugin/core/GrailsGradlePluginToolchainTest.java:
##########
@@ -0,0 +1,399 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.gradle.plugin.core;
+
+import org.gradle.testkit.runner.BuildResult;
+import org.gradle.testkit.runner.GradleRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Tests that {@link GrailsGradlePlugin} propagates the project's Java 
toolchain
+ * to JavaExec tasks via {@code javaLauncher.convention()}.
+ *
+ * <p>Without the fix, JavaExec tasks spawned by Grails (dbm-* migration
+ * commands, console, shell, application context commands) use the JDK
+ * running Gradle instead of the project's configured toolchain. This
+ * causes {@code UnsupportedClassVersionError} when the project targets
+ * a different JDK version than the one running Gradle.</p>
+ *
+ * <p>NOTE: Cannot use Spock here because grails-gradle-tasks transitively
+ * pulls {@code org.apache.groovy:groovy:4.0.30} which conflicts with
+ * Gradle's built-in {@code org.codehaus.groovy:groovy:3.0.25}.</p>
+ *
+ * @since 7.0.8
+ */
+class GrailsGradlePluginToolchainTest {

Review Comment:
   Done. Rewrote the entire test as `GrailsGradlePluginToolchainSpec` extending 
`GradleSpecification`. Resolved the Groovy conflict by excluding 
`org.apache.groovy` from the test classpath (see comment on `build.gradle`). 
All 8 tests pass as Spock specs.



##########
grails-gradle/plugins/build.gradle:
##########
@@ -56,6 +56,15 @@ dependencies {
     implementation 'org.springframework.boot:spring-boot-gradle-plugin'
     implementation 'org.springframework.boot:spring-boot-loader-tools'
     implementation 'io.spring.gradle:dependency-management-plugin'
+
+    // Testing - Gradle TestKit is auto-added by java-gradle-plugin
+    // NOTE: Cannot use Spock here because grails-gradle-tasks transitively
+    // pulls org.apache.groovy:groovy:4.0.30 which conflicts with

Review Comment:
   `grails-gradle-tasks/build.gradle` line 42 explicitly declares 
`implementation 'org.apache.groovy:groovy:4.0.30'` because its source code uses 
Groovy 4 APIs (it's not a Gradle plugin itself, just utility classes consumed 
by the plugins module). Added an exclusion of the `org.apache.groovy` group 
from the test configurations in `plugins/build.gradle` so Spock runs against 
Gradle's bundled Groovy 3 without conflicts.



-- 
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