Hola
Hola

Reputation: 125

How to run a task in gradle with spring boot profile?

I created a task in Gradle to run a function in java, the function below

tasks.register("runFunction", JavaExec) {
    main = 'com.google.cloud.functions.invoker.runner.Invoker'
    classpath(configurations.invoker)
    inputs.files(configurations.runtimeClasspath, sourceSets.main.output)
    args(
            '--target', 'gfk.stream.client.cloud.functions.excel.business.FileGenerate',
            '--port', 8081,
    )
    doFirst {
        args('--classpath', files(configurations.runtimeClasspath, sourceSets.main.output).asPath)
    }
}

In the spring boot application, I have configured some classes to run with dev profile. How do I run this task( runFunction) with dev profile in spring boot? btw I am using gradlew

Upvotes: 0

Views: 276

Answers (1)

CH Liu
CH Liu

Reputation: 1884

You can set the Spring profile by system properties:

tasks.register("runFunction", JavaExec) {
    systemProperty("spring.profiles.active", "dev")
    ...
}

Upvotes: 1

Related Questions