Author: rahul
Date: Wed Dec 27 16:05:28 2006
New Revision: 490608

URL: http://svn.apache.org/viewvc?view=rev&rev=490608
Log:
Allow building shale-test with JDK 1.4 (important as most of framework depends 
on it). With the JSF 1.2 bits coming in place for shale-test, the Java EE 5 
artifacts (JSF 1.2, Servlet 2.5, JSP 2.1 jars) that are pulled in are built 
with JDK 1.5, causing compilation (and thus, build) failures on JDK 1.4 (as 
expected).

Therefore, introduce two profiles in the shale-test pom (correct one gets 
activated automagically based on JDK version in use, so nothing needs to be 
done at the mvn command).

The shale-test-jdk14 profile depends on {myfaces-api-1.1.4,servlet 2.4,JSP 2.0} 
and excludes the sources that use Java EE 5 APIs. Thus, when built on JDK 1.4, 
the shale-test jar caters only to JSF 1.1 users.

The shale-test-jdk15 profile depends on {jsf-1.2_02,servlet 2.5,JSP 2.1} (and 
excludes nothing).

As a side-effect, when using the mock factories with a jar built with JDK 1.4, 
trying to load the JSF 1.2 classes may fail with a ClassNotFoundException 
(since the classes never get built in the first place). Code now accomodates 
for that.

Finally, this does introduce one additional thing to maintain. shale-test 
developers need to keep the exclusions in the 1.4 profile updated to this can 
continue to work beyond v1.0.4 (until we decide to drop JDK 1.4 support).

With this change, 'mvn -Papps install' from framework trunk works for me with 
JDK 1.4.

SHALE-375

Modified:
    shale/framework/trunk/shale-test/pom.xml
    
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockApplicationFactory.java
    
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockFacesContextFactory.java

Modified: shale/framework/trunk/shale-test/pom.xml
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/pom.xml?view=diff&rev=490608&r1=490607&r2=490608
==============================================================================
--- shale/framework/trunk/shale-test/pom.xml (original)
+++ shale/framework/trunk/shale-test/pom.xml Wed Dec 27 16:05:28 2006
@@ -41,27 +41,6 @@
         </dependency>
 
         <dependency>
-            <groupId>javax.faces</groupId>
-            <artifactId>jsf-api</artifactId>
-            <version>1.2_02</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>javax.servlet.jsp</groupId>
-            <artifactId>jsp-api</artifactId>
-            <version>2.1</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
             <groupId>jmock</groupId>
             <artifactId>jmock</artifactId>
             <version>1.0.1</version>
@@ -100,4 +79,81 @@
 
     </dependencies>
 
-</project>
\ No newline at end of file
+    <!-- Allow building with JDK 1.4 as well as JDK 1.5,
+         the 1.4 profile caters only to JSF 1.1 -->
+    <profiles>
+
+        <profile>
+            <id>shale-test-jdk14</id>
+            <activation>
+                <jdk>1.4</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.myfaces.core</groupId>
+                    <artifactId>myfaces-api</artifactId>
+                    <version>1.1.4</version>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>servlet-api</artifactId>
+                    <version>2.4</version>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>jsp-api</artifactId>
+                    <version>2.0</version>
+                    <scope>provided</scope>
+                </dependency>
+            </dependencies>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>
+                            <excludes>
+                                <exclude>org/apache/shale/test/el/**</exclude>
+                                
<exclude>org/apache/shale/test/mock/*12.java</exclude>
+                            </excludes>
+                            <testExcludes>
+                                
<testExclude>org/apache/shale/test/el/**</testExclude>
+                            </testExcludes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>shale-test-jdk15</id>
+            <activation>
+                <jdk>1.5</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>javax.faces</groupId>
+                    <artifactId>jsf-api</artifactId>
+                    <version>1.2_02</version>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>servlet-api</artifactId>
+                    <version>2.5</version>
+                    <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>javax.servlet.jsp</groupId>
+                    <artifactId>jsp-api</artifactId>
+                    <version>2.1</version>
+                    <scope>provided</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+    </profiles>
+
+</project>

Modified: 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockApplicationFactory.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockApplicationFactory.java?view=diff&rev=490608&r1=490607&r2=490608
==============================================================================
--- 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockApplicationFactory.java
 (original)
+++ 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockApplicationFactory.java
 Wed Dec 27 16:05:28 2006
@@ -68,6 +68,8 @@
                 this.application = (MockApplication) clazz.newInstance();
             } catch (NoClassDefFoundError e) {
                 clazz = null; // We are not running in a JSF 1.2 environment
+            } catch (ClassNotFoundException e) {
+                clazz = null; // Same as above
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {

Modified: 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockFacesContextFactory.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockFacesContextFactory.java?view=diff&rev=490608&r1=490607&r2=490608
==============================================================================
--- 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockFacesContextFactory.java
 (original)
+++ 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/mock/MockFacesContextFactory.java
 Wed Dec 27 16:05:28 2006
@@ -56,6 +56,10 @@
             // We are not running on JSF 1.2, so go to our fallback
             clazz = null;
             constructor = null;
+        } catch (ClassNotFoundException e) {
+            // Same as above
+            clazz = null;
+            constructor = null;
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {


Reply via email to