Upgrade to Groovy 3.0.7

See gh-24946
pull/24964/head
dreis2211 4 years ago committed by Andy Wilkinson
parent a4919a047e
commit d4eccb7715

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

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -87,7 +87,8 @@ final class ResolveDependencyCoordinatesTransformationTests {
@Test @Test
void transformationOfAnnotationOnImport() { 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(); assertGrabAnnotationHasBeenTransformed();
} }
@ -100,14 +101,16 @@ final class ResolveDependencyCoordinatesTransformationTests {
@Test @Test
void transformationOfAnnotationOnStaticImport() { 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(); assertGrabAnnotationHasBeenTransformed();
} }
@Test @Test
void transformationOfAnnotationOnStaticStarImport() { 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(); assertGrabAnnotationHasBeenTransformed();
} }

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

@ -8044,8 +8044,10 @@ Alternatively, you can specify a source for your test, which disables the behavi
==== Using Spock to Test Spring Boot Applications ==== 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. 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. `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/2.0-M4/modules.html#_spring_module[the documentation for Spock's Spring module] for further details.
See http://spockframework.org/spock/docs/1.2/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.

@ -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") { group("org.spockframework") {
modules = [ modules = [
"spock-core", "spock-core",

Loading…
Cancel
Save