KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > jbiplugin > PackageServiceUnitMojo


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: PackageAssemblyMojo.java 16:56:43 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.tools.jbiplugin;
23
24 import java.io.File JavaDoc;
25 import java.io.FileOutputStream JavaDoc;
26 import java.util.zip.ZipOutputStream JavaDoc;
27
28 import org.apache.maven.plugin.MojoExecutionException;
29
30 /**
31  * Make a JBI Archive of a service unit project
32  *
33  * @goal jbi-service-unit
34  * @description Make a JBI Service Unit Archive from a service unit project
35  * @requiresDependencyResolution runtime
36  *
37  * @author cdeneux - Capgemini Sud
38  */

39 public class PackageServiceUnitMojo extends PackageAbstractMojo {
40
41     /**
42      * Execute the plugin
43      */

44     public void execute() throws MojoExecutionException {
45         try {
46             project.getArtifact().setFile(new File JavaDoc(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 JavaDoc(outputDirectory
52                             + File.separator + jbiName + ".zip")
53                             .getAbsolutePath());
54                 }
55                 
56                 new File JavaDoc(outputDirectory
57                     + File.separator + jbiName + ".zip").delete();
58                 
59                 outputDirectory.mkdirs();
60
61                 // Add the jbi files
62
ZipOutputStream JavaDoc zipOutputStream = new ZipOutputStream JavaDoc(
63                     new FileOutputStream JavaDoc(new File JavaDoc(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 JavaDoc e) {
74             e.printStackTrace();
75             throw new MojoExecutionException(e.getLocalizedMessage(), e);
76         }
77     }
78     
79 }
80
Popular Tags