Lilly
03/28/2024, 5:43 PMincludeBuild("./configuration-plugin")
In my android build I can apply the plugins like:
plugins {
id("de.mycompany.configuration.scripts.android.application")
}
The package structure of my composite build where the convention plugins rely is de.mycopnay.configuration.scripts...(e.g. android-application.kts)
. Is it possible to shorten the name without changing the package structure, so i can apply the plugins as:
plugins {
id("convention.android.application")
}
Vampire
03/28/2024, 7:20 PMLilly
03/28/2024, 9:31 PM1. Inside your buildSrc or composite build project, create a directory structure following this pattern: src/main/resources/META-INF/gradle-plugins.
2. Create a properties file named after your desired additional plugin ID. For example, for the ID de.mycompany.configuration.scripts.android-application, you would create a file named de.mycompany.configuration.scripts.android-application.properties.
3. In that properties file, specify the implementation-class property that points to the generated class name of your precompiled script plugin. This can be tricky with precompiled script plugins, as the implementation class is generated by Gradle. For precompiled scripts, the class name typically follows the pattern org.gradle.kotlin.dsl.<file-name-without-extension>, but you may need to inspect the build output to determine the exact class name.
Is this waht you mean or can I achieve it another (maybe better) wayLilly
03/28/2024, 9:53 PMgradlePlugin {
plugins {
create("myPlugins") {
id = "my-plugin"
implementationClass = "my.MyPlugin"
}
}
}
where implementationClass points to the generated plugin class in the /build folder?Thomas Broyer
03/29/2024, 8:00 AMconvention.android.application.gradle.kts
that contains:
plugins {
id("de.mycompany.configuration.scripts.android.application")
}
?Lilly
03/29/2024, 3:02 PMsrc/kotlin/convention.android.application.gradle.kts
right?Vampire
03/29/2024, 3:11 PMI'm not aware of this approach so I had to ask ChatGPT and got:Please be aware, that ChatGPT (and all similar AI tools) is perfectly fine in giving answers that look correct, but utterly bad in giving answers that are correct. They are pretty unsuitable to answer questions you don't know the answer of already. They are great to do stuff you are too lazy to do (the good kind of lazy, not the bad one) as you have to understand what it gives you, remove the non-sense and make it work properly. What it told you can be done yes, but doing it in
buildSrc
when you already have an included build is pretty much non-sense.
What I meant was what you wrote second which then effectively creates that file on-the-fly, but you can of course also create the file in src/main/resources
manually in your plugin project.
What Thomas said is also one variation, it does not simply create a second ID for the new plugin, but creates a whole new plugin that applies the other one.
Use whatever you like more. 🙂
And yes, if you go the second-plugin approach, naming the file src/kotlin/convention.android.application.gradle.kts
and not having a package statement is one option.
Naming it application.gradle.kts
with package statement convention.android
would be another.Vampire
03/29/2024, 3:12 PMmy-plugin
concretely is a bad idea, all non-built-in plugins should be namespaced, i. e. contain at least one dot.
IDs without dot should stay reserved for built-in plugins, then you are also sure that there will not be a name clash in a newer Gradle version.Lilly
03/29/2024, 10:37 PMVampire
03/29/2024, 10:54 PMLilly
03/29/2024, 10:57 PMVampire
03/29/2024, 10:58 PMLilly
03/29/2024, 10:59 PM