-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Imad BELMOUJAHID opened MRESOURCES-284 and commented
I wanted to trace a new evolution that I added recently. This concerns the maven-resources-plugin (3.2.1-SNAPSHOT) and maven-filtering (3.3.0-SNAPSHOT) plugins.
with this evolution it is now possible to add configuration files with json format. the second part of the evolution is to have to use a single configuration json file for all environments (dev, preprod, prod)
Example of use:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<rootNode>dev</rootNode>
<!--suppress UnresolvedMavenProperty -->
<delimiters>@_*_@</delimiters>
<filters>
<filter>${project.basedir}/src/main/properties/test.json</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<rootNode>dev</rootNode> : four determine the environment if the json file contains multiple environments. if you want to use multiple files json (one for each environment), you can remove this parameter and add the full path from the root node in the ressource file (application.yml).
Example test.json:
{
"dev" : {
"type" : "toto",
"key2" : "value2",
"key3" : {
"key4" : "value4"
}
},
"qualif" : {
"type2" : "toto1",
"key5" : "value7",
"key7" : {
"key8" : "value7"
}
}
}
Example ressource file: application.yml
spring:
profiles: @_key3.key4_@
toto: @_type_@
tata: @_key2_@
Example result:
spring:
profiles: value4
toto: toto
tata: value2
I will send the PR
thanks
Affects: 3.2.0
Attachments:
Remote Links: