cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stev...@outerthought.org
Subject [WIKI-UPDATE] MarcPortier YourCocoonBasedProject XPatchTaskUsage Fri Jun 27 20:00:05 2003
Date Fri, 27 Jun 2003 18:00:06 GMT
Page: http://wiki.cocoondev.org/Wiki.jsp?page=MarcPortier , version: 9 on Fri Jun 27 17:05:47
2003 by MarcPortier

+ Personal Bookmark section for stuff in this Wiki
+ 
+ * [XPatchTaskUsage]
+ 


Page: http://wiki.cocoondev.org/Wiki.jsp?page=YourCocoonBasedProject , version: 5 on Fri Jun
27 17:34:47 2003 by MarcPortier

- build.bat -propertyfile %PROJECT_PROPERTIES% clean webapp -Dbuild.webapp=%PROJECT_WEBAPP%
-Dtools.tasks.dest=%PROJECT_TASKDEFS%
?                                                                                        
 --------------------------------------

+ build.bat -propertyfile %PROJECT_PROPERTIES% clean webapp -Dbuild.webapp=%PROJECT_WEBAPP%
+  -Dtools.tasks.dest=%PROJECT_TASKDEFS%
+ ----
+ !Addendum
+ 
+ I recently automated some more of this in a set of ant-tasks that you can include in your
own project's build.xml.
+ 
+ It defers with the above only in details (and it should work for linux as well)
+ 
+ {{{
+ <!--
+ This Apache Ant build.xml snippet contains targets for helping out 
+ managing the Cocoon dependencies of your project.
+ 
+ Usage: (assuming you use Apache Ant for your projects)
+ 
+ 1) Copy this file to somewhere in your project. 
+    (e.g. to ./src/targets/cocoon-build.xml)
+ 2) Add the following to the top of your project's Ant build.xml script
+    (possibly adjusting the path):
+ 
+   <!DOCTYPE project [
+     <!ENTITY cocoon-targets SYSTEM "file:./src/targets/cocoon-build.xml">
+   ]>
+ 
+ 3) Before the closing '</project>' in your build.xml, add this:
+ 
+   &cocoon-targets;
+ 
+   
+ This is like expanding a macro: it pulls in the contents of this file.
+ All targets in this build file snippet depend upon 
+ the following properties being set
+ 	1. cocoon-dist.home
+ 	     location of src distribution of cocoon to use
+ 	2. cocoon-build.properties
+ 	     property file with specific cocoon build settings
+ 	     (selecting which blocks, samples,...)
+ 	     typically src/cocoon/local.build.properties
+ 	3. cocoon-xconf.dir
+ 	     location where the appropriate patch files can be found
+ 	     typically src/cocoon/xconf
+ 	4. cocoon-tool.dir
+ 	     where cocoon is build inside your project
+ 	     typically this is tools/cocoon
+ 
+ 
+ A minimal build.xml would thus be:
+ 
+ <!DOCTYPE project [
+ <!ENTITY cocoon-targets SYSTEM "file:./cocoon-targets.ent">
+ ]>
+ 
+ <project default="site">
+     <property name="cocoon-dist.home" value="location-to-cocoon-src-dist" />
+     <property name="cocoon-build.properties" value="src/cocoon/local.build.properties"
+ 	<property name="cocoon-xconf.dir" value="src/cocoon/xconf" />
+ 	<property name="cocoon-tool.dir" value="tools/cocoon" />
+ 
+     &cocoon-targets;
+ </project>
+ -->
+ 
+ 
+ 	<!-- sets some essesntial properties for these targets -->	
+     <target name="-cocoon.init">
+ 			<mkdir dir="${cocoon-tool.dir}" />
+ 			<property name="cocoon.webapp" value="${cocoon-tool.dir}/webapp" />
+ 			<property name="cocoon.tasks" value="${cocoon-tool.dir}/taskdefs" />
+ 			<property name="cocoon.lib" value="${cocoon.webapp}/WEB-INF/lib" />    
+ 
+     </target>
+     
+     
+ 
+ 	<!-- checks what kind of OS this is running on -->    
+     <target name="-cocoon.oscheck" >
+     	<condition property="isWindows">
+ 		    <os family="windows" />
+ 		</condition>
+     </target>
+     
+     
+     
+ 	<!-- creates Windows batch files for cocoon dependencies -->
+     <target name="-cocoon.bat" if="isWindows"
+     	    depends="-cocoon.init, -cocoon.oscheck" >
+ 
+         <echo>Building batch files for support on windows OS</echo>
+ 		<property name="shbat" value="bat" />
+ 
+     	<echo file="${cocoon-tool.dir}/getc2.${shbat}"><![CDATA[ 	
+ @echo off	
+ cd %COCOON_HOME%
+ build.bat -propertyfile %PROJECT_PROPERTIES% clean webapp -Dbuild.webapp=%PROJECT_WEBAPP%
+  -Dtools.tasks.dest=%PROJECT_TASKDEFS%
+ ]]></echo>
+ 
+     	<echo file="${cocoon-tool.dir}/runc2.${shbat}"><![CDATA[
+ @echo off
+ set JETTY_WEBAPP=%PROJECT_WEBAPP%
+ cd %COCOON_HOME%
+ cocoon.bat servlet-debug
+ ]]></echo>
+     </target>
+ 
+ 
+ 
+ 	<!-- creates shell scripts for cocoon dependencies -->    
+     <target name="-cocoon.sh" unless="isWindows"
+     	    depends="-cocoon.init, -cocoon.oscheck" >
+ 
+         <echo>Building shell scripts for support on non-windows</echo>
+ 		<property name="shbat" value="sh" />
+ 
+     	<echo file="${cocoon-tool.dir}/getc2.${shbat}"><![CDATA[
+ #!/bin/sh
+ cd $COCOON_HOME
+ build.sh -propertyfile $PROJECT_PROPERTIES clean webapp -Dbuild.webapp=$PROJECT_WEBAPP
+  -Dtools.task.dest=$PROJECT_TASKDEFS    	
+ ]]></echo>
+ 
+     	<echo file="${cocoon-tool.dir}/runc2.${shbat}"><![CDATA[
+ #!/bin/sh
+ export JETTY_WEBAPP=$PROJECT_WEBAPP
+ cd $COCOON_HOME
+ cocoon.sh servlet-debug
+ ]]></echo>
+ 
+     </target>    
+ 
+ 
+ 
+     <!-- creates as needed batch files or shell scripts -->
+     <target name="-cocoon.shbat" depends="-cocoon.bat, -cocoon.sh" />
+ 
+ 
+ 
+ 	<!-- checks if the cocoon dependency is holding what we expect 
+ 		 sets a variable if all is ok -->
+ 	<target name="-cocoon.test" depends="-cocoon.init">
+ 		<condition property="cocoon.ok" value="true">
+ 			<and>
+ 				<available type="dir" file="${cocoon.lib}" />
+ 				<available classname="XConfToolTask" 
+ 				           classpath="${cocoon.tasks}"/>
+ 			</and>
+ 		</condition>
+ 	</target>
+ 
+ 
+ 	
+ 	<!-- fails the build if the cocoon dependency is not met -->
+ 	<target name="-cocoon.check" depends="-cocoon.test" unless="cocoon.ok">
+ 		<fail>No cocoon available. Run 'ant get_cocoon' first.</fail>
+ 	</target>
+ 
+ 
+ 
+ 
+ 	<target name="-cocoon.patch">
+ 		<echo>Patching ${cocoon.patch.target} with 
+ ${cocoon-xconf.dir}/*.${cocoon.patch.src-extension} ...</echo>
+ 		<xpatch 
+ 			file="${cocoon.patch.target}"
+             srcdir="${cocoon-xconf.dir}" 
+             includes="**/*.${cocoon.patch.src-extension}"/>
+     </target>
+ 
+ 
+     <!-- applies the patch files in the ${cocoon-xconf.dir} 
+     	 on the various cocoon conf files -->
+ 	<target name="cocoon.xconf" depends="-cocoon.check">
+ 		<path id="cocoon-tasks.cp">
+ 			<pathelement path="${cocoon.tasks}" />
+ 			<path>
+ 				<fileset dir="${cocoon.lib}">
+ 					<include name="xalan*.jar" />
+ 					<include name="xerces*.jar" />
+ 					<include name="xml*.jar" />
+ 				</fileset>
+ 			</path>
+ 		</path>
+ 
+ 		<taskdef 
+ 		    name="xpatch" 
+ 		    classname="XConfToolTask" 
+ 		    classpathref="cocoon-tasks.cp"/>	
+ 
+ 		<antcall target="-cocoon.patch" >
+ 			<param name="cocoon.patch.target" 
+ 				   value="${cocoon.webapp}/WEB-INF/cocoon.xconf" />
+ 			<param name="cocoon.patch.src-extension" 
+ 				   value="xconf" />
+ 		</antcall>
+ 
+ 		<antcall target="-cocoon.patch" >
+ 			<param name="cocoon.patch.target" 
+ 				   value="${cocoon.webapp}/WEB-INF/logkit.xconf" />
+ 			<param name="cocoon.patch.src-extension" 
+ 				   value="xlog" />
+ 		</antcall>
+ 
+ 		<antcall target="-cocoon.patch" >
+ 			<param name="cocoon.patch.target" 
+ 				   value="${cocoon.webapp}/sitemap.xmap" />
+ 			<param name="cocoon.patch.src-extension" 
+ 				   value="xmap" />
+ 		</antcall>
+ 
+ 		<antcall target="-cocoon.patch" >
+ 			<param name="cocoon.patch.target" 
+ 				   value="${cocoon.webapp}/WEB-INF/web.xml" />
+ 			<param name="cocoon.patch.src-extension" 
+ 				   value="xweb" />
+ 		</antcall>
+ 
+ 	</target>
+ 
+ 
+ 
+     <!-- gets cocoon-webapp into this project -->
+     <target name="cocoon.get" depends="-cocoon.shbat">
+         <exec executable="${cocoon-tool.dir}/getc2.${shbat}" >
+ 	  	    <env key="COCOON_HOME" file="${cocoon-dist.home}" />
+ 	  	    <env key="PROJECT_PROPERTIES" file="${cocoon-build.properties}" />
+ 	  	    <env key="PROJECT_WEBAPP" file="${cocoon.webapp}" />
+ 	  	    <env key="PROJECT_TASKDEFS" file="${cocoon.tasks}" />
+         </exec>
+     </target>
+ 
+ 
+ 
+     <!-- runs cocoon on the built in jetty to test -->
+     <target name="cocoon.run" depends="-cocoon.shbat, -cocoon.check">
+         <exec executable="${cocoon-tool.dir}/runc2.${shbat}" >
+ 	  	    <env key="COCOON_HOME" file="${cocoon-dist.home}" />
+ 	        <env key="PROJECT_WEBAPP" file="${cocoon.webapp}" />
+         </exec>
+     </target>
+ 
+ }}}
+ 
+ 


Page: http://wiki.cocoondev.org/Wiki.jsp?page=XPatchTaskUsage , version: 7 on Fri Jun 27 17:23:39
2003 by MarcPortier

+ 
+ ----
+ !Addendum
+ 
+ About the xpath context for the various expressions -- ([mpo|MarcPortier]) 
+ 
+ - The xpath expressions in the attributes @xpath and @remove start from the context of the
document-root.
+ 
+ - The others (@insert-before, @insert-after, @unless(-path)) start from the context pointed
to by @xpath.
+ 
+ 



Mime
View raw message