I'm using `withPluginClasspath` when testing my pl...
# community-support
e
I'm using
withPluginClasspath
when testing my plugin that interfaces with AGP, however AGP is a
compileOnly
dependency in my project. I tried also adding it as a
testImplementation
dependency, but I'm still getting errors like:
Copy code
> Failed to apply plugin 'com.eygraber.release-tag-version-code'.
   > Could not create plugin of type 'ReleaseTagVersionCodePlugin'.
      > Could not generate a decorated class for type ReleaseTagVersionCodePlugin.
         > com/android/build/gradle/AppPlugin
Changing the AGP dependency to
implementation
makes the test work, but I'd prefer to keep
compileOnly
. Any options?
t
I talk about this problem here. My suggestion is to use my testkit support plugin https://github.com/autonomousapps/dependency-analysis-gradle-plugin/tree/main/testkit
☝️ 1
πŸ’― 1
e
Ha was just reading that now πŸ˜…
m
I'm team
publish to a dedicated local maven repo and make your test tasks depend on it
.
withPluginClasspath
is too different from real life conditions
πŸ’― 1
t
I used to do it (https://github.com/tbroyer/gradle-errorprone-plugin/commit/1f86d71a38ed9178a5428af3c5f1f6c205eefcfc) but found it too cumbersome and not worth it for my use case. ymmv
(and I've since removed that dependency altogether so that's no longer a problem ☺️)
t
yah managing it manually is pretty cumbersome, which is why I wrote a plugin πŸ˜‰
πŸ† 1
e
This particular use case has a very small test suite, so it looks like I'm gonna go the
additionalPluginClasspath
route, but for anything even slightly larger or more complicated I'd use your plugin. Thanks!
πŸ‘ 2
t
another benefit of my plugin is it provides a DSL-like API for generating build scripts and source code, which I personally find preferable to managing static files, especially when I occasionally need to make large-scale cross-cutting changes to my test fixtures. but then, I have several hundred tests to manage
e
Agreed, and I enjoyed working with it on DAGP πŸ˜„
🀝 1