Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It should be easier to set which profile is active when running gradle tasks #832

Closed
berlin-ab opened this issue May 9, 2014 · 13 comments
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@berlin-ab
Copy link

When I run:

$ gradle bootRun -Pspring.profiles.active=dev

or

$ gradle bootRun -Dspring.profiles.active=dev

... my application does not start in the dev @Profile, and it should.

Here's my example project:

https://github.com/berlin-ab/springbootblog/tree/blog/profiles

@berlin-ab
Copy link
Author

It works after following the advice here: #592

Although, I think there should be a change made to the gradle plugin to make this the default. We want to be able to run specify that gradle should use the test profile, and we want to do that often.

@dsyer
Copy link
Member

dsyer commented May 12, 2014

When you say "make this the default" what exactly does that mean? Does it amount to setting run { systemProperties = System.properties } in the plugin (instead of requiring you to do it in "build.gradle"? Or do you want to create a project template for your work that has that set already (along the lines of some of your other queries), and we could do that outside Boot?

@berlin-ab
Copy link
Author

@dsyer I was intentionally leaving the solution up to you by being vague, but now that you ask... I'd put the configuration in the spring boot gradle plugin, so it is not something that the developer needs to think about.

@dougio
Copy link

dougio commented Aug 23, 2015

I set spring profile in a shell variable as was mentioned here, this is simple enough for me.

SPRING_PROFILES_ACTIVE=dev gradle clean bootRun

@JamesMcMahon
Copy link

While the shell variable solution is great it still feels like this something missing from Spring boot, especially given it's close parity with Rails.

@jklap
Copy link

jklap commented Nov 8, 2016

Would be nice if you could set the profile in build.gradle cleanly such as

bootRun {
  profile: development
}

Seems like the best suggestion from #592 is:

bootRun {
  environment SPRING_PROFILES_ACTIVE: environment.SPRING_PROFILES_ACTIVE ?: "local"
}

@philwebb philwebb added the type: enhancement A general enhancement label Nov 15, 2016
@vjm
Copy link

vjm commented Jan 16, 2017

adding bootRun.systemProperties = System.properties to your gradle will respect gradle bootRun -Dspring.profiles.active=dev.

@wilkinsona
Copy link
Member

#1176 will address this

@mjustin
Copy link

mjustin commented Apr 24, 2017

I really like @jklap 's suggestion, which is different than this request (and the ticket it was closed as a duplicate of):

Would be nice if you could set the profile in build.gradle cleanly such as

bootRun {
  profile: development
}

Is that worth creating a separate issue for?

@wilkinsona
Copy link
Member

@mjustin Yes, a separate issue would be better for that as it's rather different to setting active profiles via the command line which is what's covered here and by #1176.

@kabmamadi
Copy link

Hello.
I couldn't make it work with -Dspring.profiles.active=dev.
So I directly added the profile in my environment: export SPRING_PROFILES_ACTIVE=test
And it works.

@marlonklc
Copy link

When I run:

$ gradle bootRun -Pspring.profiles.active=dev

or

$ gradle bootRun -Dspring.profiles.active=dev

... my application does not start in the dev @Profile, and it should.

Here's my example project:

https://github.com/berlin-ab/springbootblog/tree/blog/profiles

The best way that a found was:
./gradlew bootRun --args='--spring.profiles.active=local'

just specificy what profile do you want and be happy.

I hope that it works to another person.

Cheers!

@ShanikaEdiriweera
Copy link

Is there a way to specify profile when running gradle build ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests