How to pass system property to Gradle task

前端 未结 14 2556
别跟我提以往
别跟我提以往 2020-12-08 02:17

I\'m using Gradle spring-boot plugin and I need to select a spring active profile for the test run.

How do I pass spring.profiles.active sy

14条回答
  •  独厮守ぢ
    2020-12-08 03:09

    There is no generic way to pass system properties to a task. In a nutshell, it's only supported for tasks that fork a separate JVM.

    The bootRunLocal task (as defined above) will not execute in a separate JVM, and calling execute() on a task isn't supported (and would have to happen in the execution phase in any case). Tests, on the other hand, are always executed in a separate JVM (if executed by a Test task). To set system properties for test execution, you need to configure the corresponding Test task(s). For example:

    test {
        systemProperty "spring.profiles.active", "local"
    }
    

    For more information, see Test in the Gradle Build Language Reference.

提交回复
热议问题