jefft 2003/06/20 23:53:55
Modified: src/targets webapp-build.xml tools/src blocks-build.xsl tools/src/anttasks XConfToolTask.java Log: Surround sitemap.xmap block snippets with comments indicating their origin: <!-- Start configuration from '<block>' --> .... <!-- End configuration from '<block>' --> to make it easier for users to see what's what. Off by default, only switched on for sitemap.xmap Revision Changes Path 1.20 +3 -2 cocoon-2.1/src/targets/webapp-build.xml Index: webapp-build.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/src/targets/webapp-build.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- webapp-build.xml 5 Jun 2003 03:02:45 -0000 1.19 +++ webapp-build.xml 21 Jun 2003 06:53:55 -0000 1.20 @@ -84,7 +84,8 @@ <copy file="${build}/${name}-deprecated.jar" tofile="${build.webapp.lib}/${name}-${version}-deprecated.jar"/> <xpatch file="${build.webapp}/WEB-INF/cocoon.xconf" srcdir="${deprecated.conf}" - includes="**/*.xconf"/> + includes="**/*.xconf" + addComments="true"/> </target> <target name="prepare-webapp-idldocs" depends="idldocs" unless="unless.exclude.webapp.idldocs"> @@ -166,7 +167,7 @@ <include name="${customconf}/*.xmap" /> <include name="${customconf}/*.xpipe" /> </xpatch> - <xpatch file="${build.webapp}/WEB-INF/cocoon.xconf" srcdir=""> + <xpatch file="${build.webapp}/WEB-INF/cocoon.xconf" srcdir="" addComments="true"> <include name="${customconf}/*.xconf" /> </xpatch> <xpatch file="${build.webapp}/WEB-INF/logkit.xconf" srcdir=""> 1.22 +2 -1 cocoon-2.1/tools/src/blocks-build.xsl Index: blocks-build.xsl =================================================================== RCS file: /home/cvs/cocoon-2.1/tools/src/blocks-build.xsl,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- blocks-build.xsl 26 May 2003 08:44:30 -0000 1.21 +++ blocks-build.xsl 21 Jun 2003 06:53:55 -0000 1.22 @@ -77,7 +77,8 @@ <target name="patch-conf" depends="init"> <xpatch file="{string('${build.webapp}')}/sitemap.xmap" - srcdir="{string('${blocks}')}"> + srcdir="{string('${blocks}')}" + addcomments="true"> <xsl:for-each select="project[contains(@name,'cocoon-block-')]"> <xsl:variable name="block-name" select="substring-after(@name,'cocoon-block-')"/> <include name="{$block-name}/conf/**/*.xmap" unless="unless.exclude.block.{$block-name}"/> 1.8 +31 -1 cocoon-2.1/tools/src/anttasks/XConfToolTask.java Index: XConfToolTask.java =================================================================== RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- XConfToolTask.java 5 Jun 2003 21:06:17 -0000 1.7 +++ XConfToolTask.java 21 Jun 2003 06:53:55 -0000 1.8 @@ -93,9 +93,12 @@ */ public final class XConfToolTask extends MatchingTask { + private static final String NL=System.getProperty("line.separator"); + private static final String FSEP=System.getProperty("file.separator"); private File file; private File directory; private File srcdir; + private boolean addComments; /** for resolving entities such as dtds */ private XMLCatalog xmlCatalog = new XMLCatalog(); @@ -128,6 +131,14 @@ } /** + * Whether to add a comment indicating where this block of code comes + * from. + */ + public void setAddComments(Boolean addComments) { + this.addComments = addComments.booleanValue(); + } + + /** * Initialize internal instance of XMLCatalog */ public void init() throws BuildException @@ -227,6 +238,7 @@ Element elem = component.getDocumentElement(); String extension = file.lastIndexOf(".")>0?file.substring(file.lastIndexOf(".")+1):""; + String basename = basename(file); if ( !elem.getTagName().equals(extension)) { log("Skipping non xconf-tool file: "+file); @@ -325,6 +337,10 @@ log("Processing: "+file); NodeList componentNodes = component.getDocumentElement().getChildNodes(); + if (this.addComments) { + root.appendChild(configuration.createComment("..... Start configuration from '"+basename+"' ")); + root.appendChild(configuration.createTextNode(NL)); + } for (int i = 0; i<componentNodes.getLength(); i++) { Node node = configuration.importNode(componentNodes.item(i), true); @@ -335,7 +351,21 @@ root.insertBefore(node, before); } } + if (this.addComments) { + root.appendChild(configuration.createComment("..... End configuration from '"+basename+"' ")); + root.appendChild(configuration.createTextNode(NL)); + } return true; } + } + + /** Returns the file name (excluding directories and extension). */ + private String basename(String file) { + int start = file.lastIndexOf(FSEP)+1; // last '/' + int end = file.lastIndexOf("."); // last '.' + + if (end == 0) end = file.length(); + + return file.substring(start, end); } }