Changelog
All notable changes to this project will be documented here.
The format follows Keep a Changelog, and this project adheres to Semantic Versioning.
[0.4.4]
Changed
- Woven advice calls are no longer wrapped in an extra block.
@Beforecalls are placed directly at the start of the function body, the@Aroundadvice call is returned directly, and the@Aftercall is thefinallyexpression itself. The generated bytecode is unchanged; the debug report dumps show the calls without the{ // BLOCK }wrapper.
[0.4.3]
Added
- Debug reports.
aspectk { debug = true }writes, per compilation, the advice that applies to each target annotation and where it came from (local,external,carried-forward), the hints that no longer resolve, and a Kotlin-like dump of every woven file with the advice on each of its functions. Reports are kept per file, so incremental builds keep the results of files they did not recompile. See Debug Reports. - Compiler diagnostics for aspect declarations. An
@Aspectdeclared as aclass, advice with the wrong parameter or@Aroundreturn type, and advice outside an@Aspectare now reported by the compiler frontend. IntelliJ IDEA and Android Studio can highlight them while editing. See IDE Support. - Build diagnostics for advice on unsuitable targets.
@Aroundadvice whosesuspendmodifier does not match its target,@Aroundon aninlinefunction with inline orcrossinlinelambda parameters, and@After/@Aroundon atailrecfunction are reported during the build. A function that fails one of the errors is not woven.
Changed
- Every AspectK diagnostic message starts with
[AspectK].
[0.4.2]
Fixed
- Aspects from other modules did not reach Android modules whose variants have no namesake
in the aspect's module. An application module with product flavors (
playDebug,internalDebug, ...) compiled without the aspects of the library modules it depends on, so nothing was woven and no error was reported. Hints now travel as a variant of each module'sapiElements, and Gradle's variant matching picks the right one. - An aspect added, changed or removed in the same module went unnoticed under AGP 9's built-in Kotlin. Incremental builds kept the previous weaving until a clean build. Change detection now reads the sources of the compile task itself.
Changed
- Aspects follow the compile classpath. A module receives the aspects of the modules it can
see at compile time. An aspect behind an
implementationdependency of another module is no longer delivered; expose it withapiwhere it has to reach further. - The sample builds with AGP 9 and has a flavored application module.
[0.4.1]
Added
- Kotlin 2.4.20 support. Supported Kotlin range is now 2.2.20 ~ 2.4.20 (see the compatibility table). The plugin no longer rejects a project on 2.4.20 at configuration time.
- Lambda targets and external target annotations are documented and tested. A target
annotation can be written on a lambda or an anonymous function, including a lambda passed to
an
inlinefunction when the annotation hasSOURCEretention, and it can be an annotation you did not declare: from the standard library, a third-party library, or Java. Both already worked; they are now covered by tests on JVM, JS, Wasm and Native. See Target Annotations.
Fixed
@Aroundon asuspendfunction returningUnitcould throwClassCastException. When the last statement of the function was a suspend call that suspended and returned a value (for example a DataStoreedit { }),proceed()returned that value instead ofUnitand the function failed with... cannot be cast to kotlin.Unit. JVM only.
[0.4.0]
Added
- Several advices on one function. Every
@Afterand@Aroundthat applies to a function now runs; before, only the last one did. Advices are ordered by kind (@Before, then@Around, then the body, then@After), then by the order the target annotations are written on the function. See Advice Ordering for the rules and for what is not guaranteed. proceedAs<T>()returns the result ofproceed()cast toT.proceedWith("name" to value)proceeds with only the named arguments replaced.getAnnotationArgs<T>()returns the arguments of an annotation on the intercepted function by parameter name. See Extension Functions.
Changed
- A function with several
@Afteror@Aroundadvices behaves differently. Code that relied on only the last advice running will now see all of them run. - The order of advices no longer depends on the names of the target annotations. For a function carrying several target annotations, it follows the order they are written in.
- The Kotlin/Native, JS and Wasm libraries of
aspectk-runtimehave a new internal name (io.github.mole-labs:aspectk-runtime, wasaspectk:aspectk-runtime). Maven coordinates are unchanged and JVM and Android are not affected. On the other targets, a library built against an older AspectK may not link against this runtime; rebuild it with 0.4.0.
Fixed
- Android unit tests could not be compiled in a module applying the plugin. The build failed
with a circular dependency on
compileDebugUnitTestKotlinAndroid.
[0.3.2]
Changed
@Afterand@Aroundnow wrap the target body in place.@Afterwraps the body intry { ... } finally { ... }where it stands, and@Aroundmoves it into theproceedlistener lambda. The generated$<name>local function is gone. See@Afterand@Aroundfor the generated shape.@Afterand@Aroundon atailrecfunction now run once per recursive call.
Fixed
@Afterand@Aroundoninlinefunctions. Reified type parameters, inline lambda parameters and non-local returns used to fail at compile time or get lost. An inline lambda parameter is not a value, so it shows up asnullinJoinPoint.args.- Generic return types in
MethodSignature. A return type that is a type parameter now resolves to its upper bound (Anyfor an unboundedT), the same way parameter types do. inherits = trueacross interfaces and modules. Overrides of an annotated interface function, or of a function declared in another module, were skipped.- Aspects in
mainnow reachtest. Hints from associated compilations were not passed along, so an aspect declared in a module's main source set was not injected into its tests. - Stale hints. Removing
@Aspectfrom a class, or deleting an advice function, left the old entry inhints.jsonand it kept being applied on later builds. - Incremental builds across modules. A changed aspect in an upstream module now recompiles the downstream modules that depend on it. Deleting an unrelated file, or removing an aspect together with its targets, no longer forces a full recompile.
[0.3.1]
Fixed
@Before/@Afternow weave correctly intosuspendfunctions whose body actually suspends (e.g. callsdelay) — the generated local wrapper function is now declaredsuspendwhen the target is, matching the target's continuation.
Added
@Aroundonsuspendfunctions, via a newSuspendProceedingJoinPoint— advice can be declaredsuspendand callproceed()to resume the suspending target body.
[0.3.0]
Added
- Cross-module weaving. An
@Aspectdeclared in one module now correctly weaves into targets in a different, downstream module that depends on it — no configuration needed beyond applying the plugin to both modules. Works transitively through any dependency depth, including diamond-shaped graphs, and a module that never uses AspectK doesn't need the plugin applied at all, even sitting between two participating modules. - Kotlin 2.4.0 / 2.4.10 support, via a new
aspectk-core-compat:compat-2400module. Supported Kotlin range is now 2.2.20 ~ 2.4.10 (see the compatibility table). - AspectK no longer requires the Android Gradle Plugin on the classpath — applying it to a plain (non-Android) Kotlin Multiplatform module now works correctly.
Fixed
- Incremental-build correctness. Real (non-clean) Gradle builds could previously miss
re-weaving in three cases, all now fixed:
- Editing only a target file (aspect file untouched) could leave the target unwoven if the aspect's file wasn't part of that incremental round.
- Editing only an aspect file (target file untouched) could leave a stale target unwoven, since Kotlin's own incremental compiler wouldn't recompile it — a full recompile is now forced only when a file that actually changed declares or drops aspect content.
- Cross-module hints only propagated one dependency hop; a target reachable only transitively (e.g. through a diamond) could miss the aspect's hints entirely.
[0.2.2]
Fixed
-
@Aroundon functions with complex bodies now compiles correctly — the IR deep-copy of the local function body was performed statement-by-statement, giving each call its ownSymbolRemapper. References between local variables (e.g.val b = a + 1) were left pointing to the outer function's symbols, which the JVM lowering phase misidentified as closure captures. Once the outer body was cleared the missing frame slot causedIllegalStateException: No mapping for symbolat codegen. The entire body is now deep-copied in a single pass so all intra-body references are correctly remapped. (#AroundLocalFunctionGenerationTest) -
@Aroundon functions containing lambdas or nested local functions no longer returns wrong values —BodyTransformer.visitReturnpreviously redirected everyIrReturnto the generated$<name>local function, including returns inside nested lambdas and local functions. This caused constructs such aslistOf(1,2,3).sumOf { it + base }to short-circuit after the first element. The transformer now only redirects returns that originally targeted the outer function.
Added
-
Extension functions on
JoinPoint(JoinPointExtensions.kt):getArg<T>(name)— retrieves a named argument, cast toT; throws on missing namegetArgOrNull<T>(name)— same as above but returnsnullon missing name or cast failuregetTarget<T>()— caststargettoT; throws onnullor cast failuregetTargetOrNull<T>()— caststargettoT; returnsnullotherwisefindAnnotation<T>()— findsAnnotationInfoby annotation type on the intercepted function
-
Extension functions on
MethodSignature(MethodSignatureExtensions.kt):findAnnotation<T>()— findsAnnotationInfoby annotation type inannotations
-
Extension functions on
AnnotationInfo(AnnotationInfoExtensions.kt):getArg<T>(paramName)— retrieves a named annotation argument, cast toTgetArgOrNull<T>(paramName)— same but returnsnullon missing name or cast failure
[0.2.0]
Added
@Afteradvice annotation: runs after the target function body in afinallyblock, regardless of whether an exception was thrown@Aroundadvice annotation: replaces the target function call; the original body is invoked viaProceedingJoinPoint.proceed()ProceedingJoinPointinterface withproceed()andproceed(vararg args)for argument substitutionDefaultProceedingJoinPointruntime implementation generated at each@Aroundcall site
Changed
- Advice generation pipeline restructured: each
AspectContextis now dispatched directly to its generator, eliminating redundant internal lookups
[0.1.1]
Added
- Kotlin version validation: AspectK now throws a
GradleExceptionat configuration time if the project's Kotlin compiler version is not in the supported range
Changed
- Kotlin version updated to 2.3.10
pluginIdinAspectKCompilerPluginRegistrarnow referencesBuildConfig.COMPILER_PLUGIN_IDinstead of a hardcoded string
[0.1.0] — Initial Release
Added
@Aspectannotation to mark aspect classes@Beforeadvice annotation withtargetandinheritsparametersJoinPointinterface withtarget,signature, andargsMethodSignaturewith full compile-time metadataMethodParameterwith type, name, annotations, and nullability infoAnnotationInfofor runtime-accessible annotation metadata- Kotlin Multiplatform support (JVM, JS, WASM, Native Tier 1–3)
- K2 IR-based compiler plugin (
AspectKCompilerPluginRegistrar) - Gradle plugin (
io.github.mole-labs.aspectk.compiler) - Many-to-many aspect-to-target relationships
- Inheritance support via
inherits = true - Thread-safe
AspectLookUpimplementation