diff --git a/.gitignore b/.gitignore
index 3f554bd..527c78c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ target
.classpath
.project
.DS_Store
+**/*/Test.java
diff --git a/README.md b/README.md
index da60961..2cc1f9c 100644
--- a/README.md
+++ b/README.md
@@ -157,18 +157,22 @@ The apigee.config.dir option must be used to identify the top most directory con
├── api
│ ├── forecastweatherapi
│ │ ├── kvms.json
+ │ │ ├── kvms-security.json
│ └── oauth
│ ├── kvms.json
├── env
│ ├── prod
│ │ ├── kvms.json
+ │ │ ├── kvms-targets.json
│ │ ├── flowhooks.json
│ │ ├── targetServers.json
│ │ ├── references.json
│ ├── test
│ │ ├── kvms.json
│ │ ├── targetServers.json
+ │ │ ├── targetServers-backend.json
│ │ ├── keystores.json
+ │ │ ├── keystores-signed.json
│ │ ├── aliases.json
│ │ └── references.json
└── org
diff --git a/pom.xml b/pom.xml
index d747948..bc6b6ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.7.1-SNAPSHOT
+ 2.8.0-SNAPSHOT
maven-plugin
apigee-config-maven-plugin
Plugin to manage configuration in Apigee
diff --git a/samples/APIandConfig/shared-pom.xml b/samples/APIandConfig/shared-pom.xml
index 29db31a..c4ee445 100644
--- a/samples/APIandConfig/shared-pom.xml
+++ b/samples/APIandConfig/shared-pom.xml
@@ -69,7 +69,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.7.0
+ 2.8.0
create-config-targetserver
diff --git a/samples/EdgeConfig/shared-pom.xml b/samples/EdgeConfig/shared-pom.xml
index 70c60a2..15dbc94 100644
--- a/samples/EdgeConfig/shared-pom.xml
+++ b/samples/EdgeConfig/shared-pom.xml
@@ -26,7 +26,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.7.0
+ 2.8.0
create-config-targetserver
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/GatewayAbstractMojo.java b/src/main/java/com/apigee/edge/config/mavenplugin/GatewayAbstractMojo.java
index 9f79fe4..39163bc 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/GatewayAbstractMojo.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/GatewayAbstractMojo.java
@@ -19,6 +19,8 @@
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -457,7 +459,7 @@ private File findConsolidatedConfigFile()
return null;
}
- private File findConfigFile(String scope, String config)
+ /*private File findConfigFile(String scope, String config)
throws MojoExecutionException {
File configFile = new File(configDir + File.separator +
scope + File.separator +
@@ -466,27 +468,50 @@ private File findConfigFile(String scope, String config)
return configFile;
}
return null;
+ }*/
+
+ /**
+ * finds all the files for a given operation. For example kvms.json, kvms*.json
+ * @param scope
+ * @param config
+ * @return
+ * @throws MojoExecutionException
+ */
+ private List findConfigFiles(String scope, String config)
+ throws MojoExecutionException {
+ List configFiles = new ArrayList();
+ File[] listOfFiles = new File(configDir + File.separator + scope).listFiles();
+ for (File file : listOfFiles) {
+ if (file.isFile() && file.getName().startsWith(config)) {
+ configFiles.add(file);
+ }
+ }
+ return configFiles;
}
protected List getAPIConfig(Logger logger, String config, String api)
throws MojoExecutionException {
File configFile;
+ List configFiles;
String scope = "api" + File.separator + api;
+ ArrayList apiConfig = new ArrayList();
/* configDir takes precedence over edge.json */
if (configDir != null && configDir.length() > 0) {
- configFile = findConfigFile(scope, config);
- if (configFile == null) {
- logger.info("Config file " + scope + File.separator + config + ".json not found.");
- return null;
- }
-
- logger.info("Retrieving config from " + scope + File.separator + config + ".json");
- try {
- return ConfigReader.getAPIConfig(configFile);
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage());
+ configFiles = findConfigFiles(scope, config);
+ for (File cfgFile : configFiles) {
+ if (cfgFile == null) {
+ logger.info("Config file " + scope + File.separator + cfgFile.getName() + " not found.");
+ return null;
+ }
+ logger.info("Retrieving config from " + scope + File.separator + cfgFile.getName());
+ try {
+ apiConfig.addAll(ConfigReader.getAPIConfig(cfgFile));
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage());
+ }
}
+ return apiConfig;
}
/* consolidated edge.json in CWD as fallback */
@@ -545,25 +570,29 @@ protected Set getAPIList(Logger logger)
protected List getEnvConfig(Logger logger, String config)
throws MojoExecutionException {
File configFile;
+ List configFiles;
String scope = "env" + File.separator + this.buildProfile.getEnvironment();
-
+ ArrayList envConfig = new ArrayList();
+
/* configDir takes precedence over edge.json */
if (configDir != null && configDir.length() > 0) {
- configFile = findConfigFile(scope, config);
- if (configFile == null) {
- logger.info("Config file " + scope + File.separator + config + ".json not found.");
- return null;
- }
-
- logger.info("Retrieving config from " + scope + File.separator + config + ".json");
- try {
- return ConfigReader.getEnvConfig(this.buildProfile.getEnvironment(),
- configFile);
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage());
+ configFiles = findConfigFiles(scope, config);
+ for (File cfgFile : configFiles) {
+ if (cfgFile == null) {
+ logger.info("Config file " + scope + File.separator + cfgFile.getName() + " not found.");
+ return null;
+ }
+ logger.info("Retrieving config from " + scope + File.separator + cfgFile.getName());
+ try {
+ envConfig.addAll(ConfigReader.getEnvConfig(this.buildProfile.getEnvironment(), cfgFile));
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage());
+ }
}
+ return envConfig;
}
+
/* consolidated edge.json in CWD as fallback */
configFile = findConsolidatedConfigFile();
@@ -588,22 +617,26 @@ protected List getEnvConfig(Logger logger, String config)
protected List getOrgConfig(Logger logger, String config)
throws MojoExecutionException {
File configFile;
+ List configFiles;
String scope = "org";
+ ArrayList orgConfig = new ArrayList();
/* configDir takes precedence over edge.json */
if (configDir != null && configDir.length() > 0) {
- configFile = findConfigFile(scope, config);
- if (configFile == null) {
- logger.info("Config file " + scope + File.separator + config + ".json not found.");
- return null;
- }
-
- logger.info("Retrieving config from " + scope + File.separator + config + ".json");
- try {
- return ConfigReader.getOrgConfig(configFile);
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage());
+ configFiles = findConfigFiles(scope, config);
+ for (File cfgFile : configFiles) {
+ if (cfgFile == null) {
+ logger.info("Config file " + scope + File.separator + cfgFile.getName() + " not found.");
+ return null;
+ }
+ logger.info("Retrieving config from " + scope + File.separator + cfgFile.getName());
+ try {
+ orgConfig.addAll(ConfigReader.getOrgConfig(cfgFile));
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage());
+ }
}
+ return orgConfig;
}
/* consolidated edge.json in CWD as fallback */
@@ -627,22 +660,26 @@ protected List getOrgConfig(Logger logger, String config)
protected Map getOrgConfigWithId(Logger logger, String config)
throws MojoExecutionException {
File configFile;
+ List configFiles;
String scope = "org";
-
+ Map> orgConfig = new HashMap> ();
+
/* configDir takes precedence over edge.json */
- if (configDir != null && configDir.length() > 0) {
- configFile = findConfigFile(scope, config);
- if (configFile == null) {
- logger.info("Config file " + scope + File.separator + config + ".json not found.");
- return null;
- }
-
- logger.info("Retrieving config from " + scope + File.separator + config + ".json");
- try {
- return ConfigReader.getOrgConfigWithId(configFile);
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage());
+ if (configDir != null && configDir.length() > 0) {
+ configFiles = findConfigFiles(scope, config);
+ for (File cfgFile : configFiles) {
+ if (cfgFile == null) {
+ logger.info("Config file " + scope + File.separator + cfgFile.getName() + " not found.");
+ return null;
+ }
+ logger.info("Retrieving config from " + scope + File.separator + cfgFile.getName());
+ try {
+ orgConfig.putAll(ConfigReader.getOrgConfigWithId(cfgFile));
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage());
+ }
}
+ return orgConfig;
}
/* consolidated edge.json in CWD as fallback */