how to add multiple build configurations for my plugin?
Answered
Hello, I use ./gradlew clean build to build my plugin. I want there to be 2 diff configurations for build, i.e - prod(production) and dev(development) and I would want to execute some command like ./gradlew clean build prod to build for production.
In some files, I want to write some code like
If(build.isEquals("prod")) {
} else {
}
Please sign in to leave a comment.
Hi,
You can use properties like “dev” and “prod” passed to
./gradlewcommand like./gradlew -Pdev …or./gradlew -Pprod …. In your build script, use:I didn't understand it. I want to have two separate logic in a Java file. So, from build.script file, i need to store the build configuration and access it wherever I want. how to achieve this?
I misunderstood that you want to achieve it in the plugin build script.
I suggest searching for information about Gradle resource filtering. See e.g., https://stackoverflow.com/questions/25328132/is-resource-filtering-in-gradle-possible-without-using-tokens
You can store the information about the environment in some properties file in the resources folder and access it at runtime. This file should hold a placeholder for the environment value, which will be replaced with actual value during the build.
Hello, I am using ./gradlew clean build -DbuildType="prod" but when I do System.getProperty("build type") it returns null
Hi, your property name is
buildType, but you fetchbuild type. These are different values.this might be a typo here. in my program I was using correct name. Is this because there is no main class in my plugin?
Do I have to mention smthg in my build.gradle.kts file?