Slackbot
01/28/2023, 9:54 PMVampire
01/28/2023, 11:59 PMLilly
01/29/2023, 12:56 AMJavi
01/29/2023, 11:02 AMVampire
01/29/2023, 5:02 PMVampire
01/29/2023, 5:04 PMTrue story but then I have to track the version of Kotlin and Android Gradle Plugin in both builds.
Why? If you depend on those plugins in your PSP plugin build and then apply your PSP plugin that applies those plugins, why do you then need to track the versions again in the consumer build?
Lilly
01/29/2023, 8:45 PMproject-gradle.kts
which is applied in the project-level build.gradle.kts of the main project.
project-gradle.kts:
plugins {
/*
* It is not possible to add android.application and android.library at the same time.
* The same applies for kotlin.android and kotlin.jvm.
*/
// Provides version updater
id("com.github.ben-manes.versions")
// Provides code analyzing
id("de.acme.configuration.code-analyzing")
// Provides suggestions for build optimizations
id("com.osacky.doctor")
}
project-level build.gradle.kts:
plugins {
// Provides code analyzing and a gradle versions updater
alias(libs.plugins.dc.project)
// Provides android support
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
// Provides kotlin support
alias(libs.plugins.kotlin.android).apply(false)
alias(libs.plugins.kotlin.jvm).apply(false)
}
In the latter snippet, the first plugin is my PSP followed by the AGP plugins for android.application and android.library. I know android is not your sphere but do you think it is possible to apply android and kotlin plugins via the PSP?Lilly
01/29/2023, 8:51 PMplugins
block of project-gradle.kts I get following error:
FAILURE: Build failed with an exception.
* Where:
Precompiled script plugin 'D:\dev\android\workspace\dcapps\configuration-plugin\src\main\kotlin\de\acme\configuration\project.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'com.android.library']
> Failed to apply plugin 'com.android.internal.library'.
> Cannot add a configuration with name 'androidJdkImage' as a configuration with that name already exists.
Exception is
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.android.library']
Vampire
01/29/2023, 9:13 PMcom.android.application
and com.android.library
together.
In the upper version you also don't do that, you just add them to the classpath (apply(false)
).
But if you add them to the plugins block of your psp, you are trying to apply them both, that's something different.
If you just want them on the classpath when your psp is applied, just depend on them in your psp-building project.
If you want to apply those plugins via psp, you should probably have to different psp, one for either and both could apply another psp that does common things.Lilly
01/29/2023, 9:25 PMIf you just want them on the classpath when your psp is applied, just depend on them in your psp-building project.Can you help me with that? What exactly do I have to do?
Vampire
01/29/2023, 10:58 PMapply(false)
to your psp, right?Vampire
01/29/2023, 10:59 PMVampire
01/29/2023, 11:00 PMapply(false)
in a psp, as the only sense for apply(false)
is to bring a plugin to the classpath.
But with a psp, the plugin already is on the classpath purely by having the implements
or runtimeOnly
dependency on it.
That's also why you can apply it without verison, because it is already on the classpath.Vampire
01/29/2023, 11:00 PMLilly
01/30/2023, 10:12 AMimplementation
dependency on it in PSP buildLilly
01/30/2023, 10:13 AM@Suppress("DSL_SCOPE_VIOLATION")
plugins {
// Provides code analyzing and a gradle versions updater
alias(libs.plugins.dc.project)
}
More slimmer and it also works like a charm ❤️