Apply plugin with dynamic name

Good afternoon,

I am publishing a plugin with 3 names, one for each Environment: pluginName-dev, pluginName-pre and pluginName-pro.

I want to apply a different plugin depending on environment. I have checked pluginManagement block in settings.gradle.kts but it is not usefult for dynamic name, just for dynamic version value

Best regards

What about this?


plugins {

I tried this and it worked for me. You can also do system properties if you like. Though, I don’t believe that you can access Gradle project properties from that block.

1 Like

First of all, thank you for your help @EarthCitizen

The users of the plugin set environment at the first line of gradle file. Is it possible to convert this variable into a System Property before reading it in plugins block?

Which part of the build.gradle.kts file gets executed before the plugins code? So I can set in that part the environment variable.

Thanks in advance!

The plugins block is before everything else.

Something you can try is putting system properties in the file:

Where you literally need to prefix your property name with systemProp.. These can also be put in $HOME/.gradle/ if you are doing this in more than one project.

Then in your Gradle build file, you would have this:

plugins {

If that does not work, then you need to externalize the system property or environment variable.

At the end I used System environment variable as it is executed from a CI/CD pipeline.

Thank you very much :slight_smile: