You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2006/05/31 20:10:13 UTC

svn commit: r410619 - /maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java

Author: carlos
Date: Wed May 31 11:10:13 2006
New Revision: 410619

URL: http://svn.apache.org/viewvc?rev=410619&view=rev
Log:
[MEJB-6] Make the ejb-jar.xml deployment descriptor optional. Enforce some naming conventions an other minor checks

Modified:
    maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java

Modified: maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java?rev=410619&r1=410618&r2=410619&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java (original)
+++ maven/plugins/trunk/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java Wed May 31 11:10:13 2006
@@ -46,7 +46,7 @@
 
     private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
-    private static final String ejbJarXmlFile = "META-INF/ejb-jar.xml";
+    private static final String EJB_JAR_XML = "META-INF/ejb-jar.xml";
 
     /**
      * The directory for the generated EJB.
@@ -130,17 +130,20 @@
      * @required
      */
     private JarArchiver jarArchiver;
-
+    
     /**
-     * What EJB version should the ejb-plugin generate? ejbVersion can be "2.x" or "3.x"
-     * (where x is a digit), defaulting to "2.1".  When ejbVersion is "3.x", the
+     * <p>
+     * What EJB version should the ejb-plugin generate? ejbVersion can be "2.x" or "3.x" 
+     * (where x is a digit), defaulting to "2.1".  When ejbVersion is "3.x", the 
      * ejb-jar.xml file is optional.
-     *
-     * <br/>Usage:
+     * </p>
+     * 
+     * <p>
+     * Usage:
      * <pre>
      * &lt;ejbVersion&gt;3.0&lt;&#47;ejbVersion&gt;
      * </pre>
-     * @parameter expression="2.1"
+     * @parameter default-value="2.1"
      * @required
      */
     private String ejbVersion;
@@ -177,7 +180,10 @@
     public void execute()
         throws MojoExecutionException
     {
-        getLog().info( "Building ejb " + jarName + " with ejbVersion " + ejbVersion );
+        if ( getLog().isInfoEnabled() )
+        {
+            getLog().info( "Building ejb " + jarName + " with ejbVersion " + ejbVersion );
+        }
 
         File jarFile = new File( basedir, jarName + ".jar" );
 
@@ -187,25 +193,32 @@
 
         archiver.setOutputFile( jarFile );
 
-        File deploymentDescriptor = new File( outputDirectory, ejbJarXmlFile );
+        File deploymentDescriptor = new File( outputDirectory, EJB_JAR_XML );
 
-        // test EJB version compliance
-        if ( !( ejbVersion.matches( "\\A3\\.[0-9]\\z" ) || deploymentDescriptor.exists() ) )
+        /* test EJB version compliance */
+        if ( !ejbVersion.matches( "\\A[2-3]\\.[0-9]\\z" ) )
         {
-            throw new MojoExecutionException( "Error assembling EJB: META-INF/ejb-jar.xml is required for ejbVersion < 3.0" );
+            throw new MojoExecutionException( "ejbVersion is not valid: " + ejbVersion
+                + ". Must be 2.x or 3.x (where x is a digit)" );
+        }
+
+        if ( ejbVersion.matches( "\\A2\\.[0-9]\\z" ) && !deploymentDescriptor.exists() )
+        {
+            throw new MojoExecutionException( "Error assembling EJB: " + EJB_JAR_XML
+                + " is required for ejbVersion 2.x" );
         }
 
         try
         {
             archiver.getArchiver().addDirectory( new File( outputDirectory ), DEFAULT_INCLUDES,
-                                                 new String[]{ejbJarXmlFile, "**/package.html"} );
+                                                 new String[] { EJB_JAR_XML, "**/package.html" } );
+
 
-            // possibly require ejb-jar.xml
             if ( deploymentDescriptor.exists() )
             {
-                archiver.getArchiver().addFile( deploymentDescriptor, ejbJarXmlFile );
+                archiver.getArchiver().addFile( deploymentDescriptor, EJB_JAR_XML );
             }
-
+            
             // create archive
             archiver.createArchive( project, archive );