* <preGoal> to default it if none is selected |
project.properties: maven.shale.jsf.impl.default=myfaces -project.xml <extend>${maven.shale.jsf.impl.default}-project.xml</extend> project.xml: <extend>${maven.shale.jsf.impl}-project.xml</extend> jsfri-project.xml: <dependencies> on JSF RI myfaces-project.xml <dependencies> on MyFaces On the command line: -Dmaven.shale.jsf.impl = [jsfri | myfaces] Or in build.properties: maven.shale.jsf.impl = [jsfri | myfaces] Or, do not specify maven.shale.jsf.impl and let it default, currently to 'myfaces'
<extends>${maven.shale.jsf.impl}-project.xml</extends>
core-library/maven.xml
<!-- If shale-test.jar isn't in the local repository, fail the build --> <preGoal name="test:compile"> <j:set var="shale.test.jar" value="${maven.repo.local}/shale/jars/shale-test-${pom.currentVersion}.jar"/> <ant:available property="shale.test.jar.available" file="${shale.test.jar}"/> <j:choose> <j:when test="${shale.test.jar.available}"> <ant:echo>Using ${shale.test.jar}</ant:echo> <ant:path id="shale.test.path"> <ant:pathelement path="${shale.test.jar}"/> </ant:path> <maven:addPath id="maven.dependency.classpath" refid="shale.test.path"/> </j:when> <j:otherwise> <fail>The shale-test-${pom.currentVersion}.jar file is not available. Please build the project using maven build-all -Dmaven.test.skip so that all .jar files will be installed into your local repository.</fail> </j:otherwise> </j:choose> </preGoal>
shale/build.properties.sample
#### Maven build properties #### # The location of the JSF api and implementation .jar files #maven.shale.jsf.api.jar=${maven.repo.local}/myfaces/jars/myfaces-jsf-api-1.0.9.jar #maven.shale.jsf.impl.jar=${maven.repo.local}/myfaces/jars/myfaces-impl-1.0.9.jar maven.shale.jsf.api.jar=${maven.repo.local}/jsf/jars/jsf-api-1.1.jar maven.shale.jsf.impl.jar=${maven.repo.local}/jsf/jars/jsf-impl-1.1.jar
shale/maven.xml
<!-- Pick up the choice of JSF implementation from properties --> <goal name="shale-jsf"> <ant:path id="shale.jsf.path"> <ant:pathelement path="${maven.shale.jsf.api.jar}"/> <ant:pathelement path="${maven.shale.jsf.impl.jar}"/> </ant:path> <ant:echo>Using JSF api: ${maven.shale.jsf.api.jar}</ant:echo> <ant:echo>Using JSF impl: ${maven.shale.jsf.impl.jar}</ant:echo> </goal> <!-- Include the correct JSF implementation in the compile classpath --> <preGoal name="java:compile"> <attainGoal name="shale-jsf"/> <maven:addPath id="maven.dependency.classpath" refid="shale.jsf.path"/> </preGoal> <!-- Include the correct JSF implementation in the test classpath --> <preGoal name="test:compile"> <attainGoal name="shale-jsf"/> <maven:addPath id="maven.dependency.classpath" refid="shale.jsf.path"/> </preGoal>
use-cases/maven.xml
<preGoal name="war:war"> <ant:available property="myfaces.present" classname="org.apache.myfaces.config.MyfacesConfig" classpath="${maven.shale.jsf.impl.jar}"/> <j:if test="${myfaces.present}"> <ant:echo>MyFaces JSF Implementation present: ${myfaces.present} </ant:echo> <ant:replace dir="${maven.war.webapp.dir}/WEB-INF" token="MYFACES_BEGIN" value="<!-- MyFaces Listener -->"/> <ant:replace dir="${maven.war.webapp.dir}/WEB-INF" token="MYFACES_END" value=""/> </j:if> <ant:available property="jsfri.present" classname="com.sun.faces.RIConstants" classpath="${maven.shale.jsf.impl.jar}"/> <j:if test="${jsfri.present}"> <ant:echo>JSF Reference Implementation present: ${jsfri.present} </ant:echo> <ant:replace dir="${maven.war.webapp.dir}/WEB-INF" token="MYFACES_BEGIN" value="<!-- MyFaces Listener"/> <ant:replace dir="${maven.war.webapp.dir}/WEB-INF" token="MYFACES_END" value="-->"/> </j:if> <!-- Include the JSF api and implementation in the webapp --> <ant:copy todir="${maven.war.webapp.dir}/WEB-INF/lib/" overwrite="false" file="${maven.shale.jsf.api.jar}"/> <ant:copy todir="${maven.war.webapp.dir}/WEB-INF/lib/" overwrite="false" file="${maven.shale.jsf.impl.jar}"/> <!-- Include source code in the .war file --> <ant:copy todir="${maven.war.webapp.dir}/WEB-INF/src/" overwrite="false"> <ant:fileset dir="${basedir}/src/java" excludes="**/.svn/**"> </ant:fileset> </ant:copy> <!-- Copy the default message bundle to avoid problems if the server locale is not English. --> <ant:copy file="${basedir}/src/java/org/apache/shale/usecases/view/Bundle.properties" tofile="${maven.war.webapp.dir}/WEB-INF/classes/org/apache/shale/usecases/view/Bundle_en.properties"/> </preGoal>