Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7bca3ac
refactor(bgp): relocate DependencyInfo/VersionMediatingDependencySet …
Sep 4, 2026
8c78300
fix(bgp): add kotlin test dependency, fix ktlint violations
Sep 4, 2026
d3b4ae8
refactor(bgp): extract PublishingMetadataInjector from ExpoPublishing…
Sep 4, 2026
0692a9a
feat(bgp): add dynamic-version/versionless dependency filter
Sep 4, 2026
1381131
fix(bgp-task-3): remove blank line from test class body (ktlint compl…
Sep 4, 2026
68a4f6a
feat(bgp): add RncTransitiveDependencyDiscoverer
Sep 4, 2026
87de5f0
test(bgp): cover runtimeOnly discovery in RncTransitiveDependencyDisc…
Sep 4, 2026
3b48e70
feat(bgp): add includeTransitiveDependencies extension option
Sep 4, 2026
94f917c
feat(bgp): wire RNC transitive dependency discovery into RNBrownfield…
Sep 4, 2026
503856e
docs: describe includeTransitiveDependencies option, flag task-name c…
Sep 4, 2026
a26fa2c
fix: move warning sentence outside code fence in docs
Sep 4, 2026
0f5b7b8
docs(task-7): document code fence fix in report
Sep 4, 2026
ed31d7e
feat(rnapp): enable includeTransitiveDependencies, remove hand-rolled…
Sep 4, 2026
5a71da0
fix: apply final review fixes for BGP transitive dependencies branch
Sep 4, 2026
23ac2c9
fix(bgp): correct runtime -> runtimeOnly config name in Expo fallback…
Sep 9, 2026
dd128c8
test(bgp): add regression test for Expo Gradle-fallback runtimeOnly d…
Sep 9, 2026
baa9c8b
fix(bgp): dedupe transitive-dependency discovery, drop dangling spec …
Sep 9, 2026
e10f0bd
fix(bgp): address code review findings on transitive-dependency media…
Sep 15, 2026
baeadcf
fix(bgp): fix evaluation-order bug in transitive-dependency discovery…
Sep 17, 2026
2991cc8
fix(bgp): fix stale dependency deletion when superseding, add tests
Sep 17, 2026
c680ac6
Merge remote-tracking branch 'origin/main' into feat/bgp-transitive-d…
Sep 17, 2026
8597ff1
fix(bgp): stop RNC discoverer from running on Expo projects, fix Expo…
Sep 17, 2026
106c8c3
fix(bgp): fix task-name collision breaking upgrades, harden RNC disco…
Sep 17, 2026
abf14c6
refactor(bgp): condense code comments
Sep 17, 2026
854b8e4
chore(bgp): bump plugin version to 2.0.0-alpha09
Sep 18, 2026
09c800b
chore(bgp): sync alpha09 version to expo config plugin and CI script
Sep 18, 2026
58d38a6
test: update expected plugin version in gradleHelpers test
Sep 18, 2026
b68dc41
test: bump sample plugin tag in release-notes test
Sep 18, 2026
c27b65b
chore: add changeset for the alpha09 bump
Sep 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bump-bgp-alpha09.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@callstack/react-native-brownfield': patch
---

Bump the Brownfield Gradle Plugin version injected by the Expo config plugin to `2.0.0-alpha09`.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ jobs:
needs.filter.outputs.expo56 == 'true' ||
needs.filter.outputs.androidapp == 'true' ||
needs.filter.outputs.packages == 'true' ||
needs.filter.outputs.gradle-plugins == 'true' ||
needs.filter.outputs.ci == 'true'
) &&
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped')
Expand Down Expand Up @@ -172,6 +173,7 @@ jobs:
needs.filter.outputs.expo56 == 'true' ||
needs.filter.outputs.androidapp == 'true' ||
needs.filter.outputs.packages == 'true' ||
needs.filter.outputs.gradle-plugins == 'true' ||
needs.filter.outputs.ci == 'true'
) &&
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped') &&
Expand Down Expand Up @@ -202,6 +204,7 @@ jobs:
needs.filter.outputs.expo57 == 'true' ||
needs.filter.outputs.androidapp == 'true' ||
needs.filter.outputs.packages == 'true' ||
needs.filter.outputs.gradle-plugins == 'true' ||
needs.filter.outputs.ci == 'true'
) &&
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped')
Expand Down Expand Up @@ -231,6 +234,7 @@ jobs:
needs.filter.outputs.expo57 == 'true' ||
needs.filter.outputs.androidapp == 'true' ||
needs.filter.outputs.packages == 'true' ||
needs.filter.outputs.gradle-plugins == 'true' ||
needs.filter.outputs.ci == 'true'
) &&
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped') &&
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/gradle-plugin-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ jobs:
- name: Run KtLint
working-directory: gradle-plugins/react/brownfield
run: ./gradlew ktlintCheck --no-daemon --stacktrace

- name: Run Unit Tests
working-directory: gradle-plugins/react/brownfield
run: ./gradlew test --no-daemon --stacktrace
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ packages/react-native-brownfield/ios/swiftpm/.build/
# skillgym
.skillgym-results/

# internal process artifacts (should never be part of the PR diff)
.superpowers/
docs/superpowers/

.cursor
47 changes: 2 additions & 45 deletions apps/RNApp/android/BrownfieldLib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import groovy.json.JsonOutput
import groovy.json.JsonSlurper

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
Expand All @@ -18,22 +15,6 @@ publishing {
afterEvaluate {
from(components.getByName("default"))
}

pom {
withXml {
/**
* As a result of `from(components.getByName("default"))` all of the project
* dependencies are added to `pom.xml` file. We do not need the react-native
* third party dependencies to be a part of it as we embed those dependencies.
*/
val dependenciesNode =
(asNode().get("dependencies") as groovy.util.NodeList).first() as groovy.util.Node
dependenciesNode.children()
.filterIsInstance<groovy.util.Node>()
.filter { (it.get("groupId") as groovy.util.NodeList).text() == rootProject.name }
.forEach { dependenciesNode.remove(it) }
}
}
}
}

Expand All @@ -42,29 +23,6 @@ publishing {
}
}

val moduleBuildDir: Directory = layout.buildDirectory.get()

/**
* As a result of `from(components.getByName("default"))` all of the project
* dependencies are added to `module.json` file. We do not need the react-native
* third party dependencies to be a part of it as we embed those dependencies.
*/
tasks.register("removeDependenciesFromModuleFile") {
doLast {
file("$moduleBuildDir/publications/mavenAar/module.json").run {
val json = inputStream().use { JsonSlurper().parse(it) as Map<String, Any> }
(json["variants"] as? List<MutableMap<String, Any>>)?.forEach { variant ->
(variant["dependencies"] as? MutableList<Map<String, Any>>)?.removeAll { it["group"] == rootProject.name }
}
writer().use { it.write(JsonOutput.prettyPrint(JsonOutput.toJson(json))) }
}
}
}

tasks.named("generateMetadataFileForMavenAarPublication") {
finalizedBy("removeDependenciesFromModuleFile")
}

react {
autolinkLibrariesWithApp()
}
Expand Down Expand Up @@ -128,9 +86,8 @@ android {
}

dependencies {
implementation("androidx.core:core-ktx:1.17.0")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("com.google.android.material:material:1.13.0")
// react-native-screens' androidx deps are deliberately not declared here — the plugin
// discovers them. Hand-declaring would mask a broken discoverer.
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.3.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
Expand Down
2 changes: 1 addition & 1 deletion apps/RNApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha08-SNAPSHOT")
classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha09-SNAPSHOT")
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/scripts/prepare-android-build-gradle-for-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (!projectDirName) {

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const SNAPSHOT_VERSION = '2.0.0-alpha08-SNAPSHOT';
const SNAPSHOT_VERSION = '2.0.0-alpha09-SNAPSHOT';
const targetPath = path.resolve(
__dirname,
'..',
Expand Down
16 changes: 16 additions & 0 deletions docs/docs/docs/getting-started/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ publishing {
mavenLocal()
}
}
```

Skip this task-registration block entirely — `experimentalIncludeTransitiveDependencies` (described below) is enabled by default and already does this for you.

```kotlin
val moduleBuildDir: Directory = layout.buildDirectory.get()

tasks.register("removeDependenciesFromModuleFile") {
Expand All @@ -332,6 +336,18 @@ tasks.named("generateMetadataFileForMavenAarPublication") {
}
```

> **Transitive dependencies:** by default, the plugin discovers your embedded native modules' own third-party dependencies (e.g. AndroidX libraries pulled in by `react-native-screens`) and publishes them into this AAR's POM/Gradle Module Metadata, so the app consuming this AAR resolves them automatically via Maven — no manual step needed.
>
> If you'd rather hand-declare these yourself instead (e.g. while this is still experimental), set `experimentalIncludeTransitiveDependencies = false` in this module's `reactBrownfield { }` block and use the task-registration block above:
>
> ```kotlin
> reactBrownfield {
> experimentalIncludeTransitiveDependencies = false
> }
> ```
>
> If you are upgrading an existing app that already has the hand-written `tasks.register("removeDependenciesFromModuleFile")` block above, you can leave it in place — the plugin's own task is named differently (`brownfieldRemoveDependenciesFromModuleFile`) and the two do not conflict. It is redundant once `experimentalIncludeTransitiveDependencies` is enabled (the plugin performs the same removal), so you can delete it whenever convenient.

## 7. Create a Brownfield Configuration

Create `brownfield.config.json` in your project root:
Expand Down
8 changes: 5 additions & 3 deletions docs/docs/docs/guides/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ The brownfield Gradle plugin adds both directories to the source sets, potential

## [Android] Transitive dependencies not being auto resolved

Installed third-party packages like `react-native-screens` or others may rely on transitive dependencies in their `build.gradle` file. These dependencies are not auto resolved by `brownfield-gradle-plugin`. This is an intended behavior in bare React Native apps.
Installed third-party packages like `react-native-screens` or others may rely on transitive dependencies in their `build.gradle` file. For bare React Native apps, `brownfield-gradle-plugin` auto resolves these by default via the (experimental) `experimentalIncludeTransitiveDependencies` option — see [Configure Maven Publishing](/docs/getting-started/android#6-configure-maven-publishing) for details.

For Expo apps, this should work out of the box.
For Expo apps, this works out of the box unconditionally.

To make it work with bare React Native Apps, you have two options:
Upgrading an existing app requires no changes on your side — in particular, you do not need to remove the hand-written `tasks.register("removeDependenciesFromModuleFile")` block if you have one, since the plugin's own task is named differently and the two do not conflict. Be aware of two behaviour changes once this is enabled: dependencies your embedded modules need will start appearing in the published POM, and a version you pinned yourself may be **raised** (never lowered) if an embedded module requires a higher one.

If you've set `experimentalIncludeTransitiveDependencies = false` (e.g. to opt out while this is still experimental), use one of the options below instead.

#### Option 1:

Expand Down
7 changes: 7 additions & 0 deletions gradle-plugins/react/brownfield/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ dependencies {
implementation(libs.common)
implementation(libs.asm.commons)
implementation(libs.versioncompare)
testImplementation(libs.junit.jupiter)
testImplementation(gradleTestKit())
testImplementation(kotlin("test"))
}

tasks.test {
useJUnitPlatform()
}

tasks.named("detekt").configure {
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugins/react/brownfield/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT_ID=com.callstack.react.brownfield
ARTIFACT_ID=brownfield-gradle-plugin
VERSION=2.0.0-alpha08
VERSION=2.0.0-alpha09
GROUP=com.callstack.react
IMPLEMENTATION_CLASS=com.callstack.react.brownfield.plugin.RNBrownfieldPlugin

Expand Down
2 changes: 2 additions & 0 deletions gradle-plugins/react/brownfield/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ agp = "8.5.2"
common = "31.2.2" # do not bump it for now, as it throws an error for incompatible AGP used
asm-commons = "9.7"
versioncompare = "1.5.0"
junit = "5.11.4"

[plugins]
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinJvm" }
Expand All @@ -17,3 +18,4 @@ agp = { module = "com.android.tools.build:gradle", name = "agp", version.ref = "
common = { module = "com.android.tools:common", version.ref = "common" }
asm-commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm-commons" }
versioncompare = { module = "io.github.g00fy2:versioncompare", version.ref = "versioncompare" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.callstack.react.brownfield.artifacts

import com.callstack.react.brownfield.shared.Logging
import com.callstack.react.brownfield.shared.TRANSITIVE_DEPENDENCY_CONFIG_NAMES
import com.callstack.react.brownfield.shared.UnresolvedArtifactInfo
import com.callstack.react.brownfield.shared.VersionMediatingDependencySet
import com.callstack.react.brownfield.shared.collectPublishableGradleDependencies
import com.callstack.react.brownfield.shared.isPublishableCoordinate
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency

/**
* Result of [RncTransitiveDependencyDiscoverer.discover].
*
* @param dependencies The mediated set of third-party dependencies to inject.
* @param supersededCoordinates Coordinates the consumer declares itself that an embedded module
* also needs. The caller must drop their pre-existing POM/module.json entries: [dependencies]
* already carries the mediated (never-lower) version, so keeping both duplicates or shadows it.
*/
data class RncTransitiveDependencyDiscoveryResult(
val dependencies: VersionMediatingDependencySet,
val supersededCoordinates: Set<Pair<String, String>>,
)

/**
* Discovers third-party dependencies of the native modules embedded into the fat AAR, for
* publication into its POM/module metadata. The RNC-CLI counterpart to
* `ExpoPublishingHelper.appendExpoTransitiveDependenciesFromGradle`.
*/
class RncTransitiveDependencyDiscoverer(private val project: Project) {
fun discover(artifacts: List<UnresolvedArtifactInfo>): RncTransitiveDependencyDiscoveryResult {
val discovered = VersionMediatingDependencySet()
val supersededCoordinates = mutableSetOf<Pair<String, String>>()

artifacts
.filter { it.isExpoPublishDependency != true }
.forEach { artifact -> discoverFromArtifact(artifact, discovered, supersededCoordinates) }

return RncTransitiveDependencyDiscoveryResult(discovered, supersededCoordinates)
}

private fun discoverFromArtifact(
artifact: UnresolvedArtifactInfo,
discovered: VersionMediatingDependencySet,
supersededCoordinates: MutableSet<Pair<String, String>>,
) {
val moduleProject = project.rootProject.findProject(":${artifact.moduleName}")
if (moduleProject == null) {
Logging.log(
"WARNING: Could not discover transitive dependencies for embedded module " +
"'${artifact.moduleName}' - no Gradle project found at " +
"':${artifact.moduleName}' in the root project",
)
return
}

collectPublishableGradleDependencies(moduleProject).forEach { moduleDependency ->
val consumerDeclaration = consumerDeclaredDependency(moduleDependency.groupId, moduleDependency.artifactId)

if (consumerDeclaration != null) {
// Supersede on the declaration existing, not on it having a version: a versionless
// one (BOM/platform) still leaves a stale entry that must be replaced, not doubled.
supersededCoordinates.add(moduleDependency.groupId to moduleDependency.artifactId)

// Module-side versions are already validated upstream; this is the consumer-side
// equivalent, keeping a dynamic version from winning mediation and being published.
val consumerVersioned = moduleDependency.copy(version = consumerDeclaration.version)
if (isPublishableCoordinate(consumerVersioned)) {
discovered.add(consumerVersioned)
}
}

discovered.add(moduleDependency)
}
}

/**
* The consumer's own declaration of this coordinate, or null if it doesn't declare it. Returns
* the [Dependency], not its version, so "declared without a version" stays distinguishable from
* "not declared" — collapsing the two leaks duplicate POM entries.
*
* Note this narrows a dynamic declaration: consumer `appcompat:1.+` against module `1.0.0`
* publishes `1.0.0`, possibly lower than `1.+` would have resolved to. Intended — a published
* `1.+` is broken for downstream consumers.
*/
private fun consumerDeclaredDependency(
groupId: String,
artifactId: String,
): Dependency? {
return TRANSITIVE_DEPENDENCY_CONFIG_NAMES.firstNotNullOfOrNull { configName ->
project.configurations.findByName(configName)?.dependencies?.firstOrNull {
it.group == groupId && it.name == artifactId
}
}
}
}
Loading
Loading