Hey Rahul,
You should be able to accomplish this using the Maven resources plugin. The general idea is that you could copy the source contents into a temporary location, and while doing so apply Maven’s filtering. If you are using a multi-file configuration, then you’d copy the entire directory, or if you are using a single file config you’d just copy edge.json by itself.
In the example below, I have my multi-file config under a directory called “config” (sitting next to the “apiproxy” directory). Using the maven resources plugin, I am able to copy the contents of both
<PROJECT_DIR>/apiproxy/*
<PROJECT_DIR>/config/*
into
<PROJECT_DIR>/target/apiproxy/*
<PROJECT_DIR>/target/config/*
When the files are copied, maven scans inside each file and replaces every string delimited by the ‘@’ with the proper value. (this is because I specified that @ is the delimiter character). For example, if I have a file with the following text:
{
"envConfig": {
"@apigee.env@": {
...
}
}
Assuming that, the system property “apigee.env” is defined and has value of “test”, the new file will look like this:
{
"envConfig": {
"test": {
...
}
}
Note that for this to work properly, you have to tell the Apigee config plugin which directory contains the configuration files. This is done using the “apigee.config.dir” property.
e.g.
<apigee.config.dir>${basedir}/target/config/edge</apigee.config.dir>
Here is the actual XML config for the maven resources plugin. Once again, in this example I am copying both the contents of the “apiproxy” directory, and the “config” directory.
It’s likely that in your setup you are already calling the same plugin to copy the contents of the “apiproxy” directory. You can remove that and use just this plugin config … or combine this example with your existing plugin config.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<encoding>utf8</encoding>
<outputDirectory>${basedir}/target</outputDirectory>
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<resources>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>apiproxy/**</include>
<include>config/**</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
I hope this helps!