This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Jetpack Compose preview support | #BAZEL-868
[fix] Explicitly build the Android Kotlin target during build [feature] buildTarget/jvmBinaryJars request for Jetpack Compose preview [maintenance] AndroidBuildTarget should use String instead of URI to conform with BSP [maintenance] Move Android resource calculation to the Android plugin Merge-request: BAZEL-MR-947 Merged-by: Lev Leontev <[email protected]>
- Loading branch information
1 parent
da0d47e
commit dc830f8
Showing
15 changed files
with
135 additions
and
28 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
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
16 changes: 16 additions & 0 deletions
16
protocol/src/main/kotlin/org/jetbrains/bsp/JvmBinaryJars.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 @@ | ||
package org.jetbrains.bsp | ||
|
||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
|
||
public data class JvmBinaryJarsParams( | ||
val targets: List<BuildTargetIdentifier>, | ||
) | ||
|
||
public data class JvmBinaryJarsResult( | ||
val items: List<JvmBinaryJarsItem>, | ||
) | ||
|
||
public data class JvmBinaryJarsItem( | ||
val target: BuildTargetIdentifier, | ||
val jars: List<String>, | ||
) |
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
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
40 changes: 40 additions & 0 deletions
40
...g/jetbrains/bsp/bazel/server/sync/languages/android/AdditionalAndroidBuildTargetsQuery.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,40 @@ | ||
package org.jetbrains.bsp.bazel.server.sync.languages.android | ||
|
||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
import ch.epfl.scala.bsp4j.StatusCode | ||
import org.eclipse.lsp4j.jsonrpc.CancelChecker | ||
import org.jetbrains.bsp.bazel.bazelrunner.BazelRunner | ||
import org.jetbrains.bsp.bazel.bazelrunner.utils.BazelArgumentsUtils.getJoinedBazelTargets | ||
import org.jetbrains.bsp.bazel.bazelrunner.utils.BazelArgumentsUtils.toRawUris | ||
|
||
/** | ||
* Every Kotlin Android target actually produces three targets, which we merge inside [KotlinAndroidModulesMerger]. | ||
* However, in order for all the dependent libraries to be unpacked properly (e.g. for Jetpack Compose preview), | ||
* we still have to pass the dependent Kotlin target explicitly during build (and not just the merged target). | ||
*/ | ||
object AdditionalAndroidBuildTargetsQuery { | ||
fun additionalAndroidBuildTargetsQuery( | ||
targets: List<BuildTargetIdentifier>, | ||
bazelRunner: BazelRunner, | ||
cancelChecker: CancelChecker, | ||
): List<BuildTargetIdentifier> { | ||
val targetUris = toRawUris(targets) | ||
val joinedTargets = getJoinedBazelTargets(targetUris) | ||
val childTargetsResult = bazelRunner.commandBuilder().query() | ||
.withArgument("""kind("kt_jvm_library", deps(kind("android_", $joinedTargets), 1))""") | ||
.executeBazelCommand(null).waitAndGetResult(cancelChecker) | ||
|
||
if (childTargetsResult.statusCode != StatusCode.OK) { | ||
error("Could not retrieve additional android build targets") | ||
} | ||
|
||
val targetUriSet = targetUris.asSequence().map { it.trimStart('@') }.toSet() | ||
|
||
return childTargetsResult.stdoutLines | ||
.asSequence() | ||
.filter { it.endsWith("_kt") } | ||
.filter { it.dropLast(3) in targetUriSet } | ||
.map { BuildTargetIdentifier(it) } | ||
.toList() | ||
} | ||
} |
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