1 11 package org.eclipse.update.internal.jarprocessor; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.util.List ; 16 import java.util.Properties ; 17 import java.util.Set ; 18 19 23 public class PackUnpackStep extends PackStep { 24 private Set exclusions = null; 25 26 public PackUnpackStep(Properties options) { 27 super(options); 28 exclusions = Utils.getPackExclusions(options); 29 } 30 31 public PackUnpackStep(Properties options, boolean verbose) { 32 super(options, verbose); 33 exclusions = Utils.getPackExclusions(options); 34 } 35 36 public String recursionEffect(String entryName) { 37 if (canPack() && entryName.endsWith(".jar") && !exclusions.contains(entryName)) { return entryName; 39 } 40 return null; 41 } 42 43 46 public File postProcess(File input, File workingDirectory, List containers) { 47 if (canPack() && packCommand != null && input != null) { 48 Properties inf = Utils.getEclipseInf(input, verbose); 49 if (!shouldPack(input, containers, inf)) 50 return null; 51 File tempFile = new File (workingDirectory, "temp_" + input.getName()); try { 53 String [] tmp = getCommand(input, tempFile, inf, containers); 54 String [] cmd = new String [tmp.length + 1]; 55 cmd[0] = tmp[0]; 56 cmd[1] = "-r"; System.arraycopy(tmp, 1, cmd, 2, tmp.length - 1); 58 59 int result = execute(cmd, verbose); 60 if (result == 0 && tempFile.exists()) { 61 File finalFile = new File (workingDirectory, input.getName()); 62 if (finalFile.exists()) 63 finalFile.delete(); 64 tempFile.renameTo(finalFile); 65 return finalFile; 66 } else if (verbose) { 67 System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); } 69 } catch (IOException e) { 70 if (verbose) 71 e.printStackTrace(); 72 return null; 73 } 74 } 75 return null; 76 } 77 78 81 public File preProcess(File input, File workingDirectory, List containers) { 82 return null; 83 } 84 85 public String getStepName() { 86 return "Repack"; } 88 } 89 | Popular Tags |