How to read a properties files and use the values in project Gradle script?

前端 未结 3 1909
悲哀的现实
悲哀的现实 2020-12-04 14:08

I am working on a Gradle script where I need to read the local.properties file and use the values in the properties file in build.gradle. I am doin

3条回答
  •  有刺的猬
    2020-12-04 14:49

    Another way... in build.gradle:

    Add :

    classpath 'org.flywaydb:flyway-gradle-plugin:3.1'
    

    And this :

    def props = new Properties()
    file("src/main/resources/application.properties").withInputStream { props.load(it) }
    apply plugin: 'flyway'
    flyway {
        url = props.getProperty("spring.datasource.url")
        user = props.getProperty("spring.datasource.username")
        password = props.getProperty("spring.datasource.password")
        schemas = ['db_example']
    }
    

提交回复
热议问题