Simon Marquis
07/18/2025, 11:42 AMbuild-logic
directory which contains convention plugins that is add to the main build with
pluginManagement {
includeBuild("build-logic")
}
Everything works great, until I add a settings plugin (Plugin<Settings>
) that I try to apply on the main build.
The plugin is correctly applied since we can see the generated log, but the build fails right after, with a weird message about corrupted cache:
* What went wrong:
An exception occurred applying plugin request [id: 'nowinandroid.android.application']
> Failed to apply plugin 'nowinandroid.android.lint'.
> Type com.android.build.api.dsl.ApplicationExtension not present
....
....
Caused by: java.lang.TypeNotPresentException: Type com.android.build.api.dsl.ApplicationExtension not present
at org.gradle.api.reflect.TypeOf.captureTypeArgument(TypeOf.java:299)
at org.gradle.api.reflect.TypeOf.<init>(TypeOf.java:96)
at AndroidLintConventionPlugin$apply$lambda$0$$inlined$configure$1.<init>(TypeOfExtensions.kt:28)
at AndroidLintConventionPlugin.apply(AndroidLintConventionPlugin.kt:52)
at AndroidLintConventionPlugin.apply(AndroidLintConventionPlugin.kt:25)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:55)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:190)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
....
....
Caused by: java.lang.ClassNotFoundException: com.android.build.api.dsl.ApplicationExtension
at org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader.findClass(VisitableURLClassLoader.java:187)
(I can share the full stacktrace if needed)
Here is the corresponding code: https://github.com/android/nowinandroid/pull/1908/filesSimon Marquis
07/18/2025, 11:56 AMincludeBuild("build-logic-settings")
(nested projects will not work) with only this Plugin<Settings>
no longer breaks the build, but it makes duplicating a lot of files.Simon Marquis
07/18/2025, 11:57 AMSimon Marquis
07/18/2025, 11:58 AMSimon Marquis
07/18/2025, 12:07 PMVampire
07/18/2025, 6:11 PMSimon Marquis
07/18/2025, 6:20 PMEither add AGP to the settings classpath,Not only AGP but also all the other plugins referenced in the build-logic project then?
or split the settings plugin off into a separate project. A separate sub project in the build logic build would be enough as long as you don't depend on the artifact with the project pluginsI'm not sure what you mean here. When I tried this solution, with 2 distinct projects nested in the build-logic included build, Gradle would complain that it can't find the settings plugin id.
Vampire
07/18/2025, 11:05 PMNot only AGP but also all the other plugins referenced in the build-logic project then?Possible, it depends. If you for example have
implementation
dependencies they are pulled in automatically.
But AGP you only have as compileOnly
dependency to react to the plugin being applied but not pull in the plugin to the classpath if the project does not actually apply it.
But by having the AGP in a child class loader now, your convention plugin can no longer see it if only added to the build script classloader.
I'm not sure what you mean here. When I tried this solution, with 2 distinct projects nested in the build-logic included build, Gradle would complain that it can't find the settings plugin id.Then you probably did something wrong and need to show what you did exactly. š I just tried again to be sure and it works just fine.
Simon Marquis
07/19/2025, 8:27 AMPlugin<Project>
Plugin<Settings>
⢠1 included build containing one project with Plugin<Project>
only, and manually copying the Plugin<Settings>
inside the main settings.gradle.kts
⢠2 included builds containing each Plugin<Project>
/ Plugin<Settings>
And the last version was always ~15s slower than the others, for a baseline of ~70s clean syncSimon Marquis
07/19/2025, 9:35 AMSimon Marquis
07/28/2025, 3:11 PMinternal val Project.libs get() = ...
and after the refactor, it seems like the IDE uses this instead of the generated VersionCatalog accessors for the syntax highlighting, even though everything compiles just fine, and the go-to-declaration works fine as well.
The autocompletion on the other hand references the values declared by my custom extension.Simon Marquis
07/28/2025, 3:41 PMVampire
07/28/2025, 4:04 PMSimon Marquis
07/28/2025, 4:06 PMSimon Marquis
07/28/2025, 4:08 PMVampire
07/28/2025, 4:09 PMVampire
07/28/2025, 4:09 PMVampire
07/28/2025, 4:09 PMVampire
07/28/2025, 4:10 PMSimon Marquis
07/28/2025, 4:10 PMVampire
07/28/2025, 4:11 PMSimon Marquis
07/28/2025, 4:46 PMHERE!
commentsVampire
07/28/2025, 9:15 PMinternal
classes are even considered, even if there were no version catalog.
If you remove the version catalog, the compiler complains for both lines that libs
is internal.