[maven-war-plugin] branch pzygielo-mwar-430 created (now fcb57d5)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-war-plugin] branch pzygielo-mwar-430 created (now fcb57d5)

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

khmarbaise pushed a change to branch pzygielo-mwar-430
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git.


      at fcb57d5  [MWAR-430] Check for Jakarta annotation as well

This branch includes the following new commits:

     new c5c44a6  [MWAR-430] Use MWAR-396_servlet30 as IT for this issue
     new bbb4434  [MWAR-430] Extract method to check for Servlet 3.0+
     new 7e36ebf  [MWAR-430] Extract method to check for class
     new fcb57d5  [MWAR-430] Check for Jakarta annotation as well

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven-war-plugin] 01/04: [MWAR-430] Use MWAR-396_servlet30 as IT for this issue

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

khmarbaise pushed a commit to branch pzygielo-mwar-430
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit c5c44a6cade094b74ebfc5ddc616eea9dcbc26fa
Author: Piotrek Żygieło <[hidden email]>
AuthorDate: Thu Jun 4 18:11:04 2020 +0200

    [MWAR-430] Use MWAR-396_servlet30 as IT for this issue
---
 src/it/MWAR-430_jakarta-servlet/pom.xml    | 66 ++++++++++++++++++++++++++++++
 src/it/MWAR-430_jakarta-servlet/verify.bsh | 49 ++++++++++++++++++++++
 2 files changed, 115 insertions(+)

diff --git a/src/it/MWAR-430_jakarta-servlet/pom.xml b/src/it/MWAR-430_jakarta-servlet/pom.xml
new file mode 100644
index 0000000..8f773b1
--- /dev/null
+++ b/src/it/MWAR-430_jakarta-servlet/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.war</groupId>
+  <artifactId>maven-it-mwar-430</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+
+  <name>Maven Integration Test :: MWAR-430</name>
+  <description>Test that no web.xml is required when project depends on Jakarta Servlet 5.0 or newer</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>jakarta.servlet</groupId>
+      <artifactId>jakarta.servlet-api</artifactId>
+      <version>5.0.0-M1</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.3</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/MWAR-430_jakarta-servlet/verify.bsh b/src/it/MWAR-430_jakarta-servlet/verify.bsh
new file mode 100644
index 0000000..3c7e8b5
--- /dev/null
+++ b/src/it/MWAR-430_jakarta-servlet/verify.bsh
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+try
+{
+    File explodedDir = new File( basedir, "target/maven-it-mwar-430-1.0" );
+    System.out.println( "Checking for existence of exploded directory " + explodedDir );
+    if ( !explodedDir.exists() )
+    {
+        System.out.println( "FAILURE! The directory " + explodedDir + " does not exist." );
+        return false;
+    }
+    
+    File webInfFile = new File( explodedDir, "WEB-INF/web.xml" );
+    if ( webInfFile.exists() )
+    {
+        System.err.println( "FAILURE! The file web.xml should not be present." );
+        return false;
+    }
+
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Reply | Threaded
Open this post in threaded view
|

[maven-war-plugin] 02/04: [MWAR-430] Extract method to check for Servlet 3.0+

khmarbaise
In reply to this post by khmarbaise
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch pzygielo-mwar-430
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit bbb4434922b76e4d7252140e4e03129fc20f6ef2
Author: Piotrek Żygieło <[hidden email]>
AuthorDate: Thu Jun 4 18:11:12 2020 +0200

    [MWAR-430] Extract method to check for Servlet 3.0+
---
 src/main/java/org/apache/maven/plugins/war/WarMojo.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
index 261ef04..7d7ea42 100644
--- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
@@ -321,6 +321,12 @@ public class WarMojo
             urls[i] = new File( classpathElements.get( i ) ).toURI().toURL();
         }
         ClassLoader loader = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() );
+
+        return hasWebServletAnnotationClassInClasspath( loader );
+    }
+
+    private static boolean hasWebServletAnnotationClassInClasspath( ClassLoader loader )
+    {
         try
         {
             Class.forName( "javax.servlet.annotation.WebServlet", false, loader );

Reply | Threaded
Open this post in threaded view
|

[maven-war-plugin] 03/04: [MWAR-430] Extract method to check for class

khmarbaise
In reply to this post by khmarbaise
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch pzygielo-mwar-430
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit 7e36ebf292fc01c2ddd55804cd23f9c2732b3f0d
Author: Piotrek Żygieło <[hidden email]>
AuthorDate: Thu Jun 4 18:11:18 2020 +0200

    [MWAR-430] Extract method to check for class
---
 src/main/java/org/apache/maven/plugins/war/WarMojo.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
index 7d7ea42..e731a39 100644
--- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
@@ -327,9 +327,14 @@ public class WarMojo
 
     private static boolean hasWebServletAnnotationClassInClasspath( ClassLoader loader )
     {
+        return hasClassInClasspath( loader, "javax.servlet.annotation.WebServlet" );
+    }
+
+    private static boolean hasClassInClasspath( ClassLoader loader, String clazz )
+    {
         try
         {
-            Class.forName( "javax.servlet.annotation.WebServlet", false, loader );
+            Class.forName( clazz, false, loader );
             return true;
         }
         catch ( ClassNotFoundException e )

Reply | Threaded
Open this post in threaded view
|

[maven-war-plugin] 04/04: [MWAR-430] Check for Jakarta annotation as well

khmarbaise
In reply to this post by khmarbaise
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch pzygielo-mwar-430
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit fcb57d57d036e2582515cf7487022c276c82cd7c
Author: Piotrek Żygieło <[hidden email]>
AuthorDate: Thu Jun 4 18:18:54 2020 +0200

    [MWAR-430] Check for Jakarta annotation as well
---
 src/main/java/org/apache/maven/plugins/war/WarMojo.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
index e731a39..0df35ef 100644
--- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
@@ -301,13 +301,16 @@ public class WarMojo
     }
 
     /**
-     * Determines if the current Maven project being built uses the Servlet 3.0 API (JSR 315). If it does then the
-     * <code>web.xml</code> file can be omitted.
+     * Determines if the current Maven project being built uses the Servlet 3.0 API (JSR 315)
+     * or Jakarta Servlet API.
+     * If it does then the <code>web.xml</code> file can be omitted.
      * <p>
-     * This is done by checking if the interface <code>javax.servlet.annotation.WebServlet</code> is in the compile-time
+     * This is done by checking if the interface <code>javax.servlet.annotation.WebServlet</code>
+     * or <code>jakarta.servlet.annotation.WebServlet</code> is in the compile-time
      * dependencies (which includes provided dependencies) of the Maven project.
      *
-     * @return <code>true</code> if the project being built depends on Servlet 3.0 API, <code>false</code> otherwise.
+     * @return <code>true</code> if the project being built depends on Servlet 3.0 API or Jakarta Servlet API,
+     *         <code>false</code> otherwise.
      * @throws DependencyResolutionRequiredException if the compile elements can't be resolved.
      * @throws MalformedURLException if the path to a dependency file can't be transformed to a URL.
      */
@@ -327,7 +330,8 @@ public class WarMojo
 
     private static boolean hasWebServletAnnotationClassInClasspath( ClassLoader loader )
     {
-        return hasClassInClasspath( loader, "javax.servlet.annotation.WebServlet" );
+        return hasClassInClasspath( loader, "javax.servlet.annotation.WebServlet" )
+                || hasClassInClasspath( loader, "jakarta.servlet.annotation.WebServlet" );
     }
 
     private static boolean hasClassInClasspath( ClassLoader loader, String clazz )