cziegeler 2004/05/01 09:31:15
Modified: tools/targets docs-build.xml webapp-build.xml
tools/src/anttasks SitemapTask.java
Log:
Using cache: source directory is only scanned once per build
Revision Changes Path
1.10 +1 -5 cocoon-2.1/tools/targets/docs-build.xml
Index: docs-build.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/tools/targets/docs-build.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- docs-build.xml 30 Apr 2004 07:20:36 -0000 1.9
+++ docs-build.xml 1 May 2004 16:31:15 -0000 1.10
@@ -50,11 +50,7 @@
tofile="${build.context}/xdocs/status.xml" filtering="on"/>
<!-- generate sitemap components docs -->
- <sitemap-components docDir="${build.context}/xdocs/userdocs">
- <fileset dir="${java}">
- <include name="**/*.java"/>
- </fileset>
- </sitemap-components>
+ <sitemap-components docDir="${build.context}/xdocs/userdocs"
source="${java}"/>
<!-- Forrest needs its own file at src/documentation/sitemap.xmap, so we
overwrite it with the old Cocoon-specific sitemap here -->
1.17 +1 -5 cocoon-2.1/tools/targets/webapp-build.xml
Index: webapp-build.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/tools/targets/webapp-build.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- webapp-build.xml 30 Apr 2004 07:20:36 -0000 1.16
+++ webapp-build.xml 1 May 2004 16:31:15 -0000 1.17
@@ -29,11 +29,7 @@
<copy file="${webapp}/sitemap.xmap"
tofile="${build.webapp}/sitemap.xmap"/>
<!-- generate sitemap entries -->
- <sitemap-components sitemap="${build.webapp}/sitemap.xmap">
- <fileset dir="${java}">
- <include name="**/*.java"/>
- </fileset>
- </sitemap-components>
+ <sitemap-components sitemap="${build.webapp}/sitemap.xmap"
source="${java}"/>
<copy todir="${build.webapp}/stylesheets" filtering="on">
<fileset dir="${webapp}/stylesheets">
1.4 +35 -4 cocoon-2.1/tools/src/anttasks/SitemapTask.java
Index: SitemapTask.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/SitemapTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SitemapTask.java 1 May 2004 16:12:05 -0000 1.3
+++ SitemapTask.java 1 May 2004 16:31:15 -0000 1.4
@@ -19,11 +19,14 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FileSet;
import org.apache.xpath.XPathAPI;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -69,6 +72,27 @@
/** The doc dir */
private File docDir;
+ /** Cache for classes */
+ private static Map cache = new HashMap();
+
+ /** The directory */
+ private String directory;
+
+ public void setSource(File dir) {
+ try {
+ this.directory = dir.toURL().toExternalForm();
+ if ( !dir.isDirectory() ) {
+ throw new BuildException("Source is not a directory.");
+ }
+ } catch (IOException ioe) {
+ throw new BuildException(ioe);
+ }
+ FileSet set = new FileSet();
+ set.setDir(dir);
+ set.setIncludes("**/*.java");
+ super.addFileset(set);
+ }
+
public void setSitemap( final File sitemap ) {
this.sitemap = sitemap;
}
@@ -87,12 +111,16 @@
validate();
- // this does the hard work :)
- super.execute();
+ List components = (List)cache.get(this.directory);
+ if ( components == null ) {
+ // this does the hard work :)
+ super.execute();
+ components = this.collectInfo();
+ cache.put(this.directory, components);
+ }
try {
- final List components = this.collectInfo();
if ( this.sitemap != null ) {
this.processSitemap(components);
}
@@ -111,6 +139,9 @@
* Validate that the parameters are valid.
*/
private void validate() {
+ if ( this.directory == null ) {
+ throw new BuildException("Source is not specified.");
+ }
if ( this.sitemap == null && this.docDir == null ) {
throw new BuildException("Sitemap or DocDir is not specified.");
}