在属性文件中使用属性值

时间:2017-12-22 17:58:39

标签: java properties-file

我有以下键值对的属性文件,而是重复一个特定值,我可以最初声明它并在文件的其他部分动态地使用该键。我正在寻找这个sonar-project.properties文件。

原始文件

# Required metadata
sonar.projectKey=com.company.somecompany::AppName
sonar.projectName=BR_BRANCH_JAN/AppName
sonar.projectVersion=2.3.1

# Comma-separated paths to directories with sources (required)
sonar.sources=src/main/java/
#, src/test/java/
sonar.java.binaries=target/AppName-WAR-2.3.1-SNAPSHOT/WEB-INF/classes/
sonar.java.libraries=target/AppName-WAR-2.3.1-SNAPSHOT/WEB-INF/lib/*.jar
sonar.jacoco.reportMissing.force.zero=true

# Code coverage via unit tests
sonar.junit.reportPaths=target/surefire-reports
sonar.jacoco.reportPaths=target/jacoco.exec
sonar.jacoco.reportPath=target/jacoco.exec
sonar.surefire.reportsPath=target/surefire-reports

# Language
sonar.language=java

# Encoding of the source files
sonar.sourceEncoding=UTF-8

我想修改这样的东西

app.name=AppName
# Required metadata
sonar.projectKey=com.company.somecompany::${app.name}
sonar.projectName=BR_BRANCH_JAN/${app.name}
sonar.projectVersion=2.3.1

# Comma-separated paths to directories with sources (required)
sonar.sources=src/main/java/
#, src/test/java/
sonar.java.binaries=target/${app.name}-WAR-${sonar.projectVersion}-SNAPSHOT/WEB-INF/classes/
sonar.java.libraries=target/${app.name}-WAR-${sonar.projectVersion}-SNAPSHOT/WEB-INF/lib/*.jar
sonar.jacoco.reportMissing.force.zero=true

# Code coverage via unit tests
sonar.junit.reportPaths=target/surefire-reports
sonar.jacoco.reportPaths=target/jacoco.exec
sonar.jacoco.reportPath=target/jacoco.exec
sonar.surefire.reportsPath=target/surefire-reports

# Language
sonar.language=java

# Encoding of the source files
sonar.sourceEncoding=UTF-8

0 个答案:

没有答案