-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
build-logic/src/main/kotlin/dokkabuild/utils/DokkaGradleExampleDirectoriesSource.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,36 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
package dokkabuild.utils | ||
|
||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.provider.ValueSource | ||
import org.gradle.api.provider.ValueSourceParameters | ||
import java.io.File | ||
import kotlin.io.path.isDirectory | ||
import kotlin.io.path.listDirectoryEntries | ||
import kotlin.io.path.name | ||
|
||
/** | ||
* Fetch the example directories in `dokka/examples/gradle-v2` using a [ValueSource]. | ||
* | ||
* A [ValueSource] is necessary to ensure that Gradle registers the directory values as Configuration Cache inputs, | ||
* but doesn't become overly sensitive to the contents of the directories. | ||
*/ | ||
abstract class DokkaGradleExampleDirectoriesSource : | ||
ValueSource<List<File>, DokkaGradleExampleDirectoriesSource.Parameters> { | ||
|
||
interface Parameters : ValueSourceParameters { | ||
/** | ||
* The directory containing the Dokka Gradle v2 examples: `dokka/examples/gradle-v2` | ||
*/ | ||
val exampleGradleProjectsDir: DirectoryProperty | ||
} | ||
|
||
override fun obtain(): List<File> { | ||
return parameters.exampleGradleProjectsDir.get().asFile.toPath() | ||
.listDirectoryEntries() | ||
.filter { it.isDirectory() && it.name.endsWith("-example") } | ||
.map { it.toFile() } | ||
} | ||
} |
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