1 19 package org.java.plugin.tools.ant; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.Task; 26 import org.java.plugin.ObjectFactory; 27 import org.java.plugin.registry.ManifestProcessingException; 28 import org.java.plugin.tools.PluginArchiver; 29 import org.java.plugin.util.IoUtil; 30 31 35 public final class UnpackTask extends Task { 36 private File destDir; 37 private File srcFile; 38 39 42 public void setSrcFile(final File aSrcFile) { 43 this.srcFile = aSrcFile; 44 } 45 46 49 public void setDestDir(final File aDestFolder) { 50 this.destDir = aDestFolder; 51 } 52 53 56 public void execute() { 57 if (srcFile == null) { 58 throw new BuildException("srcfile attribute must be set!", getLocation()); 60 } 61 if (destDir == null) { 62 throw new BuildException("destdir attribute must be set!", getLocation()); 64 } 65 log("Extracting plug-ins from archive..."); try { 67 PluginArchiver.unpack(IoUtil.file2url(srcFile), 68 ObjectFactory.newInstance().createRegistry(), destDir); 69 log("... plug-ins archive unpacked to folder " + destDir); } catch (IOException ioe) { 71 throw new BuildException(ioe); 72 } catch (ManifestProcessingException mpe) { 73 throw new BuildException(mpe); 74 } catch (ClassNotFoundException cnfe) { 75 throw new BuildException(cnfe); 76 } 77 } 78 } 79 | Popular Tags |