From 6a99037c8042c907fb96e1e0b49833b3db527efe Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Mon, 21 Nov 2011 20:30:07 +0000 Subject: [PATCH] - locate project extensions globally in resources folder git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8752 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../j2seproject/ProjectExtensionManager.java | 32 +++++++++++++++---- .../DesktopExeCompositeProvider.java | 2 +- .../desktop/executables/launch4j-targets.xml | 2 +- .../desktop/executables/macapp-targets.xml | 6 ++-- .../applet/LwjglAppletCompositeProvider.java | 2 +- .../gde/lwjgl/applet/lwjgl-applet-targets.xml | 4 +-- 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/j2seproject/ProjectExtensionManager.java b/sdk/jme3-core/src/com/jme3/gde/core/j2seproject/ProjectExtensionManager.java index ac56cac9c..9e8fea565 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/j2seproject/ProjectExtensionManager.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/j2seproject/ProjectExtensionManager.java @@ -40,8 +40,6 @@ import java.io.OutputStreamWriter; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; -import java.util.LinkedList; -import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -72,6 +70,7 @@ public class ProjectExtensionManager { private String[] extensionDependencies; private String antTaskLibrary; private URL zipFile; + private static final String resourcesFolder = "resources"; /** * Allows extending ant based projects @@ -428,17 +427,23 @@ public class ProjectExtensionManager { ZipInputStream str = new ZipInputStream(in); ZipEntry entry; while ((entry = str.getNextEntry()) != null) { + String fileName = resourcesFolder + "/" + extensionName + "/" + entry.getName(); if (entry.isDirectory()) { + //XXX: deleting old (beta) files here FileObject fo = projectRoot.getFileObject(entry.getName()); - if (fo == null) { - FileUtil.createFolder(projectRoot, entry.getName()); + if (fo != null && entry.getSize() != -1 && entry.getSize() == fo.getSize()) { + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Deleting old folder " + fo.getNameExt()); + fo.delete(); } + FileUtil.createFolder(projectRoot, fileName); } else { + //XXX: deleting old (beta) files here FileObject fo = projectRoot.getFileObject(entry.getName()); if (fo != null && !fo.equals(projectRoot)) { + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Deleting old file " + fo.getNameExt()); fo.delete(); } - fo = FileUtil.createData(projectRoot, entry.getName()); + fo = FileUtil.createData(projectRoot, fileName); writeFile(str, fo); } } @@ -456,17 +461,32 @@ public class ProjectExtensionManager { ZipInputStream str = new ZipInputStream(in); ZipEntry entry; while ((entry = str.getNextEntry()) != null) { - FileObject obj = projectRoot.getFileObject(entry.getName()); + //XXX: deleting old (beta) files here + FileObject old = projectRoot.getFileObject(entry.getName()); + if (old != null && !old.equals(projectRoot)) { + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Deleting old file " + old.getNameExt()); + if (entry.getSize() != -1 && entry.getSize() == old.getSize()) { + old.delete(); + } + } + String fileName = resourcesFolder + "/" + extensionName + "/" + entry.getName(); + FileObject obj = projectRoot.getFileObject(fileName); if (obj != null && !obj.equals(projectRoot)) { Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Deleting file " + obj.getNameExt()); if (entry.getSize() != -1 && entry.getSize() == obj.getSize()) { obj.delete(); + } else{ + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Keeping file " + obj.getNameExt()); } } } } finally { in.close(); } + FileObject folder = projectRoot.getFileObject(resourcesFolder + "/" + extensionName); + if (folder != null && folder.getChildren().length == 0) { + folder.delete(); + } } private void writeFile(ZipInputStream str, FileObject fo) throws IOException { diff --git a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/DesktopExeCompositeProvider.java b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/DesktopExeCompositeProvider.java index 50eb92257..07b102b93 100644 --- a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/DesktopExeCompositeProvider.java +++ b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/DesktopExeCompositeProvider.java @@ -65,7 +65,7 @@ public class DesktopExeCompositeProvider implements ProjectCustomizer.CompositeC launch4j = new ProjectExtensionManager("launch4j", "v1.2", new String[]{"jar", "-launch4j-exe"}); launch4j.setAntTaskLibrary("launch4j"); launch4j.setDataZip("nbres:/com/jme3/gde/desktop/executables/winapp-data.zip"); - macapp = new ProjectExtensionManager("macapp", "v1.1", new String[]{"jar", "-mac-app"}); + macapp = new ProjectExtensionManager("macapp", "v1.2", new String[]{"jar", "-mac-app"}); macapp.setDataZip("nbres:/com/jme3/gde/desktop/executables/macapp-data.zip"); linux = new ProjectExtensionManager("linuxlauncher", "v1.1", new String[]{"jar", "-linux-launcher"}); } diff --git a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/launch4j-targets.xml b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/launch4j-targets.xml index 05f313b14..9051454c7 100644 --- a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/launch4j-targets.xml +++ b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/launch4j-targets.xml @@ -2,7 +2,7 @@ Windows EXE Creation - + diff --git a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/macapp-targets.xml b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/macapp-targets.xml index 8d9e7c763..1f55df5a2 100644 --- a/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/macapp-targets.xml +++ b/sdk/jme3-desktop-executables/src/com/jme3/gde/desktop/executables/macapp-targets.xml @@ -8,9 +8,9 @@ - - - + + + diff --git a/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/LwjglAppletCompositeProvider.java b/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/LwjglAppletCompositeProvider.java index 4070c0371..c9c64c94b 100644 --- a/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/LwjglAppletCompositeProvider.java +++ b/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/LwjglAppletCompositeProvider.java @@ -62,7 +62,7 @@ public class LwjglAppletCompositeProvider implements ProjectCustomizer.Composite private class SavePropsListener implements ActionListener { private String extensionName = "lwjglapplet"; - private String extensionVersion = "v0.97"; + private String extensionVersion = "v0.98"; private String[] extensionDependencies = new String[]{"jar", "-lwjgl-applet"}; private ProjectExtensionManager manager = new ProjectExtensionManager(extensionName, extensionVersion, extensionDependencies); private ProjectExtensionProperties properties; diff --git a/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/lwjgl-applet-targets.xml b/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/lwjgl-applet-targets.xml index 8e652e579..7538e54bc 100644 --- a/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/lwjgl-applet-targets.xml +++ b/sdk/jme3-lwjgl-applet/src/com/jme3/gde/lwjgl/applet/lwjgl-applet-targets.xml @@ -17,7 +17,7 @@ - +