我正在尝试自定义gradle以从groovy文件中获取flyway属性
我的environment.groovy文件
environments {
dev {
flywayProperties {
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521/XE"
user="test"
password="test"
locations= "classpath:db/migration,db/insert"
}
}
qa {
flywayProperties {
driver = "oracle.jdbc.driver.OracleDriver"
url = "jdbc:oracle:thin:@localhost:1521/XE"
user = "test"
password = "test"
locations = "classpath:db/migration"
}
}
}
和我的build.gradle
loadConfiguration()
task printProps << {
println "Driver: $config.flywayProperties.driver"
println "URL: $config.flywayProperties.url"
println "User: $config.flywayProperties.user"
println "Password: $config.flywayProperties.password"
println "Locations: $config.flywayProperties.locations"
}
def loadConfiguration() {
def environment = hasProperty('env') ? env : 'dev'
project.ext.envrionment = environment
println "Environment is set to $environment"
def configFile = file('environment.groovy')
println configFile.toURL()
def config = new ConfigSlurper("$environment").parse(configFile.toURL())
project.ext.config = config
}
flyway {
driver = "$config.flywayProperties.driver"
url = "${config.flywayProperties.url}"
user = "${config.flywayProperties.user}"
password = "${config.flywayProperties.password}"
//locations = ['classpath:db/migration' , 'db/insert'] -- Works fine
locations = "${config.flywayProperties.locations}" -- Throws below error
}
尝试执行“ gradle flywayInfo”时出现以下错误
**失败:构建失败,并出现异常。*出了什么问题:任务':flywayInfo'的执行失败。
执行flywayInfo位置未知前缀时发生错误(应该是文件系统:或类路径:)::**
有人可以帮助我如何提供位置。因为我需要根据环境提供多个位置
谢谢
您是否尝试过:
locations = config.flywayProperties.locations
?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句