Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Gradle 7.5.1 #1499

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ext {
junitPlatformTestkit: [group: 'org.junit.platform', name: 'junit-platform-testkit'],
junitPlatformConsole: [group: 'org.junit.platform', name: 'junit-platform-console'],
log4j : [group: 'log4j', name: 'log4j', version: '1.2.17'],
objenesis : [group: 'org.objenesis', name: 'objenesis', version: '3.2'],
objenesis : [group: 'org.objenesis', name: 'objenesis', version: '3.3'],
jacocoAgent : [group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.8', classifier: 'runtime']
]
}
Expand Down Expand Up @@ -122,8 +122,10 @@ subprojects {
}

tasks.withType(JavaCompile) {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
if (it.name == 'compileJava') {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
options.encoding = 'UTF-8'
}
Expand Down Expand Up @@ -183,7 +185,6 @@ subprojects {
from javadoc
}

def javaVersionNoShadow = javaVersion // Test task also has javaVersion
tasks.withType(Test) {
useJUnitPlatform()
def taskName = name
Expand Down
17 changes: 17 additions & 0 deletions config/nohttp/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
Workaround for https://github.com/spring-io/nohttp/issues/55#issuecomment-1191149821
-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value=""/>
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck">
<property name="allowlistFileName" value="${config_loc}/allowlist.lines" default=""/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml" default=""/>
<property name="optional" value="true"/>
</module>
<module name="SuppressWithPlainTextCommentFilter"/>
</module>
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
# https://gradle.org/release-checksums/
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ public static void deepCopyFields(Object source, Object target) {
Class<?> clazz = source.getClass();
while (!clazz.equals(Object.class)) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
copyField(field, source, target);
}
Arrays.stream(fields)
.filter(field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())))
.forEach(field -> copyField(field, source, target));
clazz = clazz.getSuperclass();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class ConditionEvaluation extends EmbeddedSpecification {

def "PropertyExpression"() {
expect:
[1, 2, 3].size == 3
new Person(age: 3).age == 3
(new Properties().next.next.next.x = 10) == 10
Integer.MIN_VALUE < Integer.MAX_VALUE
}
Expand Down Expand Up @@ -404,4 +404,3 @@ class ConditionEvaluation extends EmbeddedSpecification {
def eat(args) { args }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ null
def "PropertyExpression"() {
expect:
isRendered """
a.size == null
| | |
| 1 false
a.empty == true
| | |
| false false
[9]
""", {
def a = [9]
assert a.size == null
assert a.empty == true
}

isRendered """
Expand Down Expand Up @@ -903,4 +903,3 @@ false
String toString() { "p" }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.spockframework.smoke.mock

import spock.lang.*
import spock.util.environment.Jvm

import java.lang.reflect.Modifier
import java.util.regex.Pattern
Expand Down Expand Up @@ -173,7 +174,8 @@ class GroovySpiesThatAreGlobal extends Specification {
}

def "mock static method"() {
GroovySpy(Collections, global: true)
// Use objenesis to create instance for Java 17 and later
GroovySpy(Collections, global: true, useObjenesis: Jvm.current.java17Compatible)

when:
Collections.emptyList()
Expand All @@ -186,7 +188,7 @@ class GroovySpiesThatAreGlobal extends Specification {
}

def "mock dynamic static method"() {
GroovySpy(Collections, global: true)
GroovySpy(Collections, global: true, useObjenesis: Jvm.current.java17Compatible)

when:
Collections.foo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class JavaSpies extends Specification {
e.message.contains("global")
}


@IgnoreIf(
value = { jvm.java17Compatible },
reason = "We can't access private fields in java.util anymore, without an explicit --add-opens"
)
@Issue("https://github.com/spockframework/spock/issues/822")
def "inferred type is ignored for instance mocks"() {
when:
Expand Down Expand Up @@ -301,4 +306,3 @@ class JavaSpies extends Specification {
}
}
}

93 changes: 75 additions & 18 deletions spock-spring/spring.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id 'jvm-test-suite'
}

apply from: script("publishMaven")

ext.displayName = "Spock Framework - Spring Module"
Expand All @@ -6,33 +10,85 @@ description = "Spock's Spring Module makes it possible to use Spring's TestConte
Supports Spring 2.5.x, 3.x, and 4.x."

def springVersion = "4.3.5.RELEASE"
def testSpringVersions = [
"3.2.16.RELEASE": (8..8),
(springVersion): (8..11),
"5.0.2.RELEASE": (8..11),
"6.0.0-M5": (17..17)
].findAll { javaVersion in it.value }

if (springVersion.startsWith("2.")) {
sourceSets.test.groovy.exclude "**/*ContextHierarchyExample.groovy"
// necessary until we have a final version of Spring 6
repositories {
mavenCentral()
maven {
url = "https://repo.spring.io/artifactory/libs-milestone-local/"
content {
includeGroup "org.springframework"
}
}
}

dependencies {
api project(":spock-core")
compileOnly "org.springframework:spring-test:$springVersion"
compileOnly "org.springframework:spring-beans:$springVersion"
compileOnly "org.springframework:spring-context:$springVersion"
}

testing {
suites {
all {
useJUnitJupiter()
dependencies {
implementation "javax.inject:javax.inject:1"
implementation libs.groovySql // for groovy.sql.Sql
implementation libs.junitPlatformTestkit
runtimeOnly libs.h2database
runtimeOnly libs.log4j
runtimeOnly libs.bytebuddy
runtimeOnly libs.cglib
runtimeOnly libs.objenesis
}
}

// not used directly at implementation-time, but needed by groovyc
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation "org.springframework:spring-beans:$springVersion"
testImplementation "org.springframework:spring-context:$springVersion"
testImplementation "org.springframework:spring-core:$springVersion"
testImplementation "org.springframework:spring-jdbc:$springVersion"
testImplementation "org.springframework:spring-tx:$springVersion"
testImplementation "javax.inject:javax.inject:1"
testImplementation libs.groovySql // for groovy.sql.Sql
testImplementation libs.junitPlatformTestkit

testRuntimeOnly libs.h2database
testRuntimeOnly libs.log4j
testRuntimeOnly libs.bytebuddy
testRuntimeOnly libs.cglib
testRuntimeOnly libs.objenesis
test {
targets {
all {
testTask.configure {
onlyIf { false } //skip normal test task
}
}
}
}


testSpringVersions.each { testSpringVersion, __ ->
"spring${testSpringVersion.charAt(0)}"(JvmTestSuite) {

sources {
java {
srcDir 'src/test/java'
}
groovy {
srcDir 'src/test/groovy'
}
resources {
srcDir 'src/test/resources'
}
}

dependencies {
implementation project
implementation "org.springframework:spring-test:$testSpringVersion"
implementation "org.springframework:spring-beans:$testSpringVersion"
implementation "org.springframework:spring-context:$testSpringVersion"
implementation "org.springframework:spring-core:$testSpringVersion"
implementation "org.springframework:spring-jdbc:$testSpringVersion"
implementation "org.springframework:spring-tx:$testSpringVersion"
}
}
}
}
}

task testCglib(type: Test) {
Expand All @@ -41,6 +97,7 @@ task testCglib(type: Test) {
}

check.dependsOn testCglib
check.dependsOn testSpringVersions.collect {k,v -> "spring${k.charAt(0)}" }

jar {
manifest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,39 @@
package org.spockframework.spring

import org.spockframework.mock.MockUtil
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import spock.lang.IgnoreIf
import spock.lang.Specification

import javax.inject.Named

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration

@IgnoreIf(
value = { jvm.java17Compatible },
reason = "Spring 4s reflection doesn't work on 17+"
)
@ContextConfiguration(locations = "MockExamples-context.xml")
class MockInjectionExample extends Specification {

@Autowired @Named('serviceMock')
@Autowired
@Named('serviceMock')
IService1 serviceMock


@Autowired @Named('serviceStub')
@Autowired
@Named('serviceStub')
IService1 serviceStub

@Autowired @Named('serviceSpy')
@Autowired
@Named('serviceSpy')
IService2 serviceSpy

@Autowired @Named('service2')
@Autowired
@Named('service2')
IService2 service2

@Autowired @Named('nonMock')
@Autowired
@Named('nonMock')
ArrayList concreteSpy;

def "Injected services are mocks"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.spockframework.spring.docs

import spock.lang.IgnoreIf
import spock.lang.Specification

import javax.inject.Named
Expand Down Expand Up @@ -81,6 +82,10 @@ class DetachedJavaConfigExample extends MockExampleBase {
}


@IgnoreIf(
value = { jvm.java17Compatible },
reason = "Spring 4s reflection doesn't work on 17+"
)
@ContextConfiguration(locations = "classpath:org/spockframework/spring/docs/MockDocu-context.xml")
class DetachedXmlExample extends MockExampleBase {
}