-
Notifications
You must be signed in to change notification settings - Fork 8
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
0 parents
commit 8aa0464
Showing
55 changed files
with
4,916 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
|
||
# Exclude external libs from GitHub language stats https://github.com/github/linguist/blob/v7.24.1/docs/overrides.md | ||
externals/*/** linguist-vendored |
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,7 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
.idea |
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,54 @@ | ||
# Dokkatoo | ||
|
||
Generates documentation from Kotlin code. | ||
|
||
Based on Kotlin Dokka. | ||
|
||
* Compatible with Gradle Build Cache | ||
* Compatible with Gradle Configuration Cache | ||
* Safe cross-project sharing and aggregation | ||
|
||
## Usage | ||
|
||
```kts | ||
// build.gradle.kts | ||
|
||
plugins { | ||
id("dev.adamko.dokkatoo") version "0.0.1-SNAPSHOT" | ||
} | ||
|
||
dokkatoo { | ||
// ... | ||
} | ||
``` | ||
|
||
```shell | ||
# generate all sites | ||
./gradlew dokkatooGenerate | ||
|
||
# only generate a single format | ||
./gradlew dokkatooGenerateHtml | ||
./gradlew dokkatooGenerateGfm | ||
./gradlew dokkatooGenerateJekyll | ||
./gradlew dokkatooGenerateJavadoc | ||
``` | ||
|
||
### Combining subprojects | ||
|
||
Any subproject can aggregate multiple subprojects into one Dokka Publication. | ||
|
||
```kts | ||
// ./build.gradle.kts | ||
|
||
plugins { | ||
kotlin("jvm") version "1.8.0" apply false // required by Gradle | ||
id("dev.adamko.dokkatoo") version "0.0.1-SNAPSHOT" | ||
} | ||
|
||
dependencies { | ||
// aggregate both subproject-hello and subproject-world | ||
// the subprojects must also have Dokkatoo applied | ||
dokkatoo(projects(":subproject-hello")) | ||
dokkatoo(projects(":subproject-world")) | ||
} | ||
``` |
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,6 @@ | ||
plugins { | ||
buildsrc.conventions.base | ||
} | ||
|
||
group = "dev.adamko" | ||
version = "0.0.1-SNAPSHOT" |
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,3 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} |
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,19 @@ | ||
rootProject.name = "buildSrc" | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature | ||
dependencyResolutionManagement { | ||
|
||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
buildSrc/src/main/kotlin/buildsrc/conventions/base.gradle.kts
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,62 @@ | ||
package buildsrc.conventions | ||
|
||
import buildsrc.conventions.utils.asConsumer | ||
import buildsrc.conventions.utils.asProvider | ||
import buildsrc.conventions.utils.dropDirectories | ||
import java.time.Duration | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
|
||
plugins { | ||
base | ||
} | ||
|
||
// common config for all projects | ||
|
||
if (project != rootProject) { | ||
project.version = rootProject.version | ||
project.group = rootProject.group | ||
} | ||
|
||
tasks.withType<AbstractArchiveTask>().configureEach { | ||
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives | ||
isPreserveFileTimestamps = false | ||
isReproducibleFileOrder = true | ||
} | ||
|
||
tasks.withType<AbstractTestTask>().configureEach { | ||
timeout.set(Duration.ofMinutes(10)) | ||
|
||
testLogging { | ||
showCauses = true | ||
showExceptions = true | ||
showStackTraces = true | ||
showStandardStreams = true | ||
events( | ||
TestLogEvent.PASSED, | ||
TestLogEvent.FAILED, | ||
TestLogEvent.SKIPPED, | ||
TestLogEvent.STARTED, | ||
TestLogEvent.STANDARD_ERROR, | ||
TestLogEvent.STANDARD_OUT, | ||
) | ||
} | ||
} | ||
|
||
tasks.withType<AbstractCopyTask>().configureEach { | ||
includeEmptyDirs = false | ||
} | ||
|
||
|
||
val kotlinDokkaSource by configurations.registering { | ||
asConsumer() | ||
attributes { | ||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("rocksdb-src")) | ||
} | ||
} | ||
|
||
val kotlinDokkaSourceElements by configurations.registering { | ||
asProvider() | ||
attributes { | ||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("rocksdb-src")) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
buildSrc/src/main/kotlin/buildsrc/conventions/gradle-plugin-variants.gradle.kts
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,52 @@ | ||
package buildsrc.conventions.buildsrc.conventions | ||
|
||
import gradle.kotlin.dsl.accessors._1aa7e5c26223e2b5ce19d03a79e08c0e.java | ||
import gradle.kotlin.dsl.accessors._1aa7e5c26223e2b5ce19d03a79e08c0e.pluginDescriptors | ||
import gradle.kotlin.dsl.accessors._1aa7e5c26223e2b5ce19d03a79e08c0e.sourceSets | ||
import org.gradle.api.attributes.plugin.GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.`java-gradle-plugin` | ||
import org.gradle.kotlin.dsl.named | ||
|
||
plugins { | ||
`java-gradle-plugin` | ||
} | ||
|
||
fun registerGradleVariant(name: String, gradleVersion: String) { | ||
val variantSources = sourceSets.create(name) | ||
|
||
java { | ||
registerFeature(variantSources.name) { | ||
usingSourceSet(variantSources) | ||
// capability("${project.group}", "${project.name}", "${project.version}") | ||
capability("org.jetbrains.dokka", "${project.name}", "2.0.0") | ||
|
||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
} | ||
|
||
configurations | ||
.matching { it.isCanBeConsumed && it.name.startsWith(variantSources.name) } | ||
.configureEach { | ||
attributes { | ||
attribute(GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(gradleVersion)) | ||
} | ||
} | ||
|
||
tasks.named<Copy>(variantSources.processResourcesTaskName) { | ||
val copyPluginDescriptors = rootSpec.addChild() | ||
copyPluginDescriptors.into("META-INF/gradle-plugins") | ||
// copyPluginDescriptors.into(tasks.pluginDescriptors.flatMap { it.outputDirectory }) | ||
copyPluginDescriptors.from(tasks.pluginDescriptors) | ||
} | ||
|
||
dependencies { | ||
add(variantSources.compileOnlyConfigurationName, gradleApi()) | ||
} | ||
} | ||
|
||
//registerGradleVariant("gradle5", "5.0") | ||
//registerGradleVariant("gradle6", "6.0") | ||
registerGradleVariant("gradle7", "7.0") | ||
registerGradleVariant("gradle8", "8.0") |
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 @@ | ||
package buildsrc.distributions |
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,50 @@ | ||
package buildsrc.conventions.utils | ||
|
||
import org.gradle.api.artifacts.Configuration | ||
import org.gradle.api.file.RelativePath | ||
|
||
/** | ||
* Mark this [Configuration] as one that will be consumed by other subprojects. | ||
* | ||
* ``` | ||
* isCanBeResolved = false | ||
* isCanBeConsumed = true | ||
* ``` | ||
*/ | ||
fun Configuration.asProvider() { | ||
isCanBeResolved = false | ||
isCanBeConsumed = true | ||
} | ||
|
||
/** | ||
* Mark this [Configuration] as one that will consume artifacts from other subprojects (also known as 'resolving') | ||
* | ||
* ``` | ||
* isCanBeResolved = true | ||
* isCanBeConsumed = false | ||
* ``` | ||
* */ | ||
fun Configuration.asConsumer() { | ||
isCanBeResolved = true | ||
isCanBeConsumed = false | ||
} | ||
|
||
|
||
/** Drop the first [count] directories from the path */ | ||
fun RelativePath.dropDirectories(count: Int): RelativePath = | ||
RelativePath(true, *segments.drop(count).toTypedArray()) | ||
|
||
|
||
/** Drop the first directory from the path */ | ||
fun RelativePath.dropDirectory(): RelativePath = | ||
dropDirectories(1) | ||
|
||
|
||
/** Drop the first directory from the path */ | ||
fun RelativePath.dropDirectoriesWhile( | ||
segmentPrediate: (segment: String) -> Boolean | ||
): RelativePath = | ||
RelativePath( | ||
true, | ||
*segments.dropWhile(segmentPrediate).toTypedArray(), | ||
) |
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 @@ | ||
kotlin-dokka/ |
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,45 @@ | ||
import buildsrc.conventions.utils.* | ||
|
||
plugins { | ||
buildsrc.conventions.base | ||
} | ||
|
||
|
||
// | ||
//val kotlinDokkaSource by configurations.creating<Configuration> { | ||
// asConsumer() | ||
// attributes { | ||
// attribute(Usage.USAGE_ATTRIBUTE, objects.named("rocksdb-src")) | ||
// } | ||
//} | ||
|
||
dependencies { | ||
kotlinDokkaSource("kotlin:dokka:1.7.20@zip") | ||
} | ||
|
||
val kotlinDokkaPrepareSource by tasks.registering(Sync::class) { | ||
group = "externals" | ||
description = "Download & unpack Kotlin Dokka source code" | ||
from( | ||
@Suppress("UnstableApiUsage") | ||
configurations.kotlinDokkaSource.flatMap { src -> | ||
src.incoming | ||
.artifactView { lenient(true) } | ||
.artifacts | ||
.resolvedArtifacts | ||
.map { artifacts -> artifacts.map { zipTree(it.file) } } | ||
} | ||
) { | ||
// drop the first dir (rocksdb-$version) | ||
eachFile { | ||
relativePath = relativePath.dropDirectories(1) | ||
} | ||
} | ||
into(layout.projectDirectory.dir("kotlin-dokka")) | ||
} | ||
|
||
configurations.kotlinDokkaSourceElements.configure { | ||
outgoing { | ||
artifact(kotlinDokkaPrepareSource.map { it.destinationDir }) | ||
} | ||
} |
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,11 @@ | ||
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx2g -XX:MaxMetaspaceSize=1g | ||
|
||
org.gradle.caching=true | ||
# https://github.com/gradle/gradle/issues/20416 | ||
systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true | ||
|
||
org.gradle.unsafe.configuration-cache=true | ||
org.gradle.unsafe.configuration-cache-problems=warn | ||
|
||
org.gradle.parallel=true | ||
org.gradle.welcome=never |
Binary file not shown.
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,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.