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 {

 

0
3 comments

Hi,

You can use properties like “dev” and “prod” passed to ./gradlew command like ./gradlew -Pdev … or  ./gradlew -Pprod …. In your build script, use:

if (project.hasProperty("dev")) {
  // do something dev specific
}
if (project.hasProperty("prod")) {
  // do something production specific
}
0

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?

0

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

0

Please sign in to leave a comment.