From ae122627de29ef85009972dc474f33418b6b8273 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Fri, 19 Mar 2010 12:34:37 +0000 Subject: [PATCH] export project config to allow project plugins to be run from executable jars --- .../java/se/sics/cooja/util/ExecuteJAR.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java b/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java index 57176da93..d7f088717 100644 --- a/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java +++ b/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java @@ -24,12 +24,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ExecuteJAR.java,v 1.8 2010/03/19 11:32:59 fros4943 Exp $ + * $Id: ExecuteJAR.java,v 1.9 2010/03/19 12:34:37 fros4943 Exp $ */ package se.sics.cooja.util; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -61,6 +62,7 @@ public class ExecuteJAR { public final static String SIMCONFIG_FILENAME = "simulation.csc"; public final static String EXTERNALTOOLS_FILENAME = "exttools.config"; + public final static String PROJECT_DEFAULT_CONFIG_FILENAME = "cooja_default.config"; public final static String FIRMWARE_SUFFIX = ".sky"; public static void main(String[] args) { @@ -418,6 +420,26 @@ public class ExecuteJAR { "Error when writing external tools configuration: " + e2.getMessage() ).initCause(e2); } + + /* Export current project configuration */ + try { + ProjectConfig pConfig = gui.getProjectConfig().clone(); + Enumeration pValues = pConfig.getPropertyNames(); + File newConfigFile = new File(workingDir, PROJECT_DEFAULT_CONFIG_FILENAME); + Properties newConfig = new Properties(); + while (pValues.hasMoreElements()) { + String name = pValues.nextElement(); + newConfig.setProperty(name, pConfig.getStringValue(name)); + } + FileOutputStream out = new FileOutputStream(newConfigFile); + newConfig.store(out, "COOJA Project Config"); + logger.info("Wrote project config: " + newConfigFile.getName()); + } catch (Exception e1) { + e1.printStackTrace(); + throw (RuntimeException) new RuntimeException( + "Error when writing project config: " + e1.getMessage() + ).initCause(e1); + } /* Delete existing META-INF dir */ File metaInfDir = new File(workingDir, "META-INF");