Can I use the application plugin to create environment specific distributions

I’m using the application plugin to generate a standalone distributable for my java app - it’s almost perfect I just can’t figure out how to create environment specific distributions

Under my src/dist directory I have sub directories which separate config per environment, e.g.

src/dist/prod/config/… src/dist/test/config/…

When I execute gradle distZip I end up with all of these files in my distribution - as expected. I would like to be able to create environment specific distributions, so that when I execute something like: gradle prodDistZip I only get the files included under src/dist/prod (along with the rest of my application binaries)

After reading the documentation for the application plugin I can’t see any way this can be configured. Does anybody have any suggestions as to how it may be done?

Thanks Rob

It’s probably worth mentioning I’m happy to move my configuration out of the dist folder, as the application plugin seems to just bundle this entire directory up by default

Simplest way would probably be to use a project property. Adding additional tasks would likely just complicate your build script and still leave the default ‘dist*’ tasks which would create incorrect/incomplete distributions.

$ gradle -PbuildType=prod distZip

In build.gradle

applicationDistribution.exclude([‘prod’, ‘test’] - buildType)

Thanks for the advice - worked great.