-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTOR-7743 Create build-logic as a replacement for buildSrc (#4614)
* Create build-logic module, rename build-settings-logic for consistency * Define the project version in base plugin * Move dokka configuration to a precompiled script plugin * Define the group in gradle.properties
- Loading branch information
Showing
22 changed files
with
163 additions
and
50 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,22 @@ | ||
# build-logic | ||
|
||
Build logic shared between Ktor subprojects. | ||
|
||
This is similar to `buildSrc`, but uses [composite builds](https://docs.gradle.org/current/userguide/composite_builds.html) | ||
to prevent projects from becoming out-of-date on any change in `buildSrc`. | ||
|
||
This project should be included in the root `settings.gradle.kts`: | ||
|
||
`<root project dir>/settings.gradle.kts` | ||
```kotlin | ||
includeBuild("build-logic") | ||
``` | ||
|
||
`<root project dir>/build.gradle.kts` | ||
```kotlin | ||
plugins { | ||
id("ktorbuild.base") | ||
} | ||
``` | ||
|
||
*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).* |
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,21 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.kotlin.gradlePlugin) | ||
implementation(libs.dokka.gradlePlugin) | ||
|
||
// A hack to make version catalogs accessible from buildSrc sources | ||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 | ||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
} | ||
|
||
// Should be synced with gradle/gradle-daemon-jvm.properties | ||
kotlin { | ||
jvmToolchain(21) | ||
} |
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,21 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
pluginManagement { | ||
includeBuild("../build-settings-logic") | ||
} | ||
|
||
plugins { | ||
id("conventions-dependency-resolution-management") | ||
} | ||
|
||
dependencyResolutionManagement { | ||
// Additional repositories for build-logic | ||
@Suppress("UnstableApiUsage") | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" |
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 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import ktorbuild.internal.resolveVersion | ||
|
||
version = resolveVersion() |
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,26 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import ktorbuild.internal.libs | ||
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask | ||
|
||
plugins { | ||
id("org.jetbrains.dokka") | ||
} | ||
|
||
dependencies { | ||
dokkaPlugin(libs.dokka.plugin.versioning) | ||
} | ||
|
||
if (project == rootProject) { | ||
tasks.withType<DokkaMultiModuleTask>().configureEach { | ||
val version = project.version | ||
val dokkaOutputDir = "../versions" | ||
val id = "org.jetbrains.dokka.versioning.VersioningPlugin" | ||
val config = """{ "version": "$version", "olderVersionsDir":"$dokkaOutputDir" }""" | ||
|
||
outputDirectory = project.layout.projectDirectory.dir("$dokkaOutputDir/$version") | ||
pluginsMapConfiguration = mapOf(id to config) | ||
} | ||
} |
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,26 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package ktorbuild.internal | ||
|
||
import org.gradle.api.Project | ||
|
||
/** | ||
* Resolves the version for the current project based on the defined properties. | ||
* Properties "releaseVersion" and "eapVersion" are passed on CI as build parameters: | ||
* ``` | ||
* ./gradlew build -PreleaseVersion=3.0.0 | ||
* ``` | ||
*/ | ||
internal fun Project.resolveVersion(): String { | ||
val projectVersion = version.toString().removeSuffix("-SNAPSHOT") | ||
val releaseVersion = findProperty("releaseVersion")?.toString() | ||
val eapVersion = findProperty("eapVersion")?.toString() | ||
|
||
return when { | ||
releaseVersion != null -> releaseVersion | ||
eapVersion != null -> "$projectVersion-eap-$eapVersion" | ||
else -> projectVersion | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
build-logic/src/main/kotlin/ktorbuild/internal/VersionCatalogs.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,16 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package ktorbuild.internal | ||
|
||
import org.gradle.accessors.dm.LibrariesForLibs | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.the | ||
|
||
/** | ||
* Accessor to make version catalog available in build-logic. | ||
* See: https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 | ||
*/ | ||
internal val Project.libs: LibrariesForLibs | ||
get() = rootProject.the<LibrariesForLibs>() |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
kotlin.code.style=official | ||
|
||
# config | ||
group=io.ktor | ||
version=3.1.0-SNAPSHOT | ||
|
||
## Performance | ||
|
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
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
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
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