# Different build flavours

**URL:** <https://discuss.gradle.org/t/different-build-flavours/22688>\
**Category:** Help/Discuss\
**Created:** [May 17, 2017, 10:29am UTC](https://discuss.gradle.org/t/different-build-flavours/22688 "2017-05-17T10:29:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lshl](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lshl](https://discuss.gradle.org/u/lshl)\
**Post date:** [May 17, 2017, 10:29am UTC](https://discuss.gradle.org/t/different-build-flavours/22688/1 "2017-05-17T10:29:26Z")

</div>

I have a Java project which I compile most of the time for release candidates (development releases), and sometimes for production release.  
Now, based of the flavour I set certain properties and certain configurations.  
Currently I am doing that based on a project property (-P), but it is not very elegant.  
I tried creating tasks that based on the task tree different configurations will take effect, the problem is that the task graph is only ready after the configuration phase, which means by that time I am unable (or rather need to put in a lot of effort) to change the already set configurations.  
Is there any elegant way in which I can achieve that?

Thanks

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [May 20, 2017, 3:58pm UTC](https://discuss.gradle.org/t/different-build-flavours/22688/2 "2017-05-20T15:58:56Z")

</div>

You might be interested in my [gradle-java-flavours](https://github.com/uklance/gradle-java-flavours) plugin. It allows you to have common code / tests / resources but also have flavour specific code / test / resources. Each flavour is built into a separate jar

---

<div class="post-metadata">

**Author:** ![lshl](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lshl](https://discuss.gradle.org/u/lshl)\
**Post date:** [May 24, 2017, 1:21am UTC](https://discuss.gradle.org/t/different-build-flavours/22688/3 "2017-05-24T01:21:55Z")

</div>

Thanks for that.  
I was hoping for a simpler solution (just 2 different types of build, I know how to do it using a makefile easy, just not that fluent in gradle).  
But I did notice you have a snapshot version… so, do you separate build types between snapshot and release? If you do, how?

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [May 24, 2017, 7:01am UTC](https://discuss.gradle.org/t/different-build-flavours/22688/4 "2017-05-24T07:01:10Z")

</div>

There’s nothing automated about my release versioning. I’ve extracted my version into its own `version.txt` file so it’s easy to update from command line and see version history etc. Prior to a release I manually remove the `-SNAPSHOT` suffix. After a release I manually increment and append `-SNAPSHOT` again.

---

<div class="post-metadata">

**Author:** ![lshl](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lshl](https://discuss.gradle.org/u/lshl)\
**Post date:** [May 25, 2017, 12:09am UTC](https://discuss.gradle.org/t/different-build-flavours/22688/5 "2017-05-25T00:09:00Z")

</div>

My solution was automating Lance’s method by using a wrapper script to change the version.txt file and then invoke gradle.
