Gradle¶
Properties¶
dir¶
properties¶
suspend fun Gradle.properties(text: String)
val Gradle.properties: Prepared<Path>
rootProject¶
val rootProject: Project
settingsGroovy¶
suspend fun Gradle.settingsGroovy(text: String)
Helper function to write the settings.gradle file.
Example
test("Create a groovy settings file") {
gradle.settingsGroovy("""
println "Loading the settings…"
""".trimIndent())
}
See also
-
settingsKts: Kotlin equivalent -
buildGroovy: Build script file
val Gradle.settingsGroovy: Prepared<Path>
Accessor for the settings.gradle file.
Example
See also
-
settingsKts: Kotlin equivalent -
buildGroovy: Build script file
settingsKts¶
suspend fun Gradle.settingsKts(text: String)
Helper function to write the settings.gradle.kts file.
Example
test("Create a Kotlin DSL settings file") {
gradle.settingsKts("""
println("Loading the settings…")
""".trimIndent())
}
See also
-
settingsGroovy: Groovy equivalent -
buildKts: Build script file
val Gradle.settingsKts: Prepared<Path>
Accessor for the settings.gradle.kts file.
Example
See also
-
settingsGroovy: Groovy equivalent -
buildKts: Build script file
Functions¶
project¶
Accessor for the files of a project, given its path.
Example
Create the modules/foo/build.gradle file:
test("Configure the :modules:foo project") {
gradle.project("modules/foo").buildGroovy("""
println "Configuring the project!"
""".trimIndent())
}
See also
-
rootProject: Access the root project -
runner: Execute the test and check the outputs
runner¶
suspend fun runner(): GradleRunner
Instantiates a GradleRunner in dir.
Examples
test("Create the root build.gradle.kts file") {
gradle.rootProject.buildKts("""
tasks.register("print") {
doLast {
println("Configuring the project")
}
}
""".trimIndent()
val result = gradle.runner()
.withPluginClasspath()
.withArguments("print")
.build()
result.output shouldContain "Configuring the project"
}
See also
-
GradleRunner.withPluginClasspath: When writing tests for a plugin, automatically adds it to the executed Gradle instance
-
GradleRunner.withArguments: Specify which tasks should be executed
-
GradleRunner.build: Executes the build, expecting a success
-
GradleRunner.buildAndFail: Executes the build, expecting a failure