You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/12/30 21:35:17 UTC

[maven-ejb-plugin] branch master updated: [MEJB-130] Accept ejbVersion 4.x (#11)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 59773cd  [MEJB-130] Accept ejbVersion 4.x (#11)
59773cd is described below

commit 59773cd78f3bffccc19a33db80be6ec95347c551
Author: Piotrek Żygieło <11...@users.noreply.github.com>
AuthorDate: Wed Dec 30 22:35:11 2020 +0100

    [MEJB-130] Accept ejbVersion 4.x (#11)
    
    * IT for EJB 4
    
    * Synchronize comment with code
    
    * Accept ejb version 4
    
    * Fix CS:LineLength
    
    * Extract ejb version validation method
    
    * UTs for ejbVersion validation
    
    * Remove IT
    
    Co-authored-by: Piotrek Żygieło <pz...@users.noreply.github.com>
---
 .../java/org/apache/maven/plugins/ejb/EjbMojo.java | 16 ++++++++----
 .../org/apache/maven/plugins/ejb/EjbMojoTest.java  | 30 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
index 205f937..6ac6cf4 100644
--- a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
@@ -194,8 +194,8 @@ public class EjbMojo
     private JarArchiver jarArchiver;
 
     /**
-     * What EJB version should the EJB Plugin generate? Valid values are "2.x" or "3.x" (where x is a digit). When
-     * ejbVersion is "3.x", the <code>ejb-jar.xml</code> file is optional.
+     * What EJB version should the EJB Plugin generate? Valid values are "2.x", "3.x" or "4.x" (where x is a digit).
+     * When ejbVersion is "2.x", the <code>ejb-jar.xml</code> file is mandatory.
      * <p/>
      * Usage:
      * 
@@ -462,14 +462,20 @@ public class EjbMojo
         return clientJarFile;
     }
 
-    private void checkEJBVersionCompliance( File deploymentDescriptor )
+    static void validateEjbVersion( String ejbVersion )
         throws MojoExecutionException
     {
-        if ( !ejbVersion.matches( "\\A[2-3]\\.[0-9]\\z" ) )
+        if ( !ejbVersion.matches( "\\A[2-4]\\.[0-9]\\z" ) )
         {
             throw new MojoExecutionException( "ejbVersion is not valid: " + ejbVersion
-                + ". Must be 2.x or 3.x (where x is a digit)" );
+                + ". Must be 2.x, 3.x or 4.x (where x is a digit)" );
         }
+    }
+
+    private void checkEJBVersionCompliance( File deploymentDescriptor )
+        throws MojoExecutionException
+    {
+        validateEjbVersion( ejbVersion );
 
         if ( ejbVersion.matches( "\\A2\\.[0-9]\\z" ) && !deploymentDescriptor.exists() )
         {
diff --git a/src/test/java/org/apache/maven/plugins/ejb/EjbMojoTest.java b/src/test/java/org/apache/maven/plugins/ejb/EjbMojoTest.java
index 89e6c70..c6225be 100644
--- a/src/test/java/org/apache/maven/plugins/ejb/EjbMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/ejb/EjbMojoTest.java
@@ -513,6 +513,36 @@ public class EjbMojoTest
         assertJarCreation( project, true, false );
     }
 
+    public void testEjb1VersionValidation()
+    {
+        try
+        {
+            EjbMojo.validateEjbVersion( "1.1" );
+            fail( "MojoException is expected" );
+        }
+        catch ( MojoExecutionException mex )
+        {
+        }
+    }
+
+    public void testEjb2VersionValidation()
+        throws MojoExecutionException
+    {
+        EjbMojo.validateEjbVersion( "2.1" );
+    }
+
+    public void testEjb3VersionValidation()
+        throws MojoExecutionException
+    {
+        EjbMojo.validateEjbVersion( "3.2" );
+    }
+
+    public void testEjb4VersionValidation()
+        throws MojoExecutionException
+    {
+        EjbMojo.validateEjbVersion( "4.0" );
+    }
+
     protected EjbMojo lookupMojo()
         throws Exception
     {