I am publishing a plugin with 3 names, one for each Environment:
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
What about this?
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.
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
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
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:
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