From 5727952ed67131ae8ae565bbb107a3e57a586ad6 Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Fri, 27 Dec 2024 23:58:47 +0100 Subject: [PATCH] Move explicit API mode enabling to build-logic --- .../src/main/kotlin/ktorbuild.kmp.gradle.kts | 2 ++ .../kotlin/ktorbuild.project.internal.gradle.kts | 12 ++++++++++++ build.gradle.kts | 13 ------------- .../build.gradle.kts | 1 + ktor-client/ktor-client-tests/build.gradle.kts | 1 + ktor-server/ktor-server-test-base/build.gradle.kts | 4 ++++ .../ktor-server-test-suites/build.gradle.kts | 4 ++++ ktor-server/ktor-server-tests/build.gradle.kts | 1 + ktor-shared/ktor-test-base/build.gradle.kts | 4 ++++ 9 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 build-logic/src/main/kotlin/ktorbuild.project.internal.gradle.kts diff --git a/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts b/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts index 5966eca2a90..98235f9b4b6 100644 --- a/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts +++ b/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts @@ -16,6 +16,8 @@ plugins { } kotlin { + explicitApi() + compilerOptions { progressiveMode = true apiVersion = ktorBuild.kotlinApiVersion diff --git a/build-logic/src/main/kotlin/ktorbuild.project.internal.gradle.kts b/build-logic/src/main/kotlin/ktorbuild.project.internal.gradle.kts new file mode 100644 index 00000000000..507a672ea06 --- /dev/null +++ b/build-logic/src/main/kotlin/ktorbuild.project.internal.gradle.kts @@ -0,0 +1,12 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("ktorbuild.kmp") +} + +kotlin { + // Disable explicit API by default for internal projects + explicitApi = null +} diff --git a/build.gradle.kts b/build.gradle.kts index ce38f4cbe07..02f1101ea67 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,15 +25,6 @@ extra["nonDefaultProjectStructure"] = mutableListOf( "ktor-java-modules-test", ) -val disabledExplicitApiModeProjects = listOf( - "ktor-client-tests", - "ktor-server-test-base", - "ktor-server-test-suites", - "ktor-server-tests", - "ktor-client-content-negotiation-tests", - "ktor-test-base" -) - apply(from = "gradle/compatibility.gradle") plugins { @@ -58,10 +49,6 @@ subprojects { apply(plugin = "ktorbuild.kmp") apply(plugin = "atomicfu-conventions") - kotlin { - if (!disabledExplicitApiModeProjects.contains(project.name)) explicitApi() - } - val skipPublish: List by rootProject.extra if (!skipPublish.contains(project.name)) { configurePublication() diff --git a/ktor-client/ktor-client-plugins/ktor-client-content-negotiation/ktor-client-content-negotiation-tests/build.gradle.kts b/ktor-client/ktor-client-plugins/ktor-client-content-negotiation/ktor-client-content-negotiation-tests/build.gradle.kts index 45bd658f8b1..8a173f16968 100644 --- a/ktor-client/ktor-client-plugins/ktor-client-content-negotiation/ktor-client-content-negotiation-tests/build.gradle.kts +++ b/ktor-client/ktor-client-plugins/ktor-client-content-negotiation/ktor-client-content-negotiation-tests/build.gradle.kts @@ -5,6 +5,7 @@ description = "Common tests for client content negotiation" plugins { + id("ktorbuild.project.internal") id("kotlinx-serialization") } diff --git a/ktor-client/ktor-client-tests/build.gradle.kts b/ktor-client/ktor-client-tests/build.gradle.kts index f8112608d3f..5c776b80bea 100644 --- a/ktor-client/ktor-client-tests/build.gradle.kts +++ b/ktor-client/ktor-client-tests/build.gradle.kts @@ -5,6 +5,7 @@ description = "Common tests for client" plugins { + id("ktorbuild.project.internal") id("kotlinx-serialization") id("test-server") } diff --git a/ktor-server/ktor-server-test-base/build.gradle.kts b/ktor-server/ktor-server-test-base/build.gradle.kts index fcd28235c33..bc587ae3abf 100644 --- a/ktor-server/ktor-server-test-base/build.gradle.kts +++ b/ktor-server/ktor-server-test-base/build.gradle.kts @@ -4,6 +4,10 @@ description = "" +plugins { + id("ktorbuild.project.internal") +} + kotlin.sourceSets { commonMain { dependencies { diff --git a/ktor-server/ktor-server-test-suites/build.gradle.kts b/ktor-server/ktor-server-test-suites/build.gradle.kts index 8489588cb44..3e02dea950c 100644 --- a/ktor-server/ktor-server-test-suites/build.gradle.kts +++ b/ktor-server/ktor-server-test-suites/build.gradle.kts @@ -4,6 +4,10 @@ description = "" +plugins { + id("ktorbuild.project.internal") +} + kotlin.sourceSets { commonMain { dependencies { diff --git a/ktor-server/ktor-server-tests/build.gradle.kts b/ktor-server/ktor-server-tests/build.gradle.kts index 0ebd71ee958..ca724ea3590 100644 --- a/ktor-server/ktor-server-tests/build.gradle.kts +++ b/ktor-server/ktor-server-tests/build.gradle.kts @@ -5,6 +5,7 @@ description = "" plugins { + id("ktorbuild.project.internal") id("kotlinx-serialization") } diff --git a/ktor-shared/ktor-test-base/build.gradle.kts b/ktor-shared/ktor-test-base/build.gradle.kts index d7e45cbac83..da479ab470c 100644 --- a/ktor-shared/ktor-test-base/build.gradle.kts +++ b/ktor-shared/ktor-test-base/build.gradle.kts @@ -4,6 +4,10 @@ description = "Common extensions for testing Ktor" +plugins { + id("ktorbuild.project.internal") +} + kotlin.sourceSets { commonMain { dependencies {