-
Notifications
You must be signed in to change notification settings - Fork 12
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
Apply annotations dependency to testFixturesImplementation
#395
Apply annotations dependency to testFixturesImplementation
#395
Conversation
I think I would prefer this still be a warning. Kotlin 2.1.0 will allow suppressing specific warnings by name even when using the warnings-as-error setting (see https://youtrack.jetbrains.com/issue/KT-8087). We'll see what @drewhamilton thinks. |
The concern is that a library author adds In #393, Jake said:
Why is this better? |
The motivating example was the compiler plugin being applied to all Kotlin compilations in the Gradle project (including test fixtures, specifically) but the annotation not being present in the associated configurations. |
Yes, sorry, I meant why is this approach better than either (a) not applying Poko to test fixtures configurations by default, or (b) adding the annotations dep to test fixtures configurations by default? My gut says (a) makes more sense, because maintaining binary compatibility in test fixtures is rarely if ever needed, but maybe that's wrong? |
I don't believe we get a choice in the fact that the compiler plugin is applied. Test fixtures support compiling Kotlin and I would expect any plugins to go along with that automatically (with our use of the subplugin plugin thing). We can add the first-party dep automatically by special-casing the test fixture plugin. That was proposed. The only case you'd need to manually intervene then is if you did a compileOnly of your own dep with an annotation. |
Yeah, this PR isn't ideal - hadn't properly considered that typo case, agree this should be at minimum a warning. My original suggestion was to special case it, and add the annotations dependency automatically. Test fixtures end up being published artifacts of a library, so figured that while maintaining binary compatibility probably isn't needed all the time, some library authors may strive for it. Having Poko automatically apply this dependency to testFixture compilations as it does to other ones feels preferable here. Manual intervention would be pretty obviously needed if a developer typos, or adds their own annotation dependency to the wrong configuration - this error would persist, and could be made a little more descriptive to point them in the right direction. |
But if test fixtures are generally published with the library, it seems like special-casing the inclusion of the annotation dep for test fixtures, as @jamiesanson initially proposed, is the most intuitive behavior. |
…st-fixtures plugin applied
testFixturesImplementation
if java-test-fixtures
plugin applied
testFixturesImplementation
if java-test-fixtures
plugin appliedtestFixturesImplementation
Apologies for taking a while to get back around to this - pushed a few commits to revert the ERROR -> INFO change and apply the annotation dependency to test fixtures automatically. I've also added |
if (target.plugins.hasPlugin("org.gradle.java-test-fixtures")) { | ||
target.dependencies.add("testFixturesImplementation", annotationDependency) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably fine to start with. We may have to move this outside the if
at some point as support is expanded.
Sorry for the delay – looks great, and thanks for adding to the sample too. |
When applying Poko to JVM projects with the
java-test-fixtures
Gradle Plugin applied, addpoko-annotations
totestFixturesImplementation
.Closes #393.