Skip to content

Commit

Permalink
Fix trivial Gradle deprecations (#2018)
Browse files Browse the repository at this point in the history
- Fix trivial Gradle deprecations
- Fix warning about nonspecified root-project name
- Do not use deprecated Test classpath conventions
  • Loading branch information
beatbrot authored Oct 18, 2024
1 parent cf89be0 commit f214a8a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions build-logic/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pluginManagement {
}
}

rootProject.name = "build-logic"
rootProject.buildFileName = 'build-logic.gradle'

dependencyResolutionManagement {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ tasks.register("collectTestXml") {


doFirst {
def target = file("$buildDir/collected-test-results")
def target = layout.buildDirectory.dir("collected-test-results").get().asFile
target.mkdirs()
reportingProjects.each { rp ->
rp.tasks.withType(Test).each { testTask ->
Expand Down Expand Up @@ -255,7 +255,7 @@ tasks.register("codeCoverageReport", JacocoReport) {
reports {
html.required = true
xml.required = true
xml.outputLocation = file("${buildDir}/reports/jacoco/report.xml") // report must be here for codecov to pick it up
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/report.xml") // report must be here for codecov to pick it up
csv.required = false
}
}
Expand Down
6 changes: 3 additions & 3 deletions spock-core/core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ tasks.named("processResources") {

tasks.register("coreConsole", JavaExec) {
description = 'Start a groovy Console with Spock Core Classpath, useful for AST-Inspection'
main = variant == 2.5 ? "groovy.ui.Console" : "groovy.console.ui.Console"
mainClass = variant == 2.5 ? "groovy.ui.Console" : "groovy.console.ui.Console"
classpath(sourceSets.named("main").map {it.runtimeClasspath }, configurations.named("coreConsoleRuntime"))
workingDir = file('build/console')
ignoreExitValue = true
ignoreExitValue true
args file('CoreConsole.groovy').absolutePath
doFirst {
workingDir.mkdirs()
Expand All @@ -109,7 +109,7 @@ tasks.register("coreConsole", JavaExec) {
// task writes out the properties necessary for it to verify the OSGi
// metadata.
def osgiProperties = tasks.register('osgiProperties', WriteProperties) {
outputFile = layout.getBuildDirectory().file("verifyOSGiProperties.bndrun")
destinationFile = layout.getBuildDirectory().file("verifyOSGiProperties.bndrun")
property('-standalone', true)
property('-runee', "JavaSE-${javaVersion < 9 ? '1.' + javaVersion : javaVersion}")
property('-runrequires', "osgi.identity;filter:='(osgi.identity=${project.name})'")
Expand Down
4 changes: 4 additions & 0 deletions spock-specs/mock-integration/mock-integration.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ def configureTaskFilters = { String key, Test t ->
codeGenerationLibraries.each { key, config ->
tasks.register("test${key.capitalize()}WithoutObjenesis", Test) {
systemProperty("org.spockframework.mock.testType", "${key.toLowerCase()} - objenesis")
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
classpath += config

configureTaskFilters(key, it)
}

tasks.register("test${key.capitalize()}WithObjenesis", Test) {
systemProperty("org.spockframework.mock.testType", "${key.toLowerCase()} + objenesis")
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
classpath += config
classpath += configurations.objenesis

Expand Down
2 changes: 1 addition & 1 deletion spock-specs/specs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tasks.named("test", Test) {
}

tasks.register("groovyConsole", JavaExec) {
main = variant == 2.5 ? "groovy.ui.Console" : "groovy.console.ui.Console"
mainClass = variant == 2.5 ? "groovy.ui.Console" : "groovy.console.ui.Console"
classpath(sourceSets.named("test").map {it.runtimeClasspath }, configurations.named("groovyConsole"))
}

Expand Down
4 changes: 2 additions & 2 deletions spock-testkit/testkit.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ tasks.named("test", Test) {

tasks.register("consoleLauncherTest", JavaExec) {
dependsOn(testClasses)
def reportsDir = file("$buildDir/test-results")
def reportsDir = layout.buildDirectory.dir("test-results")
outputs.dir(reportsDir)
classpath(sourceSets.named("test").map { it.runtimeClasspath })
main = "org.junit.platform.console.ConsoleLauncher"
mainClass = "org.junit.platform.console.ConsoleLauncher"
// jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
// args("--select-class", "spock.testkit.testsources.ExampleTestCase")
args("--select-class", "spock.testkit.testsources.UnrollTestCase")
Expand Down

0 comments on commit f214a8a

Please sign in to comment.