Package-level declarations

Types

Link copied to clipboard
data class AnnotationArgumentDeclaration(val name: String?, val value: String)
Link copied to clipboard
data class AnnotationDeclaration(val name: String, val fqName: String, val arguments: List<AnnotationArgumentDeclaration> = emptyList())

Represents a parsed Kotlin annotation declared on a class.

Link copied to clipboard
data class ClassDeclaration(val name: String, val fqName: String, val packageName: String, val isInterface: Boolean, val isAbstract: Boolean, val annotations: List<AnnotationDeclaration>, val imports: List<String>, val referencedTypes: Set<String>, val filePath: String, val visibility: Visibility = Visibility.PUBLIC, val modifiers: Set<Modifier> = emptySet(), val supertypes: List<String> = emptyList(), val primaryConstructor: ConstructorDeclaration? = null, val secondaryConstructors: List<ConstructorDeclaration> = emptyList(), val functions: List<FunctionDeclaration> = emptyList(), val properties: List<PropertyDeclaration> = emptyList(), val companionObject: ClassDeclaration? = null, val kdocText: String? = null, val importAliases: Map<String, String> = emptyMap(), val isEnum: Boolean = false)

Represents a parsed Kotlin class, interface, or object declaration.

Link copied to clipboard

Context receiver for writing declarative assertions on a ClassDeclaration element. Provides easy access to all element properties and custom helper assertions.

Link copied to clipboard
class ClassesRuleBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder for compiling and verifying architectural rules on Kotlin classes.

Link copied to clipboard

Fluent API for defining assertion rules on Kotlin classes.

Link copied to clipboard

Fluent API for defining filtering conditions on Kotlin classes.

Link copied to clipboard
data class ConstructorDeclaration(val visibility: Visibility, val parameters: List<ParameterDeclaration>, val annotations: List<AnnotationDeclaration>)
Link copied to clipboard
data class Dependency(val configuration: String, val targetBuildId: String, val targetPath: String)

Represents a declared project-to-project dependency edge at runtime.

Link copied to clipboard
data class FileDeclaration(val name: String, val packageName: String, val imports: List<String> = emptyList(), val classes: List<ClassDeclaration> = emptyList(), val topLevelFunctions: List<FunctionDeclaration> = emptyList(), val topLevelProperties: List<PropertyDeclaration> = emptyList(), val kdocText: String? = null, val filePath: String = "", val importAliases: Map<String, String> = emptyMap())
Link copied to clipboard
data class FileDeclarationContext(val declaration: FileDeclaration, val modulePath: String)

Context wrapper for verifying source file declarations.

Link copied to clipboard

Context receiver for writing declarative assertions on a FileDeclarationContext element. Provides easy access to all element properties and custom helper assertions.

Link copied to clipboard
class FilesRuleBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder for compiling and verifying architectural rules on Kotlin source files.

Link copied to clipboard
Link copied to clipboard
class FilesThat
Link copied to clipboard
Link copied to clipboard
data class FunctionDeclaration(val name: String, val visibility: Visibility, val modifiers: Set<Modifier>, val returnType: String, val parameters: List<ParameterDeclaration>, val annotations: List<AnnotationDeclaration>, val kdocText: String?, val isExtension: Boolean)
Link copied to clipboard
data class FunctionDeclarationContext(val declaration: FunctionDeclaration, val packageName: String, val className: String?, val modulePath: String, val filePath: String)

Context wrapper for verifying function declarations.

Link copied to clipboard

Context receiver for writing declarative assertions on a FunctionDeclarationContext element. Provides easy access to all element properties and custom helper assertions.

Link copied to clipboard
class FunctionsRuleBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder for compiling and verifying architectural rules on Kotlin function declarations.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
object Konture

Main entry point for Konture. All architecture assertion builders, scoping builders, and graph configurations are extended from or accessible through this object.

Link copied to clipboard
class KontureContext(projectGraph: ProjectGraph)

DSL Context wrapper that allows defining and verifying multiple independent rule suites.

Link copied to clipboard
annotation class KontureDsl

DSL Marker for Konture DSL structures.

Link copied to clipboard

Represents a scope containing a set of Kotlin files for checking file-level rules.

Link copied to clipboard
class KontureScope(val classes: List<ClassDeclaration>)

Represents a scope containing a set of classes for writing architecture rules in a Konsist-inspired fluent DSL.

Link copied to clipboard
class LayeredArchitectureBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder class implementing the Layered Architecture DSL.

Link copied to clipboard

Type-safe, nested DSL for defining and verifying layered architecture rules.

Link copied to clipboard
Link copied to clipboard
data class Module(val buildId: String, val path: String, val projectDir: String, val appliedPlugins: List<String>, val sourceSets: List<SourceSet>, val dependencies: List<Dependency>, val files: List<FileDeclaration> = emptyList())

Represents a single Gradle module/project and all its structural and source declarations.

Link copied to clipboard

Context receiver for writing declarative assertions on a Module element. Provides easy access to all element properties and custom helper assertions.

Link copied to clipboard
class ModulesRuleBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder for compiling and verifying architectural rules on project modules.

Link copied to clipboard

Fluent API for defining assertion rules on Gradle modules.

Link copied to clipboard

Fluent API for defining filtering conditions on Gradle modules.

Link copied to clipboard
data class ParameterDeclaration(val name: String, val type: String, val hasDefaultValue: Boolean, val annotations: List<AnnotationDeclaration>)
Link copied to clipboard
data class ProjectGraph(val builds: Map<String, List<Module>>, externalDependenciesLoader: () -> DependencyGraphModel = { DependencyGraphModel() })

Represents the complete structural graph of the multi-project/composite build. It provides core querying capabilities, circular dependency verification, and access to the parsed class/declaration hierarchy of the entire workspace.

Link copied to clipboard
class PropertiesRuleBuilder(graph: ProjectGraph = Konture.projectGraph)

A builder for compiling and verifying architectural rules on Kotlin property declarations.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class PropertyDeclaration(val name: String, val visibility: Visibility, val modifiers: Set<Modifier>, val type: String, val isVal: Boolean, val annotations: List<AnnotationDeclaration>, val kdocText: String?, val isExtension: Boolean = false)
Link copied to clipboard
data class PropertyDeclarationContext(val declaration: PropertyDeclaration, val packageName: String, val className: String?, val modulePath: String, val filePath: String)

Context wrapper for verifying property declarations.

Link copied to clipboard

Context receiver for writing declarative assertions on a PropertyDeclarationContext element. Provides easy access to all element properties and custom helper assertions.

Link copied to clipboard
data class SourceSet(val name: String, val kind: String, val production: Boolean, val srcDirs: List<String>, val kotlinFiles: List<String>, val platforms: List<String> = emptyList())

Represents a source set within a module at test runtime.

Link copied to clipboard

Properties

Link copied to clipboard

Delegates annotations property to the underlying FunctionDeclaration.

Delegates annotations property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates classes property to the underlying FileDeclaration.

Link copied to clipboard

Retrieves a file-level functional KontureFileScope representing all files in the project.

Link copied to clipboard

Delegates imports property to the underlying FileDeclaration.

Link copied to clipboard

Delegates isExtension property to the underlying FunctionDeclaration.

Delegates isExtension property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates isVal property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates isVar property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates kdocText property to the underlying FunctionDeclaration.

Delegates kdocText property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates modifiers property to the underlying FunctionDeclaration.

Delegates modifiers property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates name property to the underlying FileDeclaration.

Delegates name property to the underlying FunctionDeclaration.

Delegates name property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates packageName property to the underlying FileDeclaration.

Link copied to clipboard

Delegates parameters property to the underlying FunctionDeclaration.

Link copied to clipboard

Delegates returnType property to the underlying FunctionDeclaration.

Link copied to clipboard

Retrieves a class-level functional KontureScope representing the entire project.

Link copied to clipboard

Delegates topLevelFunctions property to the underlying FileDeclaration.

Link copied to clipboard

Delegates topLevelProperties property to the underlying FileDeclaration.

Link copied to clipboard

Delegates type property to the underlying PropertyDeclaration.

Link copied to clipboard

Delegates visibility property to the underlying FunctionDeclaration.

Delegates visibility property to the underlying PropertyDeclaration.

Functions

Link copied to clipboard

Unified multi-rule block supporting modules, classes, and layered architecture validations. Runs every declared suite and aggregates all violations before failing.

Link copied to clipboard

Asserts that all class declarations in the scope represent abstract classes or interfaces.

Asserts that all class declarations represent abstract classes or interfaces.

Link copied to clipboard
fun KontureScope.assertAreAssignableTo(vararg superTypes: String)

Asserts that all class declarations in the scope extend or implement any of the specified supertypes.

Asserts that all class declarations extend or implement any of the specified supertypes.

Link copied to clipboard

Asserts that all class declarations in the scope are data classes.

Asserts that all class declarations are data classes.

Link copied to clipboard

Asserts that all class declarations in the scope represent enum classes.

Asserts that all class declarations represent enum classes.

Link copied to clipboard

Asserts that all class declarations in the scope are inline/value classes.

Asserts that all class declarations are inline/value classes.

Link copied to clipboard

Asserts that all class declarations in the scope represent interfaces.

Asserts that all class declarations represent interfaces.

Link copied to clipboard

Asserts that all class declarations in the scope are internal.

Asserts that all class declarations are internal.

Link copied to clipboard

Asserts that all class declarations in the scope are private.

Asserts that all class declarations are private.

Link copied to clipboard

Asserts that all class declarations in the scope are protected.

Asserts that all class declarations are protected.

Link copied to clipboard

Asserts that all class declarations in the scope are public.

Asserts that all class declarations are public.

Link copied to clipboard

Asserts that all class declarations in the scope are sealed classes.

Asserts that all class declarations are sealed classes.

Link copied to clipboard
Link copied to clipboard
fun KontureFileScope.assertHasKDoc(additionalMessage: String? = null)
fun KontureScope.assertHasKDoc(additionalMessage: String? = null)
@JvmName(name = "assertClassesHasKDoc")
fun List<ClassDeclaration>.assertHasKDoc(additionalMessage: String? = null)
@JvmName(name = "assertFilesHasKDoc")
fun List<FileDeclaration>.assertHasKDoc(additionalMessage: String? = null)
Link copied to clipboard
fun KontureScope.assertHaveAnnotationOf(vararg annotationFqNames: String)

Asserts that all class declarations in the scope have at least one of the specified annotations. Matches either the annotation's simple name or its fully qualified name (FQN).

fun List<ClassDeclaration>.assertHaveAnnotationOf(vararg annotationFqNames: String)

Asserts that all class declarations have at least one of the specified annotations. Matches either the annotation's simple name or its fully qualified name (FQN).

Link copied to clipboard

Asserts that all class declarations in the scope have the specified visibility.

Asserts that all class declarations have the specified visibility.

Link copied to clipboard

Asserts that all file declarations in the scope have names ending with any of the specified suffixes.

Asserts that all class declarations in the scope have names ending with any of the specified suffixes.

Asserts that all class declarations have names ending with any of the specified suffixes.

Asserts that all file declarations have names ending with any of the specified suffixes.

Link copied to clipboard

Asserts that all file declarations in the scope have names matching any of the specified glob patterns.

fun KontureScope.assertNameMatching(vararg patterns: String)

Asserts that all class declarations in the scope have names matching any of the specified glob patterns. Supports '*' wildcards.

Asserts that all class declarations have names matching any of the specified glob patterns. Supports '*' wildcards.

Asserts that all file declarations have names matching any of the specified glob patterns.

Link copied to clipboard

Asserts that all file declarations in the scope have names starting with any of the specified prefixes.

Asserts that all class declarations in the scope have names starting with any of the specified prefixes.

Asserts that all class declarations have names starting with any of the specified prefixes.

Asserts that all file declarations have names starting with any of the specified prefixes.

Link copied to clipboard

Verifies that there are no package or module dependency cycles in the project. Throws an AssertionError if a cycle is detected.

Link copied to clipboard
fun KontureFileScope.assertNoWildcardImports(additionalMessage: String? = null)
fun List<FileDeclaration>.assertNoWildcardImports(additionalMessage: String? = null)
Link copied to clipboard
fun KontureScope.assertOnlyBeAccessedByAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope are only accessed by classes residing in packages matching the specified patterns.

fun List<ClassDeclaration>.assertOnlyBeAccessedByAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes are only accessed by classes residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureScope.assertOnlyDependOnClassesInAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope depend only on classes residing in packages matching the specified patterns.

fun List<ClassDeclaration>.assertOnlyDependOnClassesInAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes depend only on classes residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureFileScope.assertOnlyOneClassPerFile(additionalMessage: String? = null)
fun List<FileDeclaration>.assertOnlyOneClassPerFile(additionalMessage: String? = null)
Link copied to clipboard
fun KontureFileScope.assertResideInAPackage(vararg packagePatterns: String)

Asserts that all file declarations in the scope reside in packages matching any of the specified patterns. Matches using standard Kotlin package wildcard matching (e.g. "..domain..").

fun KontureScope.assertResideInAPackage(vararg packagePatterns: String)

Asserts that all class declarations in the scope reside in packages matching any of the specified patterns. Matches using standard Kotlin package wildcard matching (e.g. "..domain..").

fun List<ClassDeclaration>.assertResideInAPackage(vararg packagePatterns: String)

Asserts that all class declarations reside in packages matching any of the specified patterns. Matches using standard Kotlin package wildcard matching (e.g. "..domain..").

fun List<FileDeclaration>.assertResideInAPackage(vararg packagePatterns: String)

Asserts that all file declarations reside in packages matching any of the specified patterns. Matches using standard Kotlin package wildcard matching (e.g. "..domain..").

Link copied to clipboard
fun KontureFileScope.assertTrue(additionalMessage: String? = null, predicate: (FileDeclaration) -> Boolean)
fun KontureScope.assertTrue(additionalMessage: String? = null, predicate: (ClassDeclaration) -> Boolean)
@JvmName(name = "assertClassesTrue")
fun List<ClassDeclaration>.assertTrue(additionalMessage: String? = null, predicate: (ClassDeclaration) -> Boolean)
@JvmName(name = "assertFilesTrue")
fun List<FileDeclaration>.assertTrue(additionalMessage: String? = null, predicate: (FileDeclaration) -> Boolean)
Link copied to clipboard

Access the class-level declarative assertion rule builder. Allows filtering and assertion of class structure, modifiers, annotations, visibility, and dependencies.


Filters the list of class declarations to include only normal classes (excluding interface definitions).

Define and run class dependency/structural rules inside a block-based DSL context. Automatically checks the rules at the end of the block.

Link copied to clipboard

Helper extension to check if a file contains a class matching the predicate.

Link copied to clipboard

Access the file-level declarative assertion rule builder. Allows filtering and assertion of source files and their imports, package, or wildcard usages.

Define and run source file dependency/structural rules inside a block-based DSL context. Automatically checks the rules at the end of the block.

Link copied to clipboard

Retrieves a file-level functional KontureFileScope scoped to a specific module path.

Link copied to clipboard

Retrieves a file-level functional KontureFileScope scoped to a specific package name.

Link copied to clipboard

Access the function-level declarative assertion rule builder. Allows filtering and assertion of function declarations (both top-level and nested member functions).

Define and run function dependency/structural rules inside a block-based DSL context. Automatically checks the rules at the end of the block.

Link copied to clipboard

Helper extension to check if a class is annotated with all of the specified annotations.

Helper extension to check if a function has all of the specified annotations.

Helper extension to check if a property has all of the specified annotations.

Link copied to clipboard

Helper extension to check if a class is annotated with the given annotation.

Helper extension to check if a function has the specified annotation.

Helper extension to check if a property has the specified annotation.

Link copied to clipboard

Helper extension to check if a class is annotated with any of the specified annotations.

Helper extension to check if a function has any of the specified annotations.

Helper extension to check if a property has any of the specified annotations.

Link copied to clipboard

Helper extension to check if a file imports the specified match.

Link copied to clipboard

Helper extension to check if a file imports any match containing target segments.

Link copied to clipboard

Filters the list of class declarations to include only interface definitions.

Link copied to clipboard

Define and run a nested, type-safe layered architecture specification. Automatically checks the layered rules at the end of the block.

Link copied to clipboard

Access the layered-architecture rule builder. Allows defining high-level layers and declaring directional access constraints between them.

Link copied to clipboard
Link copied to clipboard

Access the modules-level declarative assertion rule builder. Allows filtering and assertion of architectural module structures and dependencies.

Define and run module dependency rules inside a block-based DSL context. Automatically checks the rules at the end of the block.

Link copied to clipboard
Link copied to clipboard

Access the property-level declarative assertion rule builder. Allows filtering and assertion of property declarations (both top-level and class properties).

Define and run property dependency/structural rules inside a block-based DSL context. Automatically checks the rules at the end of the block.

Link copied to clipboard

Retrieves a class-level functional KontureScope scoped to a specific module path.

Link copied to clipboard

Retrieves a class-level functional KontureScope scoped to a specific package name.

Link copied to clipboard

Asserts rules on filtered classes using a lambda block that provides a ClassDeclarationShouldContext receiver.

Asserts rules on filtered files using a lambda block that provides a FileDeclarationShouldContext receiver. Supports both imperative assertions and Boolean predicate matches.

Asserts rules on filtered functions using a lambda block that provides a FunctionDeclarationShouldContext receiver. Supports both imperative assertions and Boolean predicate matches.

Asserts rules on filtered modules using a lambda block that provides a ModuleShouldContext receiver. Supports both imperative assertions and Boolean predicate matches.

Asserts rules on filtered properties using a lambda block that provides a PropertyDeclarationShouldContext receiver. Supports both imperative assertions and Boolean predicate matches.

Link copied to clipboard

Filters classes in this rule using a concise lambda predicate evaluated on each ClassDeclaration.

Filters files in this rule using a concise lambda predicate evaluated on each FileDeclarationContext.

Filters functions in this rule using a concise lambda predicate evaluated on each FunctionDeclarationContext.

Filters modules in this rule using a concise lambda predicate evaluated on each Module.

Filters properties in this rule using a concise lambda predicate evaluated on each PropertyDeclarationContext.

Link copied to clipboard

Filters the list of class declarations to include only those annotated with the specified annotation.

Link copied to clipboard

Filters class declarations to those containing the specified modifier.

Link copied to clipboard

Filters the list of class declarations to include only those whose names end with the specified suffix.

@JvmName(name = "withFileNameEndingWith")
fun List<FileDeclaration>.withNameEndingWith(suffix: String): List<FileDeclaration>

Filters the list of file declarations to include only those whose names end with the specified suffix.

Link copied to clipboard

Filters the list of class declarations to include only those whose simple names match the specified glob pattern. Supports '*' wildcards.

@JvmName(name = "withFileNameMatching")
fun List<FileDeclaration>.withNameMatching(pattern: String): List<FileDeclaration>

Filters the list of file declarations to include only those whose names match the specified glob pattern. Supports '*' wildcards.

Link copied to clipboard

Filters the list of class declarations to include only those whose names start with the specified prefix.

@JvmName(name = "withFileNameStartingWith")
fun List<FileDeclaration>.withNameStartingWith(prefix: String): List<FileDeclaration>

Filters the list of file declarations to include only those whose names start with the specified prefix.

Link copied to clipboard

Filters the list of class declarations to exclude those annotated with the specified annotation.

Link copied to clipboard

Filters the list of class declarations to include only those residing in packages matching the specified pattern. Supports '..' segment wildcards.

@JvmName(name = "withFilePackage")
fun List<FileDeclaration>.withPackage(packagePattern: String): List<FileDeclaration>

Filters the list of file declarations to include only those residing in packages matching the specified pattern. Supports '..' wildcards.

Link copied to clipboard

Filters class declarations to those extending or implementing the specified parent type.

Link copied to clipboard

Filters class declarations to those matching the specified visibility.