Skip to content

Commit d4eccb7

Browse files
dreis2211wilkinsona
authored andcommitted
Upgrade to Groovy 3.0.7
See spring-projectsgh-24946
1 parent a4919a0 commit d4eccb7

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

spring-boot-project/spring-boot-cli/samples/http.groovy

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.test
22

3-
@Grab("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2") // This one just to test dependency resolution
4-
import groovyx.net.http.*
3+
import org.springframework.web.client.RestTemplate;
54

65
@Controller
76
class Example implements CommandLineRunner {
@@ -17,7 +16,7 @@ class Example implements CommandLineRunner {
1716

1817
void run(String... args) {
1918
def port = context.webServer.port
20-
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
19+
def world = new RestTemplate().getForObject("http://localhost:" + port + "/", String.class);
2120
print "Hello " + world
2221
}
2322

spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.net.URL;
2222
import java.util.ArrayList;
2323
import java.util.Collections;
24+
import java.util.Deque;
2425
import java.util.LinkedList;
2526
import java.util.List;
2627
import java.util.ServiceLoader;
@@ -216,16 +217,16 @@ public Class<?>[] compile(String... sources) throws CompilationFailedException,
216217

217218
@SuppressWarnings("rawtypes")
218219
private void addAstTransformations(CompilationUnit compilationUnit) {
219-
LinkedList[] phaseOperations = getPhaseOperations(compilationUnit);
220-
processConversionOperations(phaseOperations[Phases.CONVERSION]);
220+
Deque[] phaseOperations = getPhaseOperations(compilationUnit);
221+
processConversionOperations((LinkedList) phaseOperations[Phases.CONVERSION]);
221222
}
222223

223224
@SuppressWarnings("rawtypes")
224-
private LinkedList[] getPhaseOperations(CompilationUnit compilationUnit) {
225+
private Deque[] getPhaseOperations(CompilationUnit compilationUnit) {
225226
try {
226227
Field field = CompilationUnit.class.getDeclaredField("phaseOperations");
227228
field.setAccessible(true);
228-
return (LinkedList[]) field.get(compilationUnit);
229+
return (Deque[]) field.get(compilationUnit);
229230
}
230231
catch (Exception ex) {
231232
throw new IllegalStateException("Phase operations not available from compilation unit");
@@ -235,7 +236,7 @@ private LinkedList[] getPhaseOperations(CompilationUnit compilationUnit) {
235236
@SuppressWarnings({ "rawtypes", "unchecked" })
236237
private void processConversionOperations(LinkedList conversionOperations) {
237238
int index = getIndexOfASTTransformationVisitor(conversionOperations);
238-
conversionOperations.add(index, new CompilationUnit.SourceUnitOperation() {
239+
conversionOperations.add(index, new CompilationUnit.ISourceUnitOperation() {
239240
@Override
240241
public void call(SourceUnit source) throws CompilationFailedException {
241242
ASTNode[] nodes = new ASTNode[] { source.getAST() };
@@ -270,11 +271,12 @@ public void call(SourceUnit source, GeneratorContext context, ClassNode classNod
270271
throws CompilationFailedException {
271272

272273
ImportCustomizer importCustomizer = new SmartImportCustomizer(source);
273-
ClassNode mainClassNode = MainClass.get(source.getAST().getClasses());
274+
List<ClassNode> classNodes = source.getAST().getClasses();
275+
ClassNode mainClassNode = MainClass.get(classNodes);
274276

275277
// Additional auto configuration
276278
for (CompilerAutoConfiguration autoConfiguration : GroovyCompiler.this.compilerAutoConfigurations) {
277-
if (autoConfiguration.matches(classNode)) {
279+
if (classNodes.stream().anyMatch(autoConfiguration::matches)) {
278280
if (GroovyCompiler.this.configuration.isGuessImports()) {
279281
autoConfiguration.applyImports(importCustomizer);
280282
importCustomizer.call(source, context, classNode);

spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,7 +87,8 @@ void setUpExpectations() {
8787

8888
@Test
8989
void transformationOfAnnotationOnImport() {
90-
this.moduleNode.addImport(null, null, Arrays.asList(this.grabAnnotation));
90+
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
91+
this.moduleNode.addImport("alias", classNode, Arrays.asList(this.grabAnnotation));
9192
assertGrabAnnotationHasBeenTransformed();
9293
}
9394

@@ -100,14 +101,16 @@ void transformationOfAnnotationOnStarImport() {
100101

101102
@Test
102103
void transformationOfAnnotationOnStaticImport() {
103-
this.moduleNode.addStaticImport(null, null, null, Arrays.asList(this.grabAnnotation));
104+
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
105+
this.moduleNode.addStaticImport(classNode, "field", "alias", Arrays.asList(this.grabAnnotation));
104106

105107
assertGrabAnnotationHasBeenTransformed();
106108
}
107109

108110
@Test
109111
void transformationOfAnnotationOnStaticStarImport() {
110-
this.moduleNode.addStaticStarImport(null, null, Arrays.asList(this.grabAnnotation));
112+
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
113+
this.moduleNode.addStaticStarImport("test", classNode, Arrays.asList(this.grabAnnotation));
111114

112115
assertGrabAnnotationHasBeenTransformed();
113116
}

spring-boot-project/spring-boot-dependencies/build.gradle

+1-4
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ bom {
345345
]
346346
}
347347
}
348-
library("Groovy", "2.5.14") {
348+
library("Groovy", "3.0.7") {
349349
group("org.codehaus.groovy") {
350350
imports = [
351351
"groovy-bom"
@@ -1320,9 +1320,6 @@ bom {
13201320
}
13211321
}
13221322
library("REST Assured", "4.2.1") {
1323-
prohibit("[4.3.0,)") {
1324-
because "it requires Groovy 3"
1325-
}
13261323
group("io.rest-assured") {
13271324
modules = [
13281325
"json-path",

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

+4-2
Original file line numberDiff line numberDiff line change
@@ -8044,8 +8044,10 @@ Alternatively, you can specify a source for your test, which disables the behavi
80448044
==== Using Spock to Test Spring Boot Applications
80458045
If you wish to use Spock to test a Spring Boot application, you should add a dependency on Spock's `spock-spring` module to your application's build.
80468046
`spock-spring` integrates Spring's test framework into Spock.
8047-
It is recommended that you use Spock 1.2 or later to benefit from a number of improvements to Spock's Spring Framework and Spring Boot integration.
8048-
See http://spockframework.org/spock/docs/1.2/modules.html#_spring_module[the documentation for Spock's Spring module] for further details.
8047+
See http://spockframework.org/spock/docs/2.0-M4/modules.html#_spring_module[the documentation for Spock's Spring module] for further details.
8048+
8049+
NOTE: As of Spring Boot 2.5.x and its support for Groovy 3.x you have two options to make use of Spock:
8050+
Either use the latest Spock 2.0 milestone or release that is compatible with Groovy 3.x or stick with Spock 1.3 and downgrade Spring Boot's Groovy version to 2.5.x.
80498051

80508052

80518053

spring-boot-project/spring-boot-parent/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bom {
133133
]
134134
}
135135
}
136-
library("Spock Framework", "1.3-groovy-2.5") {
136+
library("Spock Framework", "2.0-M4-groovy-3.0") {
137137
group("org.spockframework") {
138138
modules = [
139139
"spock-core",

0 commit comments

Comments
 (0)