Convert to action pattern to allow multiple actions

This commit is contained in:
Richard Wackerbarth 2015-03-07 10:43:45 -06:00
parent 2f65f5fdc1
commit 0644bdc51c
1 changed files with 15 additions and 5 deletions

View File

@ -351,8 +351,7 @@ public class Compiler implements MessageConsumer {
sketchIsCompiled = false; sketchIsCompiled = false;
// Hook runs at Start of Compilation // Hook runs at Start of Compilation
if (prefs.containsKey("recipe.hooks.prebuild")) runActions("hooks.prebuild", prefs);
runRecipe("recipe.hooks.prebuild");
objectFiles = new ArrayList<File>(); objectFiles = new ArrayList<File>();
@ -423,8 +422,7 @@ public class Compiler implements MessageConsumer {
progressListener.progress(90); progressListener.progress(90);
// Hook runs at End of Compilation // Hook runs at End of Compilation
if (prefs.containsKey("recipe.hooks.postbuild")) runActions("hooks.postbuild", prefs);
runRecipe("recipe.hooks.postbuild");
return true; return true;
} }
@ -1047,6 +1045,18 @@ public class Compiler implements MessageConsumer {
execAsynchronously(cmdArray); execAsynchronously(cmdArray);
} }
void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
List<String> patterns = new ArrayList<String>();
for (String key : prefs.keySet()) {
if (key.startsWith("recipe."+recipeClass) && key.endsWith(".pattern"))
patterns.add(key);
}
Collections.sort(patterns);
for (String recipe : patterns) {
runRecipe(recipe);
}
}
void runRecipe(String recipe) throws RunnerException, PreferencesMapException { void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION); dict.put("ide_version", "" + BaseNoGui.REVISION);