Slackbot
12/11/2023, 8:53 PMJendrik Johannes
12/11/2023, 9:03 PMJendrik Johannes
12/11/2023, 9:04 PMEli Graber
12/11/2023, 9:26 PMwithId and I'm using hasPlugin to gate against it?Jendrik Johannes
12/11/2023, 9:42 PMwithId . With hasPlugin , your code will only work if the Android plugin is applied before your own plugin.Jendrik Johannes
12/11/2023, 9:44 PMEli Graber
12/12/2023, 2:49 AMephemient
12/12/2023, 4:10 AMproject.pluginManager.withPlugin("com.android.base") {
...
}Thomas Broyer
12/12/2023, 10:40 AMVampire
12/12/2023, 10:41 AMbuildSrc or settings script classpath, your plugin is in a higher class loader and thus cannot see the AGP classes.Eli Graber
12/12/2023, 11:38 AMwithPlugin but for now I don't think it could be used. It seems to be working though, because this is all happening at serialization time because it's in a provider used as an input to a task.
it looks more like a cross-configuration issue
I'd like to not do that in the future, but how does it affect classloading? @Vampire both plugins are applied in the plugins block at the same level (i.e. in the script for the specific project)
Thomas Broyer
12/12/2023, 12:14 PM> it looks more like a cross-configuration issue
I'd like to not do that in the future, but how does it affect classloading?IIUC, the plugin is reaching to all projects in the build, so one project can have the Android plugin applied (e.g. the "app" subproject in one of the tests) but the plugin instance computing the value executes in another project where the Android plugin is not available (the "lib" subproject in the same test). Using reflection like you did, you reach for the "android" extension of that other project and use reflection on it, but never actually use Class.forName or similar, which would have the same issue as directly using the class like you did initially (unless you used Class.forName with the proper classloader).
Thomas Broyer
12/12/2023, 12:18 PMapply false).
That wouldn't explain the ClassNotFound though.Thomas Broyer
12/12/2023, 12:25 PMpluginUnderTestMetadata task's pluginClasspath ; the plugin would always be available in the classloader even if not applied to a project, so it might not detect some bugs that you'd only see later in a real project
• not using withPluginClasspath with instead either using the current build as an included build of the test project (assuming a compatible Gradle version is used for the tests) or publishing the plugin to a local Maven repository and configuring the test projects to load it from thereEli Graber
12/12/2023, 12:41 PMwithPluginClasspath thanksVampire
12/12/2023, 12:46 PMwithPluginClasspath for example by adding it to testRuntimeOnly additionally to compileOnly,
or by not using withPluginClasspath but for example deploying to some locale file-repository (something exclusive to the test execution, not mavenLocal()) and then consuming the plugin under test from that repository.