# Create multiple jars, one for each environment(spring profile) using spring-boot

**URL:** <https://discuss.gradle.org/t/create-multiple-jars-one-for-each-environment-spring-profile-using-spring-boot/28406>\
**Category:** Buildship\
**Created:** [August 29, 2018, 2:03pm UTC](https://discuss.gradle.org/t/create-multiple-jars-one-for-each-environment-spring-profile-using-spring-boot/28406 "2018-08-29T14:03:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidTomic](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@DavidTomic](https://discuss.gradle.org/u/DavidTomic)\
**Post date:** [August 29, 2018, 2:03pm UTC](https://discuss.gradle.org/t/create-multiple-jars-one-for-each-environment-spring-profile-using-spring-boot/28406/1 "2018-08-29T14:03:15Z")

</div>

Hi,

I want to have 3 tasks:

buildLocal  
buildDev  
buildProd

each of them will create jar file for specific spring-boot-profile.

i.g.  
buildLocal task will use application.properties  
buildDev task will use application-dev.properties  
buildProd task will use application-prod.properties

when running spring-boot app this are options to provide specific profile:

1. Set spring.profiles.active parameter in application.properties
2. _WebApplicationInitializer_
3. JVM System parameter
4. Environment variable

I want to use 1. option because that way I will have jar which knows which profile is activated.

I tried something like this:

> ```
> task buildDev {
> 
> doLast {
>       	
> def file = file('src/main/resources/application.properties')
>       
> def lines = file.readLines()
> lines.remove(0)
>       
> file.write "spring.profiles.active=dev\n"
> lines.each { line ->
> file << line + "\n"
> }
> }
> }
> 
> ```
> 
> buildDev.dependsOn build

This almost works, jar file is how it should be, but the problem is, application.properties in a project is changed too, which I don’t want, it should be same as before launching buildDev task.

I will appreciate any help here, thank you.
