Skip to content

Commit b23860e

Browse files
committed
Fix publishComposeJbToMavenLocal
1 parent 2ff1112 commit b23860e

16 files changed

Lines changed: 130 additions & 66 deletions

File tree

buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ abstract class AndroidXImplPlugin @Inject constructor() : Plugin<Project> {
215215
it.configureWithAndroidXExtension(androidXExtension)
216216
}
217217
project.configureConstraintsWithinGroup(androidXExtension)
218-
project.validateProjectParser(androidXExtension)
218+
if (!org.jetbrains.androidx.build.isJetBrainsForkStructureEnabled(project)) project.validateProjectParser(androidXExtension)
219219
project.validateAllArchiveInputsRecognized()
220220
project.afterEvaluate {
221221
if (androidXExtension.shouldPublishSbom()) {

buildSrc/private/src/main/kotlin/org/jetbrains/androidx/build/JetBrainsAndroidXImplPlugin.kt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,20 @@ class JetBrainsAndroidXImplPlugin @Inject constructor(
159159
"JetBrainsAndroidXPlugin should be applied after AndroidXPlugin"
160160
}
161161

162-
val androidxExtension =
163-
project.extensions.getByType(AndroidXExtension::class.java)
164-
val androidxMultiplatformExtension =
165-
project.extensions.getByType(AndroidXMultiplatformExtension::class.java)
166-
project.changeMavenCoordinatesToJetBrains(androidxExtension)
167-
project.configureMavenArtifactUpload(
168-
androidxExtension, androidxMultiplatformExtension, componentFactory)
162+
if (isJetBrainsForkStructureEnabled(project)) {
163+
val androidxExtension =
164+
project.extensions.getByType(AndroidXExtension::class.java)
165+
val androidxMultiplatformExtension =
166+
project.extensions.getByType(AndroidXMultiplatformExtension::class.java)
167+
project.changeMavenCoordinatesToJetBrains(androidxExtension)
168+
project.configureMavenArtifactUpload(
169+
androidxExtension, androidxMultiplatformExtension, componentFactory
170+
)
169171

170-
project.plugins.all { plugin ->
171-
if (plugin is KotlinMultiplatformPluginWrapper) {
172-
onKotlinMultiplatformPluginApplied(project)
172+
project.plugins.all { plugin ->
173+
if (plugin is KotlinMultiplatformPluginWrapper) {
174+
onKotlinMultiplatformPluginApplied(project)
175+
}
173176
}
174177
}
175178
}

buildSrc/private/src/main/kotlin/org/jetbrains/androidx/build/JetBrainsAndroidXRootImplPlugin.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
package org.jetbrains.androidx.build
2020

21+
import androidx.build.AndroidXExtension
22+
import androidx.build.Publish
23+
import androidx.build.RunApiTasks
24+
import androidx.build.SoftwareType.ConfigurableSoftwareType
2125
import javax.inject.Inject
2226
import org.gradle.api.Plugin
2327
import org.gradle.api.Project
@@ -27,11 +31,23 @@ class JetBrainsAndroidXRootImplPlugin @Inject constructor(
2731
val componentFactory: SoftwareComponentFactory
2832
) : Plugin<Project> {
2933
override fun apply(project: Project) {
30-
project.allprojects {
31-
it.tasks.configureEach {
34+
project.subprojects { subproject ->
35+
subproject.tasks.configureEach {
3236
if (it.name == "kotlinStoreYarnLock") it.enabled = false
3337
if (it.name == "kotlinWasmStoreYarnLock") it.enabled = false
3438
}
39+
if (isJetBrainsForkStructureEnabled(project)) {
40+
subproject.afterEvaluate {
41+
val androidxExtension = subproject.extensions.findByType(AndroidXExtension::class.java)
42+
androidxExtension?.type = ConfigurableSoftwareType(
43+
name = "JB Library",
44+
// TODO(buildsrc) verify that it doesn't harm the JB publication
45+
// (it can disable optimizations or don't add some meta info
46+
publish = Publish.NONE,
47+
checkApi = RunApiTasks.No("JB Library"),
48+
)
49+
}
50+
}
3551
}
3652
}
3753
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.jetbrains.androidx.build
18+
19+
import org.gradle.api.Project
20+
21+
/**
22+
* True if the JetBrains build code is added:
23+
* - publication
24+
* - version/group changes
25+
* - JB-only API validation
26+
*/
27+
fun isJetBrainsForkStructureEnabled(project: Project) =
28+
project.findProperty("jetbrains.forkStructureEnabled") == "true"

buildSrc/private/src/main/kotlin/org/jetbrains/androidx/build/MavenUploadHelper.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package org.jetbrains.androidx.build
1818

1919
import androidx.build.AndroidXExtension
2020
import androidx.build.AndroidXMultiplatformExtension
21-
import androidx.build.Release
2221
import androidx.build.getRepositoryDirectory
2322
import androidx.build.hasAndroidMultiplatformPlugin
2423
import androidx.build.multiplatformExtension
@@ -69,14 +68,15 @@ import org.xml.sax.XMLReader
6968
import org.gradle.api.artifacts.ModuleIdentifier
7069
import org.gradle.api.artifacts.ModuleVersionIdentifier
7170
import org.gradle.api.internal.artifacts.DefaultModuleIdentifier
72-
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
7371

7472
fun Project.configureMavenArtifactUpload(
7573
extension: AndroidXExtension,
7674
kmpExtension: AndroidXMultiplatformExtension,
7775
componentFactory: SoftwareComponentFactory
7876
) {
7977
apply(mapOf("plugin" to "maven-publish"))
78+
79+
println("QQQ0 $this")
8080
var registered = false
8181
fun registerOnFirstPublishableArtifact(component: SoftwareComponent) {
8282
if (!registered) {
@@ -105,6 +105,9 @@ private fun Project.configureComponentPublishing(
105105
component: SoftwareComponent,
106106
componentFactory: SoftwareComponentFactory
107107
) {
108+
109+
println("QQQ2 $this")
110+
108111
val projectArchiveDir = File(
109112
getRepositoryDirectory(),
110113
"${group.toString().replace('.', '/')}/$name"
@@ -179,13 +182,21 @@ private fun Project.configureComponentPublishing(
179182
}
180183
}
181184
}
185+
println("QQQ6 $this")
186+
val g = this
182187
project.tasks.withType(GenerateMavenPom::class.java).configureEach { task ->
188+
println("QQQ7 $this")
183189
task.doLast {
190+
println("QQQ8 $this $g $task")
184191
fun hasTargetWithComponent(componentName: String) =
185192
multiplatformExtension?.targets?.find { target ->
186193
target.components.any { it.name == componentName }
187194
} != null
188195

196+
println("QQQ $this")
197+
println("QQQ $extensions")
198+
println("QQQ ${extensions.findByType(KotlinMultiplatformExtension::class.java)}")
199+
189200
// extract heuristically from:
190201
// "build/publications/kotlinMultiplatformDecorated/pom-default.xml"
191202
// "build/publications/desktop/pom-default.xml"
@@ -344,16 +355,6 @@ private val jetBrainsLibrariesWithAndroidTarget = setOf(
344355
)
345356
private fun Project.configureMultiplatformPublication(componentFactory: SoftwareComponentFactory) {
346357
if (project.path !in jetBrainsLibrariesWithAndroidTarget) return
347-
val multiplatformExtension = extensions.findByType<KotlinMultiplatformExtension>()!!
348-
multiplatformExtension.targets.all { target ->
349-
if (target is KotlinAndroidTarget) {
350-
target.publishLibraryVariants(
351-
Release.DEFAULT_PUBLISH_CONFIG,
352-
"debug"
353-
)
354-
}
355-
}
356-
357358
replaceBaseMultiplatformPublication(componentFactory)
358359
}
359360

buildSrc/public/src/main/kotlin/org/jetbrains/androidx/build/ComposePlatforms.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import org.gradle.api.Project
1414
enum class ComposePlatforms(vararg val alternativeNames: String) {
1515
KotlinMultiplatform("Common"),
1616
Desktop("Jvm"),
17-
AndroidDebug("Android"),
18-
AndroidRelease("Android"),
17+
Android("Android"),
1918
Js("Web"),
2019
WasmJs("Web"),
2120
MacosX64("Macos"),
@@ -53,8 +52,7 @@ enum class ComposePlatforms(vararg val alternativeNames: String) {
5352
companion object {
5453
val JVM_BASED = EnumSet.of(
5554
Desktop,
56-
AndroidDebug,
57-
AndroidRelease
55+
Android
5856
)
5957

6058
val UI_KIT = EnumSet.of(
@@ -83,8 +81,7 @@ enum class ComposePlatforms(vararg val alternativeNames: String) {
8381
)
8482

8583
val ANDROID = EnumSet.of(
86-
AndroidDebug,
87-
AndroidRelease
84+
Android
8885
)
8986

9087
val WINDOWS_NATIVE = EnumSet.of(

buildSrc/public/src/main/kotlin/org/jetbrains/androidx/build/JetBrainsPublication.kt

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ import org.jetbrains.androidx.build.JetBrainsPublication.projectPathToLibrary
2020
import java.io.Serializable
2121
import org.gradle.api.Project
2222

23+
// TODO(buildsrc) restore stubs publication, ideally both in integration and jb-main
24+
2325
/**
2426
* Library groups and associated with them projects and targets that are published when
2527
* building the JetBrains fork of AOSP.
2628
*/
2729
object JetBrainsPublication {
2830
val libraryToComponents = mapOf(
2931
"COMPOSE" to listOf(
32+
// STUBS
3033
// publish for compatibility
31-
ComposeComponent(":annotation:annotation", supportedPlatforms = ComposePlatforms.ALL - ComposePlatforms.ANDROID),
32-
ComposeComponent(":collection:collection", supportedPlatforms = ComposePlatforms.ALL - ComposePlatforms.ANDROID),
34+
//ComposeComponent(":annotation:annotation", supportedPlatforms = ComposePlatforms.ALL - ComposePlatforms.ANDROID),
35+
//ComposeComponent(":collection:collection", supportedPlatforms = ComposePlatforms.ALL - ComposePlatforms.ANDROID),
3336

3437
ComposeComponent(":compose:animation:animation"),
3538
ComposeComponent(":compose:animation:animation-core"),
@@ -38,8 +41,9 @@ object JetBrainsPublication {
3841
ComposeComponent(":compose:foundation:foundation-layout"),
3942
ComposeComponent(":compose:material:material"),
4043
ComposeComponent(":compose:material:material-ripple"),
41-
ComposeComponent(":compose:runtime:runtime", supportedPlatforms = ComposePlatforms.ALL),
42-
ComposeComponent(":compose:runtime:runtime-saveable", supportedPlatforms = ComposePlatforms.ALL),
44+
// STUBS
45+
//ComposeComponent(":compose:runtime:runtime", supportedPlatforms = ComposePlatforms.ALL),
46+
//ComposeComponent(":compose:runtime:runtime-saveable", supportedPlatforms = ComposePlatforms.ALL),
4347
ComposeComponent(":compose:ui:ui"),
4448
ComposeComponent(":compose:ui:ui-geometry"),
4549
ComposeComponent(
@@ -94,22 +98,23 @@ object JetBrainsPublication {
9498
ComposeComponent(":compose:material3:adaptive:adaptive-navigation"),
9599
),
96100
"LIFECYCLE" to listOf(
97-
ComposeComponent(
98-
path = ":lifecycle:lifecycle-common",
99-
// No android target here - jvm artefact will be used for android apps as well
100-
supportedPlatforms = ComposePlatforms.ALL_AOSP - ComposePlatforms.ANDROID
101-
),
102-
ComposeComponent(
103-
path = ":lifecycle:lifecycle-runtime",
104-
supportedPlatforms = ComposePlatforms.ALL_AOSP
105-
),
106-
ComposeComponent(
107-
path = ":lifecycle:lifecycle-viewmodel",
108-
supportedPlatforms = ComposePlatforms.ALL_AOSP
109-
),
110-
ComposeComponent(":lifecycle:lifecycle-viewmodel-savedstate", supportedPlatforms = ComposePlatforms.ALL_AOSP),
111-
ComposeComponent(":lifecycle:lifecycle-runtime-compose", supportedPlatforms = ComposePlatforms.ALL),
112-
ComposeComponent(":lifecycle:lifecycle-viewmodel-compose"),
101+
// STUBs
102+
// ComposeComponent(
103+
// path = ":lifecycle:lifecycle-common",
104+
// // No android target here - jvm artefact will be used for android apps as well
105+
// supportedPlatforms = ComposePlatforms.ALL_AOSP - ComposePlatforms.ANDROID
106+
// ),
107+
// ComposeComponent(
108+
// path = ":lifecycle:lifecycle-runtime",
109+
// supportedPlatforms = ComposePlatforms.ALL_AOSP
110+
// ),
111+
// ComposeComponent(
112+
// path = ":lifecycle:lifecycle-viewmodel",
113+
// supportedPlatforms = ComposePlatforms.ALL_AOSP
114+
// ),
115+
// ComposeComponent(":lifecycle:lifecycle-viewmodel-savedstate", supportedPlatforms = ComposePlatforms.ALL_AOSP),
116+
// ComposeComponent(":lifecycle:lifecycle-runtime-compose", supportedPlatforms = ComposePlatforms.ALL),
117+
// ComposeComponent(":lifecycle:lifecycle-viewmodel-compose"),
113118
),
114119
"NAVIGATION" to listOf(
115120
ComposeComponent(":navigation:navigation-compose"),
@@ -123,11 +128,13 @@ object JetBrainsPublication {
123128
ComposeComponent(":navigationevent:navigationevent-compose"),
124129
),
125130
"SAVEDSTATE" to listOf(
126-
ComposeComponent(":savedstate:savedstate", supportedPlatforms = ComposePlatforms.ALL_AOSP),
127-
ComposeComponent(":savedstate:savedstate-compose", supportedPlatforms = ComposePlatforms.ALL),
131+
// STUBs
132+
// ComposeComponent(":savedstate:savedstate", supportedPlatforms = ComposePlatforms.ALL_AOSP),
133+
// ComposeComponent(":savedstate:savedstate-compose", supportedPlatforms = ComposePlatforms.ALL),
128134
),
129135
"WINDOW" to listOf(
130-
ComposeComponent(":window:window-core", supportedPlatforms = ComposePlatforms.ALL_AOSP - ComposePlatforms.WINDOWS_NATIVE),
136+
// STUBS
137+
// ComposeComponent(":window:window-core", supportedPlatforms = ComposePlatforms.ALL_AOSP - ComposePlatforms.WINDOWS_NATIVE),
131138
),
132139
)
133140

compose/material3/material3-adaptive-navigation-suite/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ androidXMultiplatform {
3737
namespace = "androidx.compose.material3.adaptive.navigationsuite"
3838
compileSdk = 35
3939
}
40-
jvmStubs()
40+
desktop()
4141

4242
defaultPlatform(PlatformIdentifier.ANDROID)
4343

compose/mpp/demo/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
2020
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
2121

2222
plugins {
23+
//id("AndroidXPlugin")
2324
id("AndroidXComposePlugin")
2425
id("kotlin-multiplatform")
25-
id("JetBrainsAndroidXPlugin")
26+
//id("JetBrainsAndroidXPlugin")
2627
alias(libs.plugins.kotlinSerialization)
2728
}
2829

compose/ui/ui-tooling-data/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ androidXMultiplatform {
3636
namespace = "androidx.compose.ui.tooling.data"
3737
compileSdk = 35
3838
}
39-
jvmStubs()
39+
desktop()
4040

4141
defaultPlatform(PlatformIdentifier.ANDROID)
4242

0 commit comments

Comments
 (0)