Upgrade to Groovy 3.0.7

See gh-24946
This commit is contained in:
dreis2211 2021-01-20 19:18:00 +01:00 committed by Andy Wilkinson
parent a4919a047e
commit d4eccb7715
6 changed files with 25 additions and 22 deletions

View File

@ -1,7 +1,6 @@
package org.test
@Grab("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2") // This one just to test dependency resolution
import groovyx.net.http.*
import org.springframework.web.client.RestTemplate;
@Controller
class Example implements CommandLineRunner {
@ -17,7 +16,7 @@ class Example implements CommandLineRunner {
void run(String... args) {
def port = context.webServer.port
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
def world = new RestTemplate().getForObject("http://localhost:" + port + "/", String.class);
print "Hello " + world
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.ServiceLoader;
@ -216,16 +217,16 @@ public class GroovyCompiler {
@SuppressWarnings("rawtypes")
private void addAstTransformations(CompilationUnit compilationUnit) {
LinkedList[] phaseOperations = getPhaseOperations(compilationUnit);
processConversionOperations(phaseOperations[Phases.CONVERSION]);
Deque[] phaseOperations = getPhaseOperations(compilationUnit);
processConversionOperations((LinkedList) phaseOperations[Phases.CONVERSION]);
}
@SuppressWarnings("rawtypes")
private LinkedList[] getPhaseOperations(CompilationUnit compilationUnit) {
private Deque[] getPhaseOperations(CompilationUnit compilationUnit) {
try {
Field field = CompilationUnit.class.getDeclaredField("phaseOperations");
field.setAccessible(true);
return (LinkedList[]) field.get(compilationUnit);
return (Deque[]) field.get(compilationUnit);
}
catch (Exception ex) {
throw new IllegalStateException("Phase operations not available from compilation unit");
@ -235,7 +236,7 @@ public class GroovyCompiler {
@SuppressWarnings({ "rawtypes", "unchecked" })
private void processConversionOperations(LinkedList conversionOperations) {
int index = getIndexOfASTTransformationVisitor(conversionOperations);
conversionOperations.add(index, new CompilationUnit.SourceUnitOperation() {
conversionOperations.add(index, new CompilationUnit.ISourceUnitOperation() {
@Override
public void call(SourceUnit source) throws CompilationFailedException {
ASTNode[] nodes = new ASTNode[] { source.getAST() };
@ -270,11 +271,12 @@ public class GroovyCompiler {
throws CompilationFailedException {
ImportCustomizer importCustomizer = new SmartImportCustomizer(source);
ClassNode mainClassNode = MainClass.get(source.getAST().getClasses());
List<ClassNode> classNodes = source.getAST().getClasses();
ClassNode mainClassNode = MainClass.get(classNodes);
// Additional auto configuration
for (CompilerAutoConfiguration autoConfiguration : GroovyCompiler.this.compilerAutoConfigurations) {
if (autoConfiguration.matches(classNode)) {
if (classNodes.stream().anyMatch(autoConfiguration::matches)) {
if (GroovyCompiler.this.configuration.isGuessImports()) {
autoConfiguration.applyImports(importCustomizer);
importCustomizer.call(source, context, classNode);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -87,7 +87,8 @@ final class ResolveDependencyCoordinatesTransformationTests {
@Test
void transformationOfAnnotationOnImport() {
this.moduleNode.addImport(null, null, Arrays.asList(this.grabAnnotation));
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
this.moduleNode.addImport("alias", classNode, Arrays.asList(this.grabAnnotation));
assertGrabAnnotationHasBeenTransformed();
}
@ -100,14 +101,16 @@ final class ResolveDependencyCoordinatesTransformationTests {
@Test
void transformationOfAnnotationOnStaticImport() {
this.moduleNode.addStaticImport(null, null, null, Arrays.asList(this.grabAnnotation));
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
this.moduleNode.addStaticImport(classNode, "field", "alias", Arrays.asList(this.grabAnnotation));
assertGrabAnnotationHasBeenTransformed();
}
@Test
void transformationOfAnnotationOnStaticStarImport() {
this.moduleNode.addStaticStarImport(null, null, Arrays.asList(this.grabAnnotation));
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
this.moduleNode.addStaticStarImport("test", classNode, Arrays.asList(this.grabAnnotation));
assertGrabAnnotationHasBeenTransformed();
}

View File

@ -345,7 +345,7 @@ bom {
]
}
}
library("Groovy", "2.5.14") {
library("Groovy", "3.0.7") {
group("org.codehaus.groovy") {
imports = [
"groovy-bom"
@ -1320,9 +1320,6 @@ bom {
}
}
library("REST Assured", "4.2.1") {
prohibit("[4.3.0,)") {
because "it requires Groovy 3"
}
group("io.rest-assured") {
modules = [
"json-path",

View File

@ -8044,8 +8044,10 @@ Alternatively, you can specify a source for your test, which disables the behavi
==== Using Spock to Test Spring Boot Applications
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.
`spock-spring` integrates Spring's test framework into Spock.
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.
See http://spockframework.org/spock/docs/1.2/modules.html#_spring_module[the documentation for Spock's Spring module] for further details.
See http://spockframework.org/spock/docs/2.0-M4/modules.html#_spring_module[the documentation for Spock's Spring module] for further details.
NOTE: As of Spring Boot 2.5.x and its support for Groovy 3.x you have two options to make use of Spock:
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.

View File

@ -133,7 +133,7 @@ bom {
]
}
}
library("Spock Framework", "1.3-groovy-2.5") {
library("Spock Framework", "2.0-M4-groovy-3.0") {
group("org.spockframework") {
modules = [
"spock-core",