Adds option to build library for Tomcat7 or Glassfish/JBoss
authorNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 27 Jun 2013 20:32:18 +0000 (16:32 -0400)
committerNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 27 Jun 2013 20:32:18 +0000 (16:32 -0400)
... attempts to avoid the need for Git branches for the different versions,
    adds different beans.xml and web.xml files and different profiles in the
    pom.

pom.xml
src/main/resources/as/beans.xml [new file with mode: 0644]
src/main/resources/tomcat/beans.xml [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index d93927a..29e9467 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
       <scope>provided</scope>
     </dependency>
 
-    <!-- JSF 2 -->
+    <!-- JSF 2, JSP tag library, Weld, CDI -->
     <dependency>
       <groupId>org.glassfish</groupId>
       <artifactId>javax.faces</artifactId>
       <groupId>javax.servlet.jsp.jstl</groupId>
       <artifactId>javax.servlet.jsp.jstl-api</artifactId>
       <version>1.2.1</version>      
-    </dependency>
-    <!-- Weld, Dependency Injection (CDI) -->
+    </dependency>    
     <dependency>
       <groupId>org.jboss.weld.servlet</groupId>
       <artifactId>weld-servlet</artifactId>
       <version>1.1.10.Final</version>      
-    </dependency>    
-    <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpclient</artifactId>
-      <version>4.2.3</version>
-    </dependency>
-    <!-- File upload -->
+    </dependency> 
+
+    <!-- File upload etc -->
     <dependency>
       <groupId>org.apache.myfaces.tomahawk</groupId>
       <artifactId>tomahawk20</artifactId>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>2.1</version>
-    </dependency>    
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.2.3</version>
+    </dependency>
+     
+    <!-- Pazpar2 client -->   
     <dependency>
       <groupId>com.indexdata</groupId>
       <artifactId>masterkey-common</artifactId>
@@ -63,6 +65,7 @@
         <excludes>          
           <exclude>main/</exclude>
           <exclude>*.java</exclude>
+          <exclude>META-INF/beans.xml</exclude>
         </excludes>
       </resource>
     </resources>
           <localCheckout>true</localCheckout>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.2</version>
+        <configuration>
+          <classifier>${env}</classifier>
+        </configuration>
+      </plugin>
+      
     </plugins>
     <extensions>
       <extension>
   </scm>
   
   <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <env></env>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    
   </properties>
   
+  <profiles>
+    <profile>
+      <!-- Tomcat 7 profile, includes JSF 2.0 and Weld -->
+      <id>default</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <env></env>
+      </properties>
+      <dependencies>
+      </dependencies>
+      <build>
+        <resources>
+          <resource>
+            <targetPath>META-INF</targetPath>
+            <directory>src/main/resources/tomcat</directory>
+            <includes>
+              <include>beans.xml</include>
+            </includes>
+          </resource>
+        </resources>
+      </build>
+    </profile>
+    <profile>
+      <!-- J2EE Application Server profile (Glassfish, JBoss) -->
+      <!-- beans.xml contains information of which configuration 
+           scheme to inject. Optimally this would be decided at 
+           the .war/application level, not at (this) jar/library
+           level, but for now this is necessary when using Glassfish
+           or JBoss -->
+      <id>as</id>
+      <properties>
+        <env>as</env>
+      </properties>
+      <dependencies>
+      </dependencies>
+      <build>
+        <resources>
+          <resource>
+            <targetPath>META-INF</targetPath>
+            <directory>src/main/resources/as</directory>
+            <includes>
+              <include>beans.xml</include>
+            </includes>
+          </resource>
+        </resources>
+      </build>      
+    </profile>
+  </profiles>
 </project>
diff --git a/src/main/resources/as/beans.xml b/src/main/resources/as/beans.xml
new file mode 100644 (file)
index 0000000..c616832
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="
+      http://java.sun.com/xml/ns/javaee 
+      http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+  <alternatives>         
+    <class>com.indexdata.mkjsf.config.WebXmlConfigReader</class>
+    <!-- Options                      Mk2ConfigReader     -->
+    <!--                              WebXmlConfigReader  -->
+  </alternatives>                
+</beans>
\ No newline at end of file
diff --git a/src/main/resources/tomcat/beans.xml b/src/main/resources/tomcat/beans.xml
new file mode 100644 (file)
index 0000000..b87599c
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="
+      http://java.sun.com/xml/ns/javaee 
+      http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
\ No newline at end of file