1 19 package org.java.plugin.tools.ant; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import java.util.Iterator ; 24 25 import org.apache.tools.ant.BuildException; 26 import org.java.plugin.registry.PluginDescriptor; 27 import org.java.plugin.registry.PluginFragment; 28 import org.java.plugin.tools.PluginArchiver; 29 30 35 public class SingleFilePluginTask extends BaseJpfTask { 36 private File destDir; 37 38 41 public void setDestDir(final File aDestDir) { 42 destDir = aDestDir; 43 } 44 45 48 public void execute() throws BuildException { 49 if (destDir == null) { 50 throw new BuildException("destdir attribute must be set!", getLocation()); 52 } 53 initRegistry(true); 54 log("Creating plug-in files..."); int count = 0; 56 for (Iterator it = getRegistry().getPluginDescriptors().iterator(); 57 it.hasNext(); count++) { 58 PluginDescriptor descr = (PluginDescriptor) it.next(); 59 File destFile = new File (destDir, descr.getId() + "-" + descr.getVersion() + ".zip"); try { 62 PluginArchiver.pack(descr, getPathResolver(), destFile); 63 } catch (IOException ioe) { 64 throw new BuildException("failed building plug-in file " + destFile, ioe, getLocation()); 66 } 67 if (getVerbose()) { 68 log("Created plug-in file " + destFile); } 70 } 71 for (Iterator it = getRegistry().getPluginFragments().iterator(); 72 it.hasNext(); count++) { 73 PluginFragment fragment = (PluginFragment) it.next(); 74 File destFile = new File (destDir, fragment.getId() + "-" + fragment.getVersion() + ".zip"); try { 77 PluginArchiver.pack(fragment, getPathResolver(), destFile); 78 } catch (IOException ioe) { 79 throw new BuildException("failed building plug-in fragment file " + destFile, ioe, getLocation()); 81 } 82 if (getVerbose()) { 83 log("Created plug-in fragment file " + destFile); } 85 } 86 log("... " + count + " plug-in files created"); } 88 } 89 | Popular Tags |