This message was deleted.
# community-support
s
This message was deleted.
n
My suggestion would be to not use mavenlocal, but instead use a composite build to try out your plugin.
j
I usually use composite build... you can see the
includeBuild
commented there... but composite build does not support settings plugins
e
that's not right, it does support settings plugins
but if you really want to consume it from a maven repo, make sure the marker artifact is published
j
I am using
Copy code
`maven-publish`
and running the command
Copy code
./gradlew publishPluginMavenPublicationToMavenLocal
which I understand to publish the artefacts in my local maven repository...
When I use the
includedBuild
and apply the settings plugin
Copy code
plugins {
    id("com.veepee.settings")
}
, I get this error
Copy code
Build file '/Users/julio.buenocotta/git/gradle-plugins/plugins-sample/build.gradle.kts' line: 1

Error resolving plugin [id: 'com.veepee.kotlin.android.application', version: '0.2.3', apply: false]
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
even if I force a given plugin version in the settings.gradle.kts file
Copy code
plugins {
    id("com.veepee.settings") version "0.2.3"
}
without this plugin block, I can compile and run the sample app using composite builds
n
I'm confused. It's complaining about a different plugin though 🤔
j
that plugin is part of the convention plugins project that I am working on.
n
so there's something else wrong, it's not the composite build at fault here, right?
j
well, if I use composite build, I can't use the settings plugin because of this error... it seems I was wrong in understanding that Settings plugins are not supported in composite builds
I thought in using the local published version to see if I could evercome this issue of
unknown version
n
Can you just remove the version from the
android.application
plugin and see if that works?
for reference, I'm using the suggestion given here: https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638 (albeit in a different context)
j
I am not adding
alias
to my root
build.gradle.kts
file as I am declaring the configured plugins like this
Copy code
implementation(libs.gradlePlugin.android)
so I can bind AGP version with a version of the plugin itself.
n
so in your settings plugin, you depend on a version of the android.application plugin, right? In the consuming project, are you also applying that same android.application plugin? If so, does it come with a version specified?
j
no, my settings plugin does not depend on AGP, but my "convention plugins" project does. As such, the client project does not declare anything related to AGP...
just so you know...
Copy code
Error resolving plugin [id: 'com.veepee.kotlin.android.application', version: '0.2.3', apply: false]
this is one of my plugins
not AGP, but it applies AGP plugin there...
v
It is wrong that composite build does not support settings plugins.
🆗 1
n
yes, I kind of got that from the other plugin's id 😛 it's that one that's throwing the error, not the AGP plugin, so I'm not sure why you keep bringing that one up?
v
It is one of the reasons that
includeBuild
within
pluginManagement { ... }
was added, exactly for the use-case, that an included build can provide a settings plugin
j
Ok, got it. I was wrong.
v
The error you posted said something about
apply false
so I think it is a different place it complains about, not the application through the
plugins { ... }
block
Besides that, the publish task you executed just publishes the code artifact
But as was said before, it does not publish the marker artifacts which are needed to resolve from plugin ID to some artifact coordinates
Do not use a specific publish task if you really want to use maven local, but use the do-all
publishToMavenLocal
then all artifacts you need are published
But I strongly recommend too to instead get the composite build working properly and throwing out maven local which is broken by design in Maven already, and makes builds slower and flaky
Especially as first repository and without content filter
n
I'm assuming somewhere in the client project there's
Copy code
id("com.veepee.kotlin.android.application") version "0.2.3" apply false
And your convention plugin is bringing in that same plugin through the composite build. My point was to remove the version from that plugin to try if that circumvents the problem you're seeing. I believe I caused some confusion by not spelling out the entire name of your android.application convention plugin. I'm not an android developer, so I wasn't aware that there's an actual plugin out there with id exactly
android.application
🤷
Or I'm just completely wrong on all of this, in which case, feel free to ignore me 😛
j
OK, I published a version with
publishToMavenLocal
, commented my
includedBuild
and tried to apply my settings plugin.. The result is that I still have the error
Copy code
Error resolving plugin [id: 'com.veepee.kotlin.android.application', version: '0.2.3', apply: false]
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
if I remove
Copy code
plugins {
    alias(libs.plugins.veepee.kotlin.android.application) apply false
from my client project... it will go complain in the place where I apply the plugin with the same error.
n
so what does that apply look like?
j
regular ?
Copy code
plugins {
    alias(libs.plugins.veepee.kotlin.android.application)
    alias(libs.plugins.veepee.flavors.android.application)
    alias(libs.plugins.veepee.android.test.android.application)
    alias(libs.plugins.veepee.flank.android.application)
    alias(libs.plugins.veepee.publishing.android.application)
    // alias(libs.plugins.veepee.crashlytics.android.application)
    alias(libs.plugins.veepee.compose.android.application)
    alias(libs.plugins.veepee.dagger)
    // id("com.google.gms.google-services")
}
@Vampire, thanks for the correct maven task. With that I was able to rule out some doubts. I will keep the included build config and try to make it work...
n
yeah, this seems like a very complex setup to try and debug as a black box to be honest 🤔 I would try and reduce it down as much as possible...
v
Yeah, if the plugin comes in already and you try to apply it again with version (which
alias
is doing), then it only works if Gradle knows which version was brought in to the classpath, otherwise you get exactly that complaint you posted. Apply it without version and it should work.
Here is an issue about that topic that also contains mitigation strategies iirc: https://github.com/gradle/gradle/issues/17968
Copy code
plugins {
    id(libs.plugins.veepee.kotlin.android.application.get().pluginId)
}
j
Ok, trying...
So, this issue is related to the issue @Niels Doucet shared, I was able to make it work in my sample with the workaround shared in the issue and by @Vampire, but it is not worth changing from
alias
to
id
in my real projects... @Vampire shared an issue about being able to use version catalog without version, but that seems like a work around the limitation of not using version catalog in settings.gradle.kts, wouldn't this issue of classpath with unknown version be solved if we could use the version catalogs in settings file? Anyways, thank you very much to all of you.
n
Feel free to add your feedback on those linked github issues. Glad you could make it work 👍
v
Being able to use version catalog in settings script will not happen due to hen-and-egg problem. The feature is designed in a way so that settings plugins can contribute a version catalog. So you cannot use a version catalog to apply a settings plugin as the version catalogs can only be available after the settings plugins were applied. But besides that, it would not change anything. If you for example add a plugin to the settings script classpath, for example by applying it, it is in the class loader of the settings script. This class loader is the parent class loader of the build script class loader. The class loader does not have information about which plugin versions were added to it, so the compatibility cannot be checked, no matter which way you added the plugin to the settings script classpath.
j
what would be the correct way to solve the issue in a way that we don't have to revert to
id
? To me, n00b, in gradle, it seems that gradle is mixing it's infra with the infra it offers to it's users...
v
The class loader can also not really know which version of a plugin was added to it. Theoretically plugin X in version Y could be in code artifact Z of version A. The actual reliable plugin version is just contained in the marker artifact and that does not even really have to be used to add the plugin to the classpath. So it is unlikely that this will ever change, unless plugins in future are forced to provide some standardized means to get their version in use somehow.
what would be the correct way to solve the issue in a way that we don't have to revert to
id
?
Depends on the gory details, if there is a way at all. How does the situation happen? Do you have settings plugins and project plugins in the same artifact and try to apply the settings one to settings and the project one to project?
If so, then split your plugin build into two+ projects, one for the settings plugin, one for the project plugins, and maybe one for common logic if you have some.
j
yes, that is my exact context, I thought about splitting it in two projects. I will explore that after I am back from my vacations that starts in a few hours 😛
v
You might want to then add a check that the versions are in sync, for example have the version in a class in the common artifact and in a class in the build plugin artifact, then compare those versions when a project plugin is applied. Due to the classloader hierarchy the common class used would always be the one from the settings class loader, so you cannot use the version from the common artifact in the comparison for the project artifact version.
j
You lost me when you started talking about classloaders... Any sample project?
v
Unfortunately not. But you can ignore the part about the classloaders, that was just explanatory, and just do exactly what I said if you want to ensure the version is the same. 🙂