Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate buildSrc to composite build #2652

Closed
wants to merge 9 commits into from
7 changes: 7 additions & 0 deletions build-logic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# About Build-logic Module

This module aims to share common build logic for whole projects, previously we were using [buildSrc](https://docs.gradle.org/7.6/userguide/organizing_gradle_projects.html#sec:build_sources),
but for some reasons like "A change in buildSrc causes the whole project to become out-of-date", we are migrating to [composite builds](https://docs.gradle.org/7.6/userguide/composite_builds.html),
which avoids the side effects of buildSrc.

For more information, you can ref https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3.
11 changes: 10 additions & 1 deletion buildSrc/build.gradle.kts → build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ repositories {
gradlePluginPortal()
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
}

gradlePlugin {
plugins {
create("build-logic") {
id = "build-logic"
implementationClass = "org.jetbrains.BuildLogic"
}
}
}
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved

dependencies {
implementation("com.github.jengelman.gradle.plugins:shadow:2.0.4")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.10.1")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.11.1")
implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
}
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty.
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/org/jetbrains/BuildLogic.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.jetbrains

import org.gradle.api.Plugin
import org.gradle.api.Project

class BuildLogic : Plugin<Project> {
override fun apply(project: Project) {
// Do nothing.
}
}
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ plugins {
kotlin("jvm") apply false
id("java")
id("org.jetbrains.dokka") version "1.7.20"
id("io.github.gradle-nexus.publish-plugin")
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("build-logic") apply false
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
}

val dokka_version: String by project

allprojects {
apply(plugin = "build-logic")
configureDokkaVersion()

group = "org.jetbrains.dokka"
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
rootProject.name = "dokka"

includeBuild("build-logic")

include("core")
include("core:test-api")
include("core:content-matcher-test-utils")
Expand Down