-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When DGP is used in a pre-compiled script plugin, correctly generate …
…accessors and disable warning logs (#3770) Gradle generates accessors in a temp project that doesn't have Gradle properties. This breaks the `enableV2` flag. This workaround detects when Gradle is generating accessors, and if so, tries to discover the `gradle.properties`.
- Loading branch information
Showing
2 changed files
with
267 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...a-runners/dokka-gradle-plugin/src/testFunctional/kotlin/BuildSrcKotlinDslAccessorsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
package org.jetbrains.dokka.gradle | ||
|
||
import io.kotest.core.spec.style.FunSpec | ||
import org.gradle.testkit.runner.TaskOutcome.* | ||
import org.jetbrains.dokka.gradle.internal.DokkaConstants | ||
import org.jetbrains.dokka.gradle.utils.* | ||
|
||
class BuildSrcKotlinDslAccessorsTest : FunSpec({ | ||
|
||
val project = initProjectWithBuildSrcConvention() | ||
|
||
context("when DGPv2 is enabled") { | ||
project | ||
.runner | ||
.addArguments( | ||
":compileKotlin", | ||
"--project-dir", "buildSrc", | ||
) | ||
.build { | ||
test("expect DGPv2 can be used in a convention plugin") { | ||
shouldHaveTasksWithAnyOutcome(":compileKotlin" to listOf(SUCCESS, UP_TO_DATE, FROM_CACHE)) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
private fun initProjectWithBuildSrcConvention( | ||
rootProjectName: String? = null, | ||
config: GradleProjectTest.() -> Unit = {}, | ||
): GradleProjectTest { | ||
|
||
return gradleKtsProjectTest( | ||
projectLocation = "BuildSrcKotlinDslAccessorsTest", | ||
rootProjectName = rootProjectName, | ||
) { | ||
|
||
buildGradleKts = """ | ||
|plugins { | ||
| kotlin("jvm") version embeddedKotlinVersion | ||
| id("org.jetbrains.dokka") version "${DokkaConstants.DOKKA_VERSION}" | ||
|} | ||
| | ||
""".trimMargin() | ||
|
||
dir("buildSrc") { | ||
buildGradleKts = """ | ||
|plugins { | ||
| `kotlin-dsl` | ||
|} | ||
| | ||
|dependencies { | ||
| implementation("org.jetbrains.dokka:dokka-gradle-plugin:${DokkaConstants.DOKKA_VERSION}") | ||
|} | ||
| | ||
""".trimMargin() | ||
|
||
|
||
settingsGradleKts = """ | ||
|rootProject.name = "buildSrc" | ||
| | ||
|${settingsRepositories()} | ||
| | ||
""".trimMargin() | ||
|
||
createFile( | ||
"src/main/kotlin/dokka-convention.gradle.kts", | ||
/* language=TEXT */ """ | ||
|plugins { | ||
| id("org.jetbrains.dokka") | ||
|} | ||
| | ||
|dokka { | ||
| moduleName.set("custom-module-name") | ||
|} | ||
| | ||
""".trimMargin() | ||
) | ||
} | ||
|
||
gradleProperties { | ||
dokka { | ||
v2Plugin = true | ||
v2MigrationHelpers = true | ||
} | ||
} | ||
|
||
config() | ||
} | ||
} |