ttt*_*ttt 4 groovy spring yaml gradle
我有具有以下属性的yml文件:
spring:
application:
name: auth module
profiles:
active: prod
Run Code Online (Sandbox Code Playgroud)
在我gradle.build:
jar {
baseName = 'auth-module-dev'
version = '0.1.2'
}
Run Code Online (Sandbox Code Playgroud)
我想构建像auth-module-%profile_name%.jar这样的jar。我怎样才能做到这一点?
dag*_*ett 10
假设您的yaml文件具有名称 cfg.yaml
别忘了---在Yaml开头添加
---
spring:
application:
name: auth module
profiles:
active: prod
Run Code Online (Sandbox Code Playgroud)
build.gradle:
defaultTasks "testMe"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.yaml', name: 'snakeyaml', version: '1.19'
}
}
def cfg = new org.yaml.snakeyaml.Yaml().load( new File("cfg.yaml").newInputStream() )
task testMe( ){
doLast {
println "make "
println "profile = ${cfg.spring.profiles.active}"
assert cfg.spring.profiles.active == "prod"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6113 次 |
| 最近记录: |