Skip to content

Commit ead8b6f

Browse files
authored
Merge branch 'main' into bjhham/pinger-failure-fix
2 parents 51988c5 + a870be2 commit ead8b6f

File tree

54 files changed

+318
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+318
-222
lines changed

build-logic/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# build-logic
2+
3+
Build logic shared between Ktor subprojects.
4+
5+
This is similar to `buildSrc`, but uses [composite builds](https://docs.gradle.org/current/userguide/composite_builds.html)
6+
to prevent projects from becoming out-of-date on any change in `buildSrc`.
7+
8+
This project should be included in the root `settings.gradle.kts`:
9+
10+
`<root project dir>/settings.gradle.kts`
11+
```kotlin
12+
includeBuild("build-logic")
13+
```
14+
15+
`<root project dir>/build.gradle.kts`
16+
```kotlin
17+
plugins {
18+
id("ktorbuild.base")
19+
}
20+
```
21+
22+
*The structure of this project is inspired by the structure used in [Dokka](https://github.com/Kotlin/dokka/tree/v2.0.0/build-logic/src/main/kotlin) and [Gradle](https://github.com/gradle/gradle/tree/v8.12.0/build-logic/jvm/src/main/kotlin).*

build-logic/build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
plugins {
6+
`kotlin-dsl`
7+
}
8+
9+
dependencies {
10+
implementation(libs.kotlin.gradlePlugin)
11+
implementation(libs.dokka.gradlePlugin)
12+
13+
// A hack to make version catalogs accessible from buildSrc sources
14+
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
15+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
16+
}
17+
18+
// Should be synced with gradle/gradle-daemon-jvm.properties
19+
kotlin {
20+
jvmToolchain(21)
21+
}

build-logic/settings.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
pluginManagement {
6+
includeBuild("../build-settings-logic")
7+
}
8+
9+
plugins {
10+
id("conventions-dependency-resolution-management")
11+
}
12+
13+
dependencyResolutionManagement {
14+
// Additional repositories for build-logic
15+
@Suppress("UnstableApiUsage")
16+
repositories {
17+
gradlePluginPortal()
18+
}
19+
}
20+
21+
rootProject.name = "build-logic"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import ktorbuild.internal.resolveVersion
6+
7+
version = resolveVersion()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import ktorbuild.internal.libs
6+
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
7+
8+
plugins {
9+
id("org.jetbrains.dokka")
10+
}
11+
12+
dependencies {
13+
dokkaPlugin(libs.dokka.plugin.versioning)
14+
}
15+
16+
if (project == rootProject) {
17+
tasks.withType<DokkaMultiModuleTask>().configureEach {
18+
val version = project.version
19+
val dokkaOutputDir = "../versions"
20+
val id = "org.jetbrains.dokka.versioning.VersioningPlugin"
21+
val config = """{ "version": "$version", "olderVersionsDir":"$dokkaOutputDir" }"""
22+
23+
outputDirectory = project.layout.projectDirectory.dir("$dokkaOutputDir/$version")
24+
pluginsMapConfiguration = mapOf(id to config)
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package ktorbuild.internal
6+
7+
import org.gradle.api.Project
8+
9+
/**
10+
* Resolves the version for the current project based on the defined properties.
11+
* Properties "releaseVersion" and "eapVersion" are passed on CI as build parameters:
12+
* ```
13+
* ./gradlew build -PreleaseVersion=3.0.0
14+
* ```
15+
*/
16+
internal fun Project.resolveVersion(): String {
17+
val projectVersion = version.toString().removeSuffix("-SNAPSHOT")
18+
val releaseVersion = findProperty("releaseVersion")?.toString()
19+
val eapVersion = findProperty("eapVersion")?.toString()
20+
21+
return when {
22+
releaseVersion != null -> releaseVersion
23+
eapVersion != null -> "$projectVersion-eap-$eapVersion"
24+
else -> projectVersion
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package ktorbuild.internal
6+
7+
import org.gradle.accessors.dm.LibrariesForLibs
8+
import org.gradle.api.Project
9+
import org.gradle.kotlin.dsl.the
10+
11+
/**
12+
* Accessor to make version catalog available in build-logic.
13+
* See: https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
14+
*/
15+
internal val Project.libs: LibrariesForLibs
16+
get() = rootProject.the<LibrariesForLibs>()

gradle-settings-conventions/build.gradle.kts renamed to build-settings-logic/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ dependencies {
1515
implementation(libs.develocity)
1616
implementation(libs.develocity.commonCustomUserData)
1717
}
18+
19+
// Should be synced with gradle/gradle-daemon-jvm.properties
20+
kotlin {
21+
jvmToolchain(21)
22+
}

gradle-settings-conventions/settings.gradle.kts renamed to build-settings-logic/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ dependencyResolutionManagement {
1010
}
1111
}
1212

13-
rootProject.name = "gradle-settings-conventions"
13+
rootProject.name = "build-settings-logic"

gradle-settings-conventions/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts renamed to build-settings-logic/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts

File renamed without changes.

0 commit comments

Comments
 (0)