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
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.
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.
Something you can try is putting system properties in the gradle.properties file:
gradle.properties
systemProp.the.env.prop.name=dev
Where you literally need to prefix your property name with systemProp.. These can also be put in $HOME/.gradle/gradle.properties if you are doing this in more than one project.
Then in your Gradle build file, you would have this: