Skip to content

Commit 151b01d

Browse files
committed
Use Kotlin DSL property assignment
1 parent 2373ec3 commit 151b01d

21 files changed

+115
-120
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies {
5454
}
5555

5656
nexusPublishing {
57-
packageGroup.set("org.junit")
57+
packageGroup = "org.junit"
5858
repositories {
5959
sonatype()
6060
}

documentation/documentation.gradle.kts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ val ota4jDocVersion = if (libs.versions.opentest4j.get().contains("SNAPSHOT")) "
8080
val apiGuardianDocVersion = if (libs.versions.apiguardian.get().contains("SNAPSHOT")) "snapshot" else libs.versions.apiguardian.get()
8181

8282
gitPublish {
83-
repoUri.set("https://github.com/junit-team/junit5.git")
84-
branch.set("gh-pages")
85-
sign.set(false)
86-
fetchDepth.set(1)
83+
repoUri = "https://github.com/junit-team/junit5.git"
84+
branch = "gh-pages"
85+
sign = false
86+
fetchDepth = 1
8787

8888
contents {
8989
from(docsDir)
@@ -142,7 +142,7 @@ tasks {
142142
}
143143

144144
register<RunConsoleLauncher>("consoleLauncher") {
145-
hideOutput.set(false)
145+
hideOutput = false
146146
outputs.upToDateWhen { false }
147147
}
148148

@@ -160,51 +160,51 @@ tasks {
160160

161161
val generateConsoleLauncherOptions by registering(CaptureJavaExecOutput::class) {
162162
classpath.from(sourceSets["test"].runtimeClasspath)
163-
mainClass.set("org.junit.platform.console.ConsoleLauncher")
163+
mainClass = "org.junit.platform.console.ConsoleLauncher"
164164
args.addAll("--help", "--disable-banner")
165-
outputFile.set(consoleLauncherOptionsFile)
165+
outputFile = consoleLauncherOptionsFile
166166
}
167167

168168
val generateConsoleLauncherDiscoverOptions by registering(CaptureJavaExecOutput::class) {
169169
classpath.from(sourceSets["test"].runtimeClasspath)
170-
mainClass.set("org.junit.platform.console.ConsoleLauncher")
170+
mainClass = "org.junit.platform.console.ConsoleLauncher"
171171
args.addAll("discover", "--help", "--disable-banner")
172-
outputFile.set(consoleLauncherDiscoverOptionsFile)
172+
outputFile = consoleLauncherDiscoverOptionsFile
173173
}
174174

175175
val generateConsoleLauncherExecuteOptions by registering(CaptureJavaExecOutput::class) {
176176
classpath.from(sourceSets["test"].runtimeClasspath)
177-
mainClass.set("org.junit.platform.console.ConsoleLauncher")
177+
mainClass = "org.junit.platform.console.ConsoleLauncher"
178178
args.addAll("execute", "--help", "--disable-banner")
179-
outputFile.set(consoleLauncherExecuteOptionsFile)
179+
outputFile = consoleLauncherExecuteOptionsFile
180180
}
181181

182182
val generateConsoleLauncherEnginesOptions by registering(CaptureJavaExecOutput::class) {
183183
classpath.from(sourceSets["test"].runtimeClasspath)
184-
mainClass.set("org.junit.platform.console.ConsoleLauncher")
184+
mainClass = "org.junit.platform.console.ConsoleLauncher"
185185
args.addAll("engines", "--help", "--disable-banner")
186-
outputFile.set(consoleLauncherEnginesOptionsFile)
186+
outputFile = consoleLauncherEnginesOptionsFile
187187
}
188188

189189
val generateExperimentalApisTable by registering(CaptureJavaExecOutput::class) {
190190
classpath.from(sourceSets["test"].runtimeClasspath)
191-
mainClass.set("org.junit.api.tools.ApiReportGenerator")
191+
mainClass = "org.junit.api.tools.ApiReportGenerator"
192192
jvmArgumentProviders += ClasspathSystemPropertyProvider("api.classpath", apiReport)
193193
args.add("EXPERIMENTAL")
194-
outputFile.set(experimentalApisTableFile)
194+
outputFile = experimentalApisTableFile
195195
}
196196

197197
val generateDeprecatedApisTable by registering(CaptureJavaExecOutput::class) {
198198
classpath.from(sourceSets["test"].runtimeClasspath)
199-
mainClass.set("org.junit.api.tools.ApiReportGenerator")
199+
mainClass = "org.junit.api.tools.ApiReportGenerator"
200200
jvmArgumentProviders += ClasspathSystemPropertyProvider("api.classpath", apiReport)
201201
args.add("DEPRECATED")
202-
outputFile.set(deprecatedApisTableFile)
202+
outputFile = deprecatedApisTableFile
203203
}
204204

205205
val generateStandaloneConsoleLauncherShadowedArtifactsFile by registering(GenerateStandaloneConsoleLauncherShadowedArtifactsFile::class) {
206206
inputJar.fileProvider(standaloneConsoleLauncher.elements.map { it.single().asFile })
207-
outputFile.set(standaloneConsoleLauncherShadowedArtifactsFile)
207+
outputFile = standaloneConsoleLauncherShadowedArtifactsFile
208208
}
209209

210210
withType<AbstractAsciidoctorTask>().configureEach {

gradle/plugins/build-parameters/build.gradle.kts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,69 @@ group = "junitbuild"
77
buildParameters {
88
pluginId("junitbuild.build-parameters")
99
bool("ci") {
10-
description.set("Whether or not this build is running in a CI environment")
11-
defaultValue.set(false)
10+
description = "Whether or not this build is running in a CI environment"
11+
defaultValue = false
1212
fromEnvironment()
1313
}
1414
integer("javaToolchainVersion") {
15-
description.set("Defines the Java toolchain version to use for compiling code")
15+
description = "Defines the Java toolchain version to use for compiling code"
1616
}
1717
group("buildCache") {
1818
string("username") {
19-
description.set("Username to authenticate with the remote build cache")
19+
description = "Username to authenticate with the remote build cache"
2020
fromEnvironment()
2121
}
2222
string("password") {
23-
description.set("Password to authenticate with the remote build cache")
23+
description = "Password to authenticate with the remote build cache"
2424
fromEnvironment()
2525
}
2626
string("url") {
27-
description.set("URL to the remote build cache")
27+
description = "URL to the remote build cache"
2828
fromEnvironment()
2929
}
3030
}
3131
group("documentation") {
32-
description.set("Parameters controlling how the documentation is built")
32+
description = "Parameters controlling how the documentation is built"
3333
bool("replaceCurrentDocs") {
34-
description.set("The documentation that is being deployed will replace what's currently deployed as 'current'")
35-
defaultValue.set(false)
34+
description = "The documentation that is being deployed will replace what's currently deployed as 'current'"
35+
defaultValue = false
3636
}
3737
}
3838
group("enterprise") {
39-
description.set("Parameters controlling Gradle Enterprise features")
39+
description = "Parameters controlling Gradle Enterprise features"
4040
group("predictiveTestSelection") {
4141
bool("enabled") {
42-
description.set("Whether or not to use Predictive Test Selection for selecting tests to execute")
43-
defaultValue.set(true)
42+
description = "Whether or not to use Predictive Test Selection for selecting tests to execute"
43+
defaultValue = true
4444
}
4545
}
4646
group("testDistribution") {
4747
bool("enabled") {
48-
description.set("Whether or not to use Test Distribution for executing tests")
49-
defaultValue.set(false)
48+
description = "Whether or not to use Test Distribution for executing tests"
49+
defaultValue = false
5050
fromEnvironment()
5151
}
5252
integer("maxLocalExecutors") {
53-
description.set("How many local executors to use for executing tests")
54-
defaultValue.set(1)
53+
description = "How many local executors to use for executing tests"
54+
defaultValue = 1
5555
}
5656
integer("maxRemoteExecutors") {
57-
description.set("How many remote executors to request for executing tests")
57+
description = "How many remote executors to request for executing tests"
5858
}
5959
}
6060
}
6161
group("testing") {
62-
description.set("Testing related parameters")
62+
description = "Testing related parameters"
6363
bool("enableJaCoCo") {
64-
description.set("Enables JaCoCo test coverage reporting")
65-
defaultValue.set(false)
64+
description = "Enables JaCoCo test coverage reporting"
65+
defaultValue = false
6666
}
6767
bool("enableJFR") {
68-
description.set("Enables Java Flight Recorder functionality")
69-
defaultValue.set(false)
68+
description = "Enables Java Flight Recorder functionality"
69+
defaultValue = false
7070
}
7171
integer("retries") {
72-
description.set("Configures the number of times failing test are retried")
72+
description = "Configures the number of times failing test are retried"
7373
}
7474
}
7575
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import org.gradle.api.attributes.TestSuiteType
2-
import org.gradle.kotlin.dsl.invoke
3-
import org.gradle.kotlin.dsl.`jacoco-report-aggregation`
4-
import org.gradle.testing.jacoco.plugins.JacocoCoverageReport
5-
61
plugins {
72
id("junitbuild.jacoco-conventions")
83
`jacoco-report-aggregation`
@@ -11,7 +6,7 @@ plugins {
116
reporting {
127
reports {
138
create<JacocoCoverageReport>("jacocoRootReport") {
14-
testType.set(TestSuiteType.UNIT_TEST)
9+
testType = TestSuiteType.UNIT_TEST
1510
}
1611
}
1712
}

gradle/plugins/common/src/main/kotlin/junitbuild.jacoco-java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tasks.withType<Test>().configureEach {
1717

1818
val codeCoverageClassesJar by tasks.registering(Jar::class) {
1919
from(tasks.jar.map { zipTree(it.archiveFile) })
20-
archiveClassifier.set("jacoco")
20+
archiveClassifier = "jacoco"
2121
enabled = project in mavenizedProjects
2222
duplicatesStrategy = DuplicatesStrategy.INCLUDE
2323
}

gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ eclipse {
3939
}
4040

4141
java {
42-
modularity.inferModulePath.set(false)
42+
modularity.inferModulePath = false
4343
}
4444

4545
if (project in mavenizedProjects) {
@@ -102,7 +102,7 @@ if (project in mavenizedProjects) {
102102
}
103103
}
104104
pom {
105-
description.set(provider { "Module \"${project.name}\" of JUnit 5." })
105+
description = provider { "Module \"${project.name}\" of JUnit 5." }
106106
}
107107
}
108108
}
@@ -156,11 +156,11 @@ val compileModule by tasks.registering(JavaCompile::class) {
156156
dependsOn(allMainClasses)
157157
enabled = project in modularProjects
158158
source = fileTree(combinedModuleSourceDir).builtBy(prepareModuleSourceDir)
159-
destinationDirectory.set(moduleOutputDir)
159+
destinationDirectory = moduleOutputDir
160160
sourceCompatibility = "9"
161161
targetCompatibility = "9"
162162
classpath = files()
163-
options.release.set(9)
163+
options.release = 9
164164
options.compilerArgs.addAll(listOf(
165165
// Suppress warnings for automatic modules: org.apiguardian.api, org.opentest4j
166166
"-Xlint:all,-requires-automatic,-requires-transitive-automatic",
@@ -177,7 +177,7 @@ val compileModule by tasks.registering(JavaCompile::class) {
177177
})
178178
options.compilerArgumentProviders.addAll(modularProjects.map { objects.newInstance(PatchModuleArgumentProvider::class, project, it) })
179179

180-
modularity.inferModulePath.set(false)
180+
modularity.inferModulePath = false
181181

182182
doFirst {
183183
options.allCompilerArgs.forEach {
@@ -260,15 +260,15 @@ afterEvaluate {
260260
tasks {
261261
compileJava {
262262
if (extension.configureRelease) {
263-
options.release.set(extension.mainJavaVersion.majorVersion.toInt())
263+
options.release = extension.mainJavaVersion.majorVersion.toInt()
264264
} else {
265265
sourceCompatibility = extension.mainJavaVersion.majorVersion
266266
targetCompatibility = extension.mainJavaVersion.majorVersion
267267
}
268268
}
269269
compileTestJava {
270270
if (extension.configureRelease) {
271-
options.release.set(extension.testJavaVersion.majorVersion.toInt())
271+
options.release = extension.testJavaVersion.majorVersion.toInt()
272272
} else {
273273
sourceCompatibility = extension.testJavaVersion.majorVersion
274274
targetCompatibility = extension.testJavaVersion.majorVersion
@@ -291,7 +291,7 @@ afterEvaluate {
291291

292292
checkstyle {
293293
toolVersion = requiredVersionFromLibs("checkstyle")
294-
configDirectory.set(rootProject.layout.projectDirectory.dir("gradle/config/checkstyle"))
294+
configDirectory = rootProject.layout.projectDirectory.dir("gradle/config/checkstyle")
295295
}
296296

297297
tasks {
@@ -308,6 +308,6 @@ pluginManager.withPlugin("java-test-fixtures") {
308308
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
309309
}
310310
tasks.named<JavaCompile>("compileTestFixturesJava") {
311-
options.release.set(extension.testJavaVersion.majorVersion.toInt())
311+
options.release = extension.testJavaVersion.majorVersion.toInt()
312312
}
313313
}

gradle/plugins/common/src/main/kotlin/junitbuild.java-multi-release-sources.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ listOf(9, 17).forEach { javaVersion ->
2626
}
2727

2828
named<JavaCompile>(sourceSet.get().compileJavaTaskName).configure {
29-
options.release.set(javaVersion)
29+
options.release = javaVersion
3030
}
3131

3232
named<Checkstyle>("checkstyle${sourceSet.name.capitalized()}").configure {

gradle/plugins/common/src/main/kotlin/junitbuild.java-toolchain-conventions.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ project.pluginManager.withPlugin("java") {
1111
val extension = the<JavaPluginExtension>()
1212
val javaToolchainService = the<JavaToolchainService>()
1313

14-
extension.toolchain.languageVersion.set(javaLanguageVersion)
14+
extension.toolchain.languageVersion = javaLanguageVersion
1515

1616
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
1717
configure<KotlinJvmProjectExtension> {
1818
jvmToolchain {
19-
languageVersion.set(javaLanguageVersion)
19+
languageVersion = javaLanguageVersion
2020
}
2121
}
2222
}
2323

2424
tasks.withType<JavaExec>().configureEach {
25-
javaLauncher.set(javaToolchainService.launcherFor(extension.toolchain))
25+
javaLauncher = javaToolchainService.launcherFor(extension.toolchain)
2626
}
2727

2828
tasks.withType<JavaCompile>().configureEach {
@@ -39,7 +39,7 @@ project.pluginManager.withPlugin("java") {
3939
tasks.withType<GroovyCompile>().configureEach {
4040
javaLauncher.set(javaToolchainService.launcherFor {
4141
// Groovy does not yet support JDK 19, see https://issues.apache.org/jira/browse/GROOVY-10569
42-
languageVersion.set(defaultLanguageVersion)
42+
languageVersion = defaultLanguageVersion
4343
})
4444
}
4545
}

gradle/plugins/common/src/main/kotlin/junitbuild.osgi-conventions.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ tasks.withType<Jar>().matching { task: Jar ->
7777
// task writes out the properties necessary for it to verify the OSGi
7878
// metadata.
7979
val osgiProperties by tasks.registering(WriteProperties::class) {
80-
destinationFile.set(layout.buildDirectory.file("verifyOSGiProperties.bndrun"))
80+
destinationFile = layout.buildDirectory.file("verifyOSGiProperties.bndrun")
8181
property("-standalone", true)
8282
project.extensions.getByType(JavaLibraryExtension::class.java).let { javaLibrary ->
8383
property("-runee", "JavaSE-${javaLibrary.mainJavaVersion}")
@@ -97,8 +97,8 @@ val osgiVerification by configurations.creatingResolvable {
9797
// that its metadata is valid. If the metadata is invalid this task will
9898
// fail.
9999
val verifyOSGi by tasks.registering(Resolve::class) {
100-
bndrun.set(osgiProperties.flatMap { it.destinationFile })
101-
outputBndrun.set(layout.buildDirectory.file("resolvedOSGiProperties.bndrun"))
100+
bndrun = osgiProperties.flatMap { it.destinationFile }
101+
outputBndrun = layout.buildDirectory.file("resolvedOSGiProperties.bndrun")
102102
isReportOptional = false
103103
// By default bnd will use jars found in:
104104
// 1. project.sourceSets.main.runtimeClasspath

0 commit comments

Comments
 (0)