|
| 1 | +package javaforce.utils; |
| 2 | + |
| 3 | +/** Uninstall Project files. |
| 4 | + * |
| 5 | + * @author pquiring |
| 6 | + */ |
| 7 | + |
| 8 | +import java.io.*; |
| 9 | + |
| 10 | +import javaforce.*; |
| 11 | + |
| 12 | +public class UninstallProject implements ShellProcessListener { |
| 13 | + private BuildTools tools; |
| 14 | + public static void main(String[] args) { |
| 15 | + if (args.length != 1) { |
| 16 | + System.out.println("Usage:UninstallProject build.xml"); |
| 17 | + System.exit(1); |
| 18 | + } |
| 19 | + try { |
| 20 | + new InstallProject().run(args[0]); |
| 21 | + } catch (Exception e) { |
| 22 | + JFLog.log(e); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + public void run(String buildfile) throws Exception { |
| 27 | + tools = new BuildTools(); |
| 28 | + if (!tools.loadXML(buildfile)) throw new Exception("error loading " + buildfile); |
| 29 | + |
| 30 | + String app = tools.getProperty("app"); |
| 31 | + String apptype = tools.getProperty("apptype"); |
| 32 | + |
| 33 | + switch (apptype) { |
| 34 | + case "client": app = app + "-client"; break; |
| 35 | + case "server": app = app + "-server"; break; |
| 36 | + } |
| 37 | + |
| 38 | + //delete /usr/bin/${app} |
| 39 | + new File("/usr/bin/" + app).delete(); |
| 40 | + |
| 41 | + //read files.lst and delete them all |
| 42 | + try { |
| 43 | + File files = new File("files.lst"); |
| 44 | + if (files.exists()) { |
| 45 | + FileInputStream fis = new FileInputStream(files); |
| 46 | + byte[] lst = fis.readAllBytes(); |
| 47 | + String[] lns = new String(lst).replaceAll("\r","").split("\n"); |
| 48 | + for(String ln : lns) { |
| 49 | + if (ln.length() == 0) continue; |
| 50 | + File file = new File(ln); |
| 51 | + if (file.exists()) { |
| 52 | + file.delete(); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } catch (Exception e) { |
| 57 | + JFLog.log(e); |
| 58 | + } |
| 59 | + |
| 60 | + doSubProjects(); |
| 61 | + } |
| 62 | + |
| 63 | + public void shellProcessOutput(String str) { |
| 64 | + System.out.print(str); |
| 65 | + } |
| 66 | + private void doSubProjects() { |
| 67 | + for(int a=2;a<=5;a++) { |
| 68 | + String project = tools.getProperty("project" + a); |
| 69 | + if (project.length() == 0) continue; |
| 70 | + main(new String[] {project + ".xml"}); |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments