unable to pass spring profile from gradle command line - spring

I have gone through multiple suggestions in stackoverflow but unable to do it.
I have spring boot gradle app and trying to execute and run the gradle build through command line. I want to pass teh spring profile also while executing so.
I tried adding
bootRun {
systemProperties = System.properties
}
in gradle.build
and also tried
gradle bootrun -Pdev
command but it is not pciking up profile. I am very very new to gradle and dont sure what to do .

so i added below part in build.gradle
bootRun {
systemProperties = System.properties
}
and i used below command line command to pass spring profile.
gradle bootRun -Dspring.profiles.active=dev
i am able to see the below spring profile loaded logs.
The following profiles are active: dev

Related

Spring-boot app logs to file in command line gradle

I was trying to log spring boot app logs to a file in Gradle.
Below is working for maven:
mvn spring-boot:run -Dspring-boot.run.profiles=it --log-file log.txt
This is my gradle startup command:
gradle.bat bootRun --args='--spring.profiles.active=it'

Intellij how to set gradle property -Pname=value

Intellij: how to set gradle property -Pname=value?
build from command line:
gradlew assemble -PuseNewLibs=true
How to do this inside Intellij?
The property tells gradle to use different dependencies.
In your run configuration, you can add -PuseNewLibs=true to the Program arguments: section.

Task 'bootRepackage' not found in root project 'gateway'

I am reading Full Stack Development with JHipster book.
I created a Microservice gateway with 'gateway' app name.
By following the book when I run
./gradlew bootRepackage -Pprod buildDocker
in the terminal, it says
Task 'bootRepackage' not found in root project 'gateway'
and then stop running.
My Jhipster version is 5.0.0
In JHipster v5.0.0+, the goal bootRepackage doesn't exist. It has changed to bootWar, so you need to use:
./gradlew bootWar -Pprod buildDocker
I have similar issue for Spring Boot 2.X. And solved it by changing to bootJar.
gradlew clean && gradlew bootJar

How to set environment variables for gradle build from spring boot application.properties via command line?

i want to be able to set environment variables during gradle build.
Below is the application.properties in spring boot
spring.datasource.url=${host}
spring.datasource.username=${username}
spring.datasource.password=${password}
whe trying to build a jar i want to be able to set
something like, gradle build -Dusername="user" -Dpassword="pwd" -Dhost="192.X.X.X"
How do i achieve in gradle?

Spring Boot Gradle bootRun task default classpath and current working directory

I am going to test external config for application. What is default classpath and default working directory for Spring Boot Gradle bootRun task?
I didn't get in from:
http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-running-your-application.html
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html
UPDATE test with System.getProperty("user.dir") show that current directory is where Gradle is started.
Working directory is actually the module with Spring Boot project, which does not necessarily have to be the rootProject.
Classpath for bootRun is:
working directory (or Gradle project directory with Spring Boot)
main classes
runtime classpath
At least this is what seems to be the default when I debug the build (now easily possible with IntelliJ IDEA 2018.2).

Resources