Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Unreleased
- See the [circuit-retained README](https://github.com/slackhq/circuit/tree/main/circuit-retained) for more details.
- **NOTE:** This is phase one of a multi-phase migration to the first-party API.

### Changed

- **SubCircuit:** `@SubCircuitInject` is now handled by the main `circuit-codegen` processor.
`circuitx-subcircuit-codegen` is now a relocation pointer to `circuit-codegen`, but prefer
depending on `circuit-codegen` directly.

### Fixed

- **SubCircuit:** Fix `subcircuit-codegen` Metro mode (`subcircuit.codegen.mode=metro`). It previously
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/circuit.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ configure<DokkaExtension> {

// Dependency guard configuration
configure<DependencyGuardPluginExtension> {
if (project.name == "circuit-codegen" || project.name == "subcircuit-codegen") {
if (project.name == "circuit-codegen") {
configuration("runtimeClasspath") {
baselineMap = {
// Remove the version
Expand Down
1 change: 1 addition & 0 deletions circuit-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
testImplementation(libs.kct)
testImplementation(libs.kct.ksp)
testImplementation(libs.kotlin.compilerEmbeddable)
testImplementation(libs.kotlin.test)
testImplementation(libs.ksp)
testImplementation(libs.ksp.api)
testImplementation(libs.metro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ internal object CircuitNames {
val SCREEN = ClassName(CIRCUIT_RUNTIME_SCREEN_PACKAGE, "Screen")
val NAVIGATOR = ClassName(CIRCUIT_RUNTIME_BASE_PACKAGE, "Navigator")
val CIRCUIT_CONTEXT = ClassName(CIRCUIT_RUNTIME_BASE_PACKAGE, "CircuitContext")

// SubCircuit target. Referenced by string only so circuit-codegen keeps no compile dependency on
// the circuitx-subcircuit runtime; these types are resolved from the consumer's classpath when a
// `@SubCircuitInject` is present.
const val SUB_CIRCUIT_PACKAGE = "com.slack.circuit.subcircuit"
val SUB_CIRCUIT_INJECT_ANNOTATION = ClassName(SUB_CIRCUIT_PACKAGE, "SubCircuitInject")
val SUB_PRESENTER = ClassName(SUB_CIRCUIT_PACKAGE, "SubPresenter")
val SUB_PRESENTER_FACTORY = ClassName(SUB_CIRCUIT_PACKAGE, "SubPresenterFactory")
val SUB_UI = ClassName(SUB_CIRCUIT_PACKAGE, "SubUi")
val SUB_UI_FACTORY = ClassName(SUB_CIRCUIT_PACKAGE, "SubUiFactory")
val SUB_CIRCUIT_UI_STATE = ClassName(SUB_CIRCUIT_PACKAGE, "SubCircuitUiState")
val SUB_SCREEN = ClassName(SUB_CIRCUIT_PACKAGE, "SubScreen")
const val SUB_PRESENTER_FACTORY_SUFFIX = "_SubPresenterFactory"
const val SUB_UI_FACTORY_SUFFIX = "_SubUiFactory"

val DAGGER_MODULE = ClassName(DAGGER_PACKAGE, "Module")
val DAGGER_BINDS = ClassName(DAGGER_PACKAGE, "Binds")
val DAGGER_INSTALL_IN = ClassName(DAGGER_HILT_PACKAGE, "InstallIn")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ internal data class CircuitOptions(
const val LENIENT = "circuit.codegen.lenient"
const val USE_JAVAX_ONLY = "circuit.codegen.useJavaxOnly"

// `subcircuit.codegen.*` fallbacks for the SubCircuit target; the keys above take precedence.
private const val LEGACY_MODE = "subcircuit.codegen.mode"
private const val LEGACY_LENIENT = "subcircuit.codegen.lenient"
private const val LEGACY_USE_JAVAX_ONLY = "subcircuit.codegen.useJavaxOnly"

internal val UNKNOWN =
CircuitOptions(CodegenMode.UNKNOWN, lenient = false, useJavaxOnly = false)

fun load(options: Map<String, String>, logger: KSPLogger): CircuitOptions {
val mode =
options[MODE].let { mode ->
(options[MODE] ?: options[LEGACY_MODE]).let { mode ->
if (mode == null) {
CodegenMode.ANVIL
} else {
Expand All @@ -36,8 +41,9 @@ internal data class CircuitOptions(
return UNKNOWN
}

val lenient = options[LENIENT]?.toBoolean() ?: false
val useJavaxOnly = options[USE_JAVAX_ONLY]?.toBoolean() ?: false
val lenient = (options[LENIENT] ?: options[LEGACY_LENIENT])?.toBoolean() ?: false
val useJavaxOnly =
(options[USE_JAVAX_ONLY] ?: options[LEGACY_USE_JAVAX_ONLY])?.toBoolean() ?: false
return CircuitOptions(mode = mode, lenient = lenient, useJavaxOnly = useJavaxOnly)
}
}
Expand Down
Loading
Loading