1 22 package org.objectweb.petals.tools.jbiplugin; 23 24 import java.io.File ; 25 import java.io.FileOutputStream ; 26 import java.util.zip.ZipOutputStream ; 27 28 import org.apache.maven.plugin.MojoExecutionException; 29 30 39 public class PackageServiceUnitMojo extends PackageAbstractMojo { 40 41 44 public void execute() throws MojoExecutionException { 45 try { 46 project.getArtifact().setFile(new File (outputDirectory 47 + File.separator + jbiName + ".zip")); 48 if (jbiDirectory.exists()) { 49 if (verbose) { 50 System.out.println("Start building JBI Service unit archive " 51 + new File (outputDirectory 52 + File.separator + jbiName + ".zip") 53 .getAbsolutePath()); 54 } 55 56 new File (outputDirectory 57 + File.separator + jbiName + ".zip").delete(); 58 59 outputDirectory.mkdirs(); 60 61 ZipOutputStream zipOutputStream = new ZipOutputStream ( 63 new FileOutputStream (new File (outputDirectory 64 + File.separator + jbiName + ".zip"))); 65 recurseDirectory(zipOutputStream, jbiDirectory, ""); 66 zipOutputStream.flush(); 67 68 zipOutputStream.close(); 69 if (verbose) { 70 System.out.println("JBI Service unit archive building done.\n"); 71 } 72 } 73 } catch (Exception e) { 74 e.printStackTrace(); 75 throw new MojoExecutionException(e.getLocalizedMessage(), e); 76 } 77 } 78 79 } 80 | Popular Tags |