changeset 2026:04da543b538a

Add support for Tomcat 8. Reviewed-by: omajid, jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-September/020943.html PR3176
author Severin Gehwolf <sgehwolf@redhat.com>
date Tue, 20 Sep 2016 10:03:56 +0200
parents 8969efd1f828
children fc1a3e0a8cf4
files web/war/pom.xml web/war/src/main/webapp-tomcat7/META-INF/context.xml web/war/src/main/webapp-tomcat8/META-INF/context.xml web/war/src/main/webapp/META-INF/context.xml
diffstat 4 files changed, 170 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/web/war/pom.xml	Thu Sep 22 11:39:51 2016 -0400
+++ b/web/war/pom.xml	Tue Sep 20 10:03:56 2016 +0200
@@ -50,6 +50,37 @@
 
   <name>Thermostat Web WAR package</name>
 
+  <!-- context.xml config syntax changed from Tomcat 7 to Tomcat 8.
+       See: https://tomcat.apache.org/migration-8.html#Web_application_resources
+       Work around this problem by choosing the correct context.xml file at build
+       time:
+            Default        => tomcat 6, 7 compatible
+            -Dtomcat=8     => tomcat 8 compatible
+   -->
+  <profiles>
+    <profile>
+      <id>tomcat8</id>
+      <activation>
+        <property>
+          <name>tomcat</name>
+          <value>8</value>
+        </property>
+      </activation>
+      <properties>
+        <tomcat-context-xml-dir>src/main/webapp-tomcat8</tomcat-context-xml-dir>
+      </properties>
+    </profile>
+    <profile>
+      <id>tomcat-lower-8</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <tomcat-context-xml-dir>src/main/webapp-tomcat7</tomcat-context-xml-dir>
+      </properties>
+    </profile>
+  </profiles>
+
   <!-- The set of dependencies of the web archive should be
        as minimal as possible. -->
   <dependencies>
@@ -211,6 +242,46 @@
           <skip>true</skip>
         </configuration>
       </plugin>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>move-web-resources</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.directory}/webapp-resources</outputDirectory>
+              <resources>          
+                <resource>
+                  <directory>src/main/webapp</directory>
+                  <!-- web.xml contains properties, which we'd like to have interpolated -->
+                  <filtering>true</filtering>
+                </resource>
+              </resources>              
+            </configuration>            
+          </execution>
+          <execution>
+            <id>move-context-xml</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.directory}/webapp-resources</outputDirectory>
+              <resources>          
+                <resource>
+                  <directory>${tomcat-context-xml-dir}</directory>
+                  <includes>
+                    <include>**/context.xml</include>
+                  </includes>
+                </resource>
+              </resources>              
+            </configuration>            
+          </execution>
+        </executions>
+      </plugin>
 
       <!--
 	   Package the web archive (WAR) as an exploded WAR *and WAR. Downstream
@@ -230,17 +301,8 @@
               <goal>exploded</goal>
             </goals>
             <configuration>
-              <webResources>
-                <resource>
-                  <filtering>true</filtering>
-                  <directory>src/main/webapp</directory>
-                  <includes>
-                    <include>**/web.xml</include>
-                  </includes>
-                </resource>
-              </webResources>
-              <warSourceDirectory>src/main/webapp</warSourceDirectory>
-              <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
+              <warSourceDirectory>${project.build.directory}/webapp-resources</warSourceDirectory>
+              <webXml>${project.build.directory}/webapp-resources/WEB-INF/web.xml</webXml>
               <webappDirectory>${thermostat.web.deploy.dir}</webappDirectory>
             </configuration>
           </execution>
@@ -251,18 +313,8 @@
               <goal>war</goal>
             </goals>
             <configuration>
-              <!-- web.xml contains properties, which we'd like to have interpolated -->
-              <webResources>
-                <resource>
-                  <filtering>true</filtering>
-                  <directory>src/main/webapp</directory>
-                  <includes>
-                    <include>**/web.xml</include>
-                  </includes>
-                </resource>
-              </webResources>
-              <warSourceDirectory>src/main/webapp</warSourceDirectory>
-              <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
+              <warSourceDirectory>${project.build.directory}/webapp-resources</warSourceDirectory>
+              <webXml>${project.build.directory}/webapp-resources/WEB-INF/web.xml</webXml>
               <!-- Required for the embedded servlet endpoint plugin. -->
               <attachClasses>true</attachClasses>
             </configuration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/war/src/main/webapp-tomcat7/META-INF/context.xml	Tue Sep 20 10:03:56 2016 +0200
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2012-2016 Red Hat, Inc.
+
+ This file is part of Thermostat.
+
+ Thermostat is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ Thermostat is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Thermostat; see the file COPYING.  If not see
+ <http://www.gnu.org/licenses/>.
+
+ Linking this code with other modules is making a combined work
+ based on this code.  Thus, the terms and conditions of the GNU
+ General Public License cover the whole combination.
+
+ As a special exception, the copyright holders of this code give
+ you permission to link this code with independent modules to
+ produce an executable, regardless of the license terms of these
+ independent modules, and to copy and distribute the resulting
+ executable under terms of your choice, provided that you also
+ meet, for each linked independent module, the terms and conditions
+ of the license of that module.  An independent module is a module
+ which is not derived from or based on this code.  If you modify
+ this code, you may extend this exception to your version of the
+ library, but you are not obligated to do so.  If you do not wish
+ to do so, delete this exception statement from your version.
+
+-->
+<!-- allow symlinks to /usr/share/java deps in WEB-INF/lib -->
+<Context path="/thermostat" allowLinking="true">
+       <!-- Configures JAAS for Tomcat -->
+       <Realm className="org.apache.catalina.realm.JAASRealm"                 
+               appName="ThermostatJAASLogin"       
+               userClassNames="com.redhat.thermostat.web.server.auth.UserPrincipal"       
+               roleClassNames="com.redhat.thermostat.web.server.auth.WrappedRolePrincipal,
+                               com.redhat.thermostat.web.server.auth.RolePrincipal"/>
+</Context>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/war/src/main/webapp-tomcat8/META-INF/context.xml	Tue Sep 20 10:03:56 2016 +0200
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2012-2016 Red Hat, Inc.
+
+ This file is part of Thermostat.
+
+ Thermostat is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ Thermostat is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Thermostat; see the file COPYING.  If not see
+ <http://www.gnu.org/licenses/>.
+
+ Linking this code with other modules is making a combined work
+ based on this code.  Thus, the terms and conditions of the GNU
+ General Public License cover the whole combination.
+
+ As a special exception, the copyright holders of this code give
+ you permission to link this code with independent modules to
+ produce an executable, regardless of the license terms of these
+ independent modules, and to copy and distribute the resulting
+ executable under terms of your choice, provided that you also
+ meet, for each linked independent module, the terms and conditions
+ of the license of that module.  An independent module is a module
+ which is not derived from or based on this code.  If you modify
+ this code, you may extend this exception to your version of the
+ library, but you are not obligated to do so.  If you do not wish
+ to do so, delete this exception statement from your version.
+
+-->
+<Context path="/thermostat">
+       <!-- allow symlinks to /usr/share/java deps in WEB-INF/lib -->
+       <Resources allowLinking="true"/>
+       <!-- Configures JAAS for Tomcat -->
+       <Realm className="org.apache.catalina.realm.JAASRealm"                 
+               appName="ThermostatJAASLogin"       
+               userClassNames="com.redhat.thermostat.web.server.auth.UserPrincipal"       
+               roleClassNames="com.redhat.thermostat.web.server.auth.WrappedRolePrincipal,
+                               com.redhat.thermostat.web.server.auth.RolePrincipal"/>
+</Context>
--- a/web/war/src/main/webapp/META-INF/context.xml	Thu Sep 22 11:39:51 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright 2012-2016 Red Hat, Inc.
-
- This file is part of Thermostat.
-
- Thermostat is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- Thermostat is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Thermostat; see the file COPYING.  If not see
- <http://www.gnu.org/licenses/>.
-
- Linking this code with other modules is making a combined work
- based on this code.  Thus, the terms and conditions of the GNU
- General Public License cover the whole combination.
-
- As a special exception, the copyright holders of this code give
- you permission to link this code with independent modules to
- produce an executable, regardless of the license terms of these
- independent modules, and to copy and distribute the resulting
- executable under terms of your choice, provided that you also
- meet, for each linked independent module, the terms and conditions
- of the license of that module.  An independent module is a module
- which is not derived from or based on this code.  If you modify
- this code, you may extend this exception to your version of the
- library, but you are not obligated to do so.  If you do not wish
- to do so, delete this exception statement from your version.
-
--->
-<!-- allow symlinks to /usr/share/java deps in WEB-INF/lib -->
-<Context path="/thermostat" allowLinking="true">
-       <!-- Configures JAAS for Tomcat -->
-       <Realm className="org.apache.catalina.realm.JAASRealm"                 
-               appName="ThermostatJAASLogin"       
-               userClassNames="com.redhat.thermostat.web.server.auth.UserPrincipal"       
-               roleClassNames="com.redhat.thermostat.web.server.auth.WrappedRolePrincipal,
-                               com.redhat.thermostat.web.server.auth.RolePrincipal"/>
-</Context>