Annotation not available to testFixtures post-Kotlin 2.0.10
Closed this issue · 6 comments
Kotlin 2.0.10 fixed a bug around friendPaths and test-fixtures, where previously implementation
dependencies would be exposed to the fixtures compile classpath.
Using @Poko
in main sources without adding testFixturesImplementation("dev.drewhamilton.poko:poko-annotations:0.17.0")
results in a compilation error due to missing classes:
> Task :my-module:compileTestFixturesKotlin FAILED
e: Could not find class <dev/drewhamilton/poko/Poko>
A thought to address this: Configuring the annotations dependency as api
doesn't feel like the right solution. Is it possible for the Poko Gradle Plugin to add this dependency to the test fixtures configuration if java-test-fixtures is applied?
It might be better to no-op the compiler plugin if the runtime isn't present in a compilation unit.
Not sure Poko's compiler plugin is the problem here - it's that Kotlin, when compiling test fixtures, doesn't find Poko's annotation on the compile classpath.
The solution might just be to recommend adding an explicit annotation dependency if you're referencing classes with @Poko
annotation from test fixtures.
That error comes from the plugin attempting to locate its own runtime:
The compiler plugin is being applied to the test fixture compilation but the runtime is not. The use of the Poko annotation in the main source set and/or referencing types which use it from a test fixture is not a problem.
Ah! Nice. No-oping the compiler plugin sounds like the move, then. Happy to send a PR through for this shortly.
It should probably still emit that message as a warning, as you may be defining a custom annotation type and wondering why it isn't working (because of a typo or missing dependency or something).
Changed the error to an information message to not break -Werror
in #395 - let me know what you think!