Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation not available to testFixtures post-Kotlin 2.0.10 #393

Closed
jamiesanson opened this issue Sep 4, 2024 · 6 comments · Fixed by #395
Closed

Annotation not available to testFixtures post-Kotlin 2.0.10 #393

jamiesanson opened this issue Sep 4, 2024 · 6 comments · Fixed by #395

Comments

@jamiesanson
Copy link
Contributor

jamiesanson commented Sep 4, 2024

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?

@JakeWharton
Copy link
Collaborator

It might be better to no-op the compiler plugin if the runtime isn't present in a compilation unit.

@jamiesanson
Copy link
Contributor Author

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.

@JakeWharton
Copy link
Collaborator

That error comes from the plugin attempting to locate its own runtime:

moduleFragment.reportError("Could not find class <$pokoAnnotationName>")

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.

@jamiesanson
Copy link
Contributor Author

Ah! Nice. No-oping the compiler plugin sounds like the move, then. Happy to send a PR through for this shortly.

@JakeWharton
Copy link
Collaborator

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).

@jamiesanson
Copy link
Contributor Author

Changed the error to an information message to not break -Werror in #395 - let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants