View Javadoc

1   package org.codehaus.mojo.jboss.packaging;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.io.IOException;
24  import java.util.Set;
25  
26  import org.apache.maven.plugin.MojoExecutionException;
27  import org.codehaus.plexus.util.FileUtils;
28  
29  /**
30   * Builds a deployable JBoss ESB Archive.
31   * 
32   * @author <a href="mailto:kevin.conner@jboss.com">Kevin Conner</a>
33   * @goal esb
34   * @phase package
35   * @requiresDependencyResolution runtime
36   * @threadSafe
37   */
38  public class ESBMojo
39      extends AbstractPackagingMojo
40  {
41      /**
42       * The name of the meta-inf directory.
43       */
44      private static final String META_INF = "META-INF";
45  
46      /**
47       * The location of the deployment.xml file.
48       */
49      private static final String DEPLOYMENT_XML = "deployment.xml";
50  
51      /**
52       * The artifact type.
53       */
54      private static final String ARTIFACT_TYPE = "jboss-esb";
55  
56      /**
57       * Override the deployment xml file
58       * 
59       * @parameter expression="${maven.esb.deployment.xml}"
60       */
61      private File deploymentXml;
62  
63      /**
64       * The location of the jboss deployment descriptor file (jboss-esb.xml) If it is present in
65       * src/main/resources/META-INF then it will automatically be included. Otherwise this parameter must be set.
66       * 
67       * @parameter default-value="${project.build.outputDirectory}/META-INF/jboss-esb.xml"
68       *            expression="${deploymentDescriptorFile}"
69       */
70      private File deploymentDescriptorFile;
71  
72      /**
73       * Perform any packaging specific to this type.
74       * 
75       * @param excludes The exclude list.
76       * @throws MojoExecutionException For plugin failures.
77       * @throws MojoFailureException For unexpected plugin failures.
78       * @throws IOException For exceptions during IO operations.
79       */
80      protected void buildSpecificPackaging( final Set excludes )
81          throws MojoExecutionException
82      {
83          final File metainfDir = new File( getOutputDirectory(), META_INF );
84          if ( deploymentXml != null )
85          {
86              try
87              {
88                  FileUtils.copyFile( deploymentXml, new File( metainfDir, DEPLOYMENT_XML ) );
89              }
90              catch ( IOException e )
91              {
92                  throw new MojoExecutionException( "Unable to copy deployment file ", e );
93              }
94          }
95      }
96  
97      /**
98       * @return deployment descriptor file name, sans path
99       */
100     public File getDeploymentDescriptor()
101     {
102         return this.deploymentDescriptorFile;
103     }
104 
105     /**
106      * Get the type of the artifact.
107      * 
108      * @return The type of the generated artifact.
109      */
110     public String getArtifactType()
111     {
112         return ARTIFACT_TYPE;
113     }
114 
115 }