You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2020/06/13 09:24:11 UTC

[maven-war-plugin] branch master updated: [MWAR-45] add an IT testing archiveClasses result

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 45a8201  [MWAR-45] add an IT testing archiveClasses result
45a8201 is described below

commit 45a820192170358c50882665b41e205f2b3855b4
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Jun 13 11:23:44 2020 +0200

    [MWAR-45] add an IT testing archiveClasses result
---
 src/it/archiveClasses/pom.xml                      | 69 +++++++++++++++
 .../main/java/org/apache/maven/it0016/Person.java  | 35 ++++++++
 .../archiveClasses/src/main/webapp/WEB-INF/web.xml | 23 +++++
 src/it/archiveClasses/src/main/webapp/index.html   | 23 +++++
 src/it/archiveClasses/verify.bsh                   | 99 ++++++++++++++++++++++
 5 files changed, 249 insertions(+)

diff --git a/src/it/archiveClasses/pom.xml b/src/it/archiveClasses/pom.xml
new file mode 100644
index 0000000..61a6fb3
--- /dev/null
+++ b/src/it/archiveClasses/pom.xml
@@ -0,0 +1,69 @@
+<?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.mwar-45</groupId>
+  <artifactId>maven-it-mwar-45</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+
+  <name>Maven Integration Test :: MWAR-45</name> 
+  <description>Test a WAR generation with archiveClasses=true</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.4</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>
+        <configuration>
+          <archiveClasses>true</archiveClasses>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/archiveClasses/src/main/java/org/apache/maven/it0016/Person.java b/src/it/archiveClasses/src/main/java/org/apache/maven/it0016/Person.java
new file mode 100644
index 0000000..4a287e7
--- /dev/null
+++ b/src/it/archiveClasses/src/main/java/org/apache/maven/it0016/Person.java
@@ -0,0 +1,35 @@
+package org.apache.maven.it0016;
+
+/*
+ * 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.
+ */
+
+public class Person
+{
+    private String name;
+    
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+}
diff --git a/src/it/archiveClasses/src/main/webapp/WEB-INF/web.xml b/src/it/archiveClasses/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..c1af95d
--- /dev/null
+++ b/src/it/archiveClasses/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app >
+</web-app>
diff --git a/src/it/archiveClasses/src/main/webapp/index.html b/src/it/archiveClasses/src/main/webapp/index.html
new file mode 100644
index 0000000..8e81e87
--- /dev/null
+++ b/src/it/archiveClasses/src/main/webapp/index.html
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+<html>
+  <body>
+    Hello World
+  </body>
+</html>
diff --git a/src/it/archiveClasses/verify.bsh b/src/it/archiveClasses/verify.bsh
new file mode 100644
index 0000000..9b3da75
--- /dev/null
+++ b/src/it/archiveClasses/verify.bsh
@@ -0,0 +1,99 @@
+/*
+ * 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-45-1.0" );
+    System.out.println( "Checking for existence of exploded directory " + explodedDir );
+    if ( !explodedDir.isDirectory() )
+    {
+        System.out.println( "FAILURE!" );
+        return false;
+    }
+
+    String[] expectedPaths = {
+            "index.html",
+            "WEB-INF/lib/commons-logging-1.0.3.jar",
+            "WEB-INF/lib/maven-it-mwar-45-1.0.jar",
+    };
+    for ( String path : expectedPaths )
+    {
+        File file = new File( explodedDir, path );
+        System.out.println( "Checking for existence of " + file );
+        if ( !file.exists() )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+
+    String[] unexpectedPaths = {
+            "WEB-INF/classes/org/apache/maven/it0016/Person.class",
+            "WEB-INF/lib/servlet-api-2.4.jar",
+    };
+    for ( String path : unexpectedPaths )
+    {
+        File file = new File( explodedDir, path );
+        System.out.println( "Checking for absence of " + file );
+        if ( file.exists() )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+
+    File warFile = new File( basedir, "target/maven-it-mwar-45-1.0.war" );
+    System.out.println( "Checking for existence of " + warFile );
+    if ( !warFile.isFile() )
+    {
+        System.out.println( "FAILURE!" );
+        return false;
+    }
+
+    JarFile war = new JarFile( warFile );
+
+    String[] includedEntries = {
+        "index.html",
+        "WEB-INF/lib/maven-it-mwar-45-1.0.jar",
+        "WEB-INF/lib/commons-logging-1.0.3.jar",
+    };
+    for ( String included : includedEntries )
+    {
+        System.out.println( "Checking for existence of " + included );
+        if ( war.getEntry( included ) == null )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+
+    war.close();
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;