ArchitectureSourceSetPolicy

First-class, declarative source-set architecture policy DSL.

Enforces platform-independence, package import/dependency restrictions, and Gradle source-set dependsOn hierarchy rules for Kotlin Multiplatform (KMP) and multi-source-set projects.

Example Usage:

architecture {
sourceSet("commonMain") {
mustBePlatformIndependent()
mustNotDependOn("android.**", "java.awt.**")
mustNotDependOnSourceSets("jvmMain", "androidMain", "iosMain")
}

sourceSet("androidMain") {
mayDependOn("android.**", "androidx.**")
}
}

Properties

Link copied to clipboard

The human-readable label identifying this source-set policy.

Link copied to clipboard

The selector specifying which source sets this policy applies to.

Functions

Link copied to clipboard
fun mayDependOn(vararg packagePatterns: String)

Restricts the platform package patterns the matched source set(s) may depend on. Any platform package reference outside of these patterns will trigger a violation.

fun mayDependOn(packagePatterns: List<String>)

Restricts the platform package patterns the matched source set(s) may depend on.

Link copied to clipboard
fun mustBePlatformIndependent(additionalBanned: List<String> = emptyList(), excluding: List<String> = emptyList())

Requires the matched source set(s) to remain platform-independent by forbidding imports and symbol references to known platform packages (e.g. android.*, java.*, platform.*).

Link copied to clipboard
fun mustNotDependOn(vararg packagePatterns: String)
fun mustNotDependOn(packagePatterns: List<String>)

Forbids the matched source set(s) from importing or depending on the specified package patterns.

Link copied to clipboard
fun mustNotDependOnSourceSets(vararg sourceSetNames: String)
fun mustNotDependOnSourceSets(sourceSetNames: List<String>)

Forbids the matched source set(s) from depending on the specified source-set names in the Gradle model.