Author: reinhard
Date: Thu Oct 28 05:30:30 2004
New Revision: 55833

Added:
   cocoon/whiteboard/block-builder/.classpath
   cocoon/whiteboard/block-builder/.project
   cocoon/whiteboard/block-builder/java/
   cocoon/whiteboard/block-builder/java/org/
   cocoon/whiteboard/block-builder/java/org/apache/
   cocoon/whiteboard/block-builder/java/org/apache/cocoon/
   cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/
   cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Block.java
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Cocoon.java
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Descriptor.java
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/EclipseClasspathBuilderTask.java
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Library.java
   
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Source.java
   cocoon/whiteboard/block-builder/lib/
   cocoon/whiteboard/block-builder/lib/ant.jar   (contents, props changed)
   cocoon/whiteboard/block-builder/lib/xercesImpl.jar   (contents, props 
changed)
   cocoon/whiteboard/block-builder/lib/xml-apis.jar   (contents, props changed)
   cocoon/whiteboard/block-builder/targets/
   cocoon/whiteboard/block-builder/targets/block-descriptor2ant-script.xsl
   cocoon/whiteboard/block-builder/targets/eclipse-project.xml
   cocoon/whiteboard/block-builder/targets/global.build.properties
Log:
Proposal for new block building system

Added: cocoon/whiteboard/block-builder/.classpath
==============================================================================
--- (empty file)
+++ cocoon/whiteboard/block-builder/.classpath  Thu Oct 28 05:30:30 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="java"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="lib" path="lib/ant.jar"/>
+       <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
+       <classpathentry kind="lib" path="lib/xml-apis.jar"/>
+       <classpathentry kind="output" path="build/eclipse"/>
+</classpath>

Added: cocoon/whiteboard/block-builder/.project
==============================================================================
--- (empty file)
+++ cocoon/whiteboard/block-builder/.project    Thu Oct 28 05:30:30 2004
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>CocoonBlockBuilder_old</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Block.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Block.java
  Thu Oct 28 05:30:30 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * @since 0.1
+ */
+public class Block {
+    
+    private String name;
+    private String relativeJardir;
+    private String blockPath;
+    private File publicJarFile;
+    
+    public Block() {
+        
+    }
+    
+    public void setName(String name) {
+       this.name = name;
+    }
+
+    public String getName() {
+       return this.name;
+    }
+    
+    public void setPath(String path) {
+       this.blockPath = path;
+    }
+    
+    public void setJardir(String dir) {
+       this.relativeJardir = dir;
+    }
+    
+    public File[] getJarFile(File basedir, final String contains) {
+       File jarDir = new File(basedir, blockPath + File.separator + 
this.relativeJardir);
+        return jarDir.listFiles(new FilenameFilter() {
+            public boolean accept(File f, String name) {
+                return name.toLowerCase().endsWith("jar") && 
name.toLowerCase().indexOf(contains) > -1;
+            }
+        });
+    }
+}

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Cocoon.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Cocoon.java
 Thu Oct 28 05:30:30 2004
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+/**
+ * @since 0.1
+ */
+public class Cocoon {
+    
+    private String jar;
+    
+       /**
+        * @return Returns the dir.
+        */
+       public String getJar() {
+               return jar;
+       }
+       /**
+        * @param dir The dir to set.
+        */
+       public void setJar(String jar) {
+               this.jar = jar;
+       }
+}

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Descriptor.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Descriptor.java
     Thu Oct 28 05:30:30 2004
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+import java.io.File;
+
+/**
+ * @since 0.1
+ */
+public class Descriptor {
+
+    File file;
+    
+    public void setFile(File file) {
+       this.file = file;
+    }
+    
+    public File getFile() {
+       return this.file;
+    }
+}

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/EclipseClasspathBuilderTask.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/EclipseClasspathBuilderTask.java
    Thu Oct 28 05:30:30 2004
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+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.Task;
+import org.apache.xerces.dom.DocumentImpl;
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * @since 0.1
+ */
+public class EclipseClasspathBuilderTask extends Task {
+    
+    private static final String EL_JARS = "jars";
+    private static final String EL_FILE = "file";
+    private static final String ATTR_ID = "id";    
+    private static final String EL_LIB  = "lib";
+    private static final String EL_CLASSPATH = "classpath";
+    private static final String EL_CLASSPATHENTRY = "classpathentry";
+    private static final String ATTR_PATH = "path";
+    private static final String ATTR_KIND = "kind";
+    private static final String ATTR_OUT = "output";    
+    private static final String LIT_ATTR_KIND_SRC = "src";
+    private static final String LIT_ATTR_KIND_CON = "con";
+    private static final String LIT_ATTR_KIND_LIB = "lib";
+    private static final String LIT_ATTR_KIND_OUT = "output";        
+    private static final String CORE_LIB = "core";
+    private static final String DEFAULT_ECLIPSE_CONTAINER = 
"org.eclipse.jdt.launching.JRE_CONTAINER";
+    
+    private List blocks = new ArrayList();
+    private Map coreJarMap = new HashMap();
+       private List coreLibs = new ArrayList();
+       private List sources = new ArrayList();
+    private List cocoonJars = new ArrayList();
+    private File corejarsFile;
+    private File outFile;
+    private File coreJarDir;
+    private String eclipseContainer = DEFAULT_ECLIPSE_CONTAINER;
+
+
+       public void execute() throws BuildException {
+        try {
+            
+            // create a new document
+            Document doc= new DocumentImpl();
+            Element root = doc.createElement(EL_CLASSPATH);
+            
+            // append all source directories
+            Iterator sourceIterator = this.sources.iterator();
+            while(sourceIterator.hasNext()) {
+                Source source = ((Source) sourceIterator.next());
+                Element entry = doc.createElement(EL_CLASSPATHENTRY);
+                entry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_SRC);
+                entry.setAttribute(ATTR_PATH, source.getDir());
+                entry.setAttribute(ATTR_OUT, source.getOut());                
+                root.appendChild(entry);               
+            }
+            
+            // append cocoon libraries
+            Iterator cocoonIterator = this.cocoonJars.iterator();
+            while(cocoonIterator.hasNext()) {
+                Cocoon cocoonEntry = (Cocoon) cocoonIterator.next();
+               File jar = new File(this.getProject().getBaseDir(), 
cocoonEntry.getJar());
+                Element entry = doc.createElement(EL_CLASSPATHENTRY);
+                entry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_LIB);
+                entry.setAttribute(ATTR_PATH, jar.getCanonicalPath());
+                root.appendChild(entry);                
+            }
+               
+            // append all public block jars
+               Iterator blockIterator = this.blocks.iterator();
+            while(blockIterator.hasNext()) {
+               File[] f = 
((Block)blockIterator.next()).getJarFile(this.getProject().getBaseDir(), 
"public");
+                if(f!=null) for(int i = 0; i < f.length; i++) {
+                    Element entry = doc.createElement(EL_CLASSPATHENTRY);
+                    entry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_LIB);
+                    entry.setAttribute(ATTR_PATH, f[i].getCanonicalPath());
+                    root.appendChild(entry);
+                }
+            }
+            
+            // append all libraries
+            Iterator libIterator = this.coreLibs.iterator();
+            while(libIterator.hasNext()) {
+                Library lib = (Library) libIterator.next();
+                if(CORE_LIB.equals(lib.getLocation())) {
+                    String jar = (new File(this.coreJarDir, (String) 
this.coreJarMap.get(lib.getId()))).getCanonicalPath();
+                    Element entry = doc.createElement(EL_CLASSPATHENTRY);
+                    entry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_LIB);
+                    entry.setAttribute(ATTR_PATH, jar);
+                    root.appendChild(entry);              
+                }
+            }
+            
+            // append default output dir
+            Element outputEntry = doc.createElement(EL_CLASSPATHENTRY);
+            outputEntry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_OUT);
+            outputEntry.setAttribute(ATTR_PATH, "");
+            root.appendChild(outputEntry);               
+            
+            // append container
+            Element containerEntry = doc.createElement(EL_CLASSPATHENTRY);
+            containerEntry.setAttribute(ATTR_KIND, LIT_ATTR_KIND_CON);
+            containerEntry.setAttribute(ATTR_PATH, this.eclipseContainer);
+            root.appendChild(containerEntry);    
+                        
+            // append root element to document
+            doc.appendChild(root);
+            
+            // serialize document
+            FileOutputStream fos = new FileOutputStream(outFile);
+            OutputFormat of = new OutputFormat("XML","UTF-8",true);
+            of.setIndent(1);
+            of.setIndenting(true);
+            XMLSerializer serializer = new XMLSerializer(fos,of);
+
+            serializer.asDOMSerializer();
+            serializer.serialize( doc.getDocumentElement() );
+            fos.close();    
+            this.log("Wrote Eclipse .classpath file sucessfully.");
+            
+        } catch(Exception ex) {
+               throw new BuildException("error while serializing dom tree: " + 
ex.getMessage() + ex.getStackTrace());
+        }
+        
+    }
+    
+    
+    private void parse(File file) throws Exception {
+       DOMParser parser = new DOMParser();
+        parser.parse(new InputSource(new FileInputStream(file)));
+        Document doc = parser.getDocument();
+        
+        // read in all available libraries
+        NodeList rootNodeList = doc.getChildNodes();
+        for(int i = 0; i <= rootNodeList.getLength(); i++ ) {
+            Node rootChildNode = rootNodeList.item(i);
+            if(rootChildNode != null && 
EL_JARS.equals(rootChildNode.getLocalName())) {
+               NodeList jarsNodeList = rootChildNode.getChildNodes();
+                for(int x = 0; x <= jarsNodeList.getLength(); x++) {
+                    Node fileNode = jarsNodeList.item(x);
+                    if(fileNode != null && 
EL_FILE.equals(fileNode.getLocalName())) {
+                        addCoreJar(fileNode, this.coreJarMap);
+                    }
+                }
+            }
+        }       
+        
+    }
+    
+       private void addCoreJar(Node fileNode, Map jarMap) {
+        String id = 
fileNode.getAttributes().getNamedItem(ATTR_ID).getNodeValue();
+        NodeList fileNodeList = fileNode.getChildNodes();
+        for(int x = 0; x <= fileNodeList.getLength(); x++) {
+            Node childNode = fileNodeList.item(x);
+            if(childNode != null && EL_LIB.equals(childNode.getLocalName())) {
+                String libValue = childNode.getFirstChild().getNodeValue();
+                jarMap.put(id, libValue);             
+            }
+        }        
+       }
+
+    public void setCorejardir(File dir) {
+       this.coreJarDir = dir;
+    }
+
+       public void setCorejars(File corejars) throws Exception {
+       this.corejarsFile = corejars;
+        parse(this.corejarsFile);
+    }
+    
+    public void setContainer(String container) {
+       this.eclipseContainer = container;
+    }
+    
+    public void setOutfile(File outfile) {
+       this.outFile = outfile;
+    }
+    
+    public void addLib(Library lib) throws BuildException {
+        this.coreLibs.add(lib);
+    }
+    
+    public void addBlock(Block block) {
+       blocks.add(block);
+    }
+    
+    public void addSource(Source source) {
+        sources.add(source);
+    }
+    
+    public void addCocoon(Cocoon cocoon) {
+       this.cocoonJars.add(cocoon);
+    }
+    
+}

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Library.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Library.java
        Thu Oct 28 05:30:30 2004
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+/**
+ * @since 0.1
+ */
+public class Library {
+    
+    private String id;
+    private String location;
+    
+    public void setId(String id) {
+       this.id = id;
+    }
+    
+    public String getId() {
+       return this.id;
+    }
+    
+    public void setLocation(String location) {
+       this.location = location;
+    }
+
+       public String getLocation() {
+               return this.location;
+       }
+
+}

Added: 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Source.java
==============================================================================
--- (empty file)
+++ 
cocoon/whiteboard/block-builder/java/org/apache/cocoon/blockbuilder/ant/Source.java
 Thu Oct 28 05:30:30 2004
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blockbuilder.ant;
+
+/**
+ * @since 0.1
+ */
+public class Source {
+    
+    String dir;
+    String out;
+
+
+       public String getOut() {
+               return out;
+       }
+    
+       public void setOut(String out) {
+               this.out = out;
+       }
+       public String getDir() {
+               return dir;
+       }
+
+       public void setDir(String dir) {
+               this.dir = dir;
+       }
+}

Added: cocoon/whiteboard/block-builder/lib/ant.jar
==============================================================================
Binary file. No diff available.

Added: cocoon/whiteboard/block-builder/lib/xercesImpl.jar
==============================================================================
Binary file. No diff available.

Added: cocoon/whiteboard/block-builder/lib/xml-apis.jar
==============================================================================
Binary file. No diff available.

Added: cocoon/whiteboard/block-builder/targets/block-descriptor2ant-script.xsl
==============================================================================
--- (empty file)
+++ cocoon/whiteboard/block-builder/targets/block-descriptor2ant-script.xsl     
Thu Oct 28 05:30:30 2004
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
+  <xsl:output standalone="yes"/>
+  <xsl:output indent="yes"/>
+  
+  <!-- paths -->
+  <xsl:variable name="blockbuilder.root">${blockbuilder.root}</xsl:variable>
+  <xsl:variable 
name="default.block.output.path">/build/public/classes</xsl:variable>
+  <xsl:variable 
name="default.core.output.path">/build/core/public/classes</xsl:variable>  
+  <xsl:variable 
name="build.public.classes">${build.public.classes}</xsl:variable>
+  <xsl:variable name="build.public">${build.public}</xsl:variable>             
+  <xsl:variable name="src.public">${src.public}</xsl:variable>
+  <xsl:variable name="lib.dir">${lib.dir}</xsl:variable>
+  <xsl:variable name="root.core">${root.core}</xsl:variable>
+  <xsl:variable 
name="path.to.cocoon.public.jar">build/core/cocoon-public.jar</xsl:variable>
+  <xsl:variable name="build.temp.tasks">${build.temp.tasks}</xsl:variable>
+  
+  <!-- compiler -->
+  <xsl:variable name="compiler.debug">${compiler.debug}</xsl:variable>
+  <xsl:variable name="compiler.optimize">${compiler.optimize}</xsl:variable>
+  <xsl:variable 
name="compiler.deprecation">${compiler.deprecation}</xsl:variable>
+  <xsl:variable name="target.vm">${target.vm}</xsl:variable>
+  <xsl:variable name="source.vm">${source.vm}</xsl:variable>
+  <xsl:variable name="compiler.nowarn">${compiler.nowarn}</xsl:variable>
+  <xsl:variable name="compiler">${compiler}</xsl:variable>    
+   
+
+  <!-- conditions -->
+  <xsl:variable name="cond.toplevelcall">${cond.toplevelcall}</xsl:variable>
+  
+  <xsl:template match="block">
+
+    <project default="compile" name="Building block {name}">
+      
+       <target name="init">
+               <!-- read local user properties -->
+               <property file="local.build.properties"/>
+
+               <!-- read global user properties -->
+               <property file="local.block.build.properties"/>
+    
+               <!-- read block default properties -->          
+               <property file="block.build.properties"/>
+               
+               <!-- read global default properties -->
+               <property 
file="{$blockbuilder.root}/targets/global.build.properties"/>                 
+               
+               <!-- if the value toplevelcall is set, unnecessary recursions 
can be avoided -->
+         <xsl:variable name="toplevelcall">${toplevelcall}</xsl:variable>
+        <condition property="cond.toplevelcall">
+          <not><isset property="toplevelcall"/></not>
+        </condition>     
+
+       </target>  
+      
+       <target depends="init" name="compile" 
+         description="Compile this block and all blocks it depends on"  
+         >             
+         
+         <!-- check whether parameters are set, unless stop script execution 
-->
+        <condition property="cond.root.core">
+               <isset property="root.core"/>
+        </condition>    
+        <fail unless="cond.root.core" message="Property root.core has to be 
set."/>
+        <xsl:for-each select="requirements/requires">
+          <xsl:variable name="prop">root.block.<xsl:value-of 
select="@name"/></xsl:variable>
+          <condition property="cond.{$prop}">
+               <isset property="{$prop}"/>
+          </condition>    
+          <fail unless="cond.{$prop}" message="Property {$prop} has to be 
set."/>
+        </xsl:for-each>
+         
+         <!-- first compile all blocks this block depends on -->
+               <antcall target="compile-required-blocks">
+                 <param name="toplevelcall" value="{$cond.toplevelcall}"/>
+               </antcall>
+               
+               <xsl:call-template name="info">
+                 <xsl:with-param name="msg">Compiling block <xsl:value-of 
select="name"/></xsl:with-param>
+               </xsl:call-template>
+               
+               <!-- setup the classpath
+                    for convenience reasons not the exact classpath is built 
but all 
+                    libraries are used -->
+               <path id="classpath">
+                 <xsl:variable name="lib.dir">${lib.dir}</xsl:variable>
+                       <fileset dir="{$lib.dir}">
+                               <include name="core/*.jar"/>
+                               <include name="endorsed/*.jar"/>        
+                               <include name="blocks/*.jar"/>
+                       </fileset>
+                       <xsl:variable 
name="output.core.classes">${root.core}<xsl:value-of 
select="$default.core.output.path"/></xsl:variable>
+                       <dirset dir="{$output.core.classes}"/>
+                       <!-- add classes of blocks this block depends on -->
+                       <xsl:for-each select="requirements/requires">
+                         <xsl:variable 
name="output.block.classes">${root.block.<xsl:value-of 
select="@name"/>}<xsl:value-of 
select="$default.block.output.path"/></xsl:variable>
+                         <dirset dir="{$output.block.classes}"/>
+                       </xsl:for-each>
+               </path>
+               
+               <!-- compile this block -->
+               <mkdir dir="{$build.public.classes}"/>
+        <javac srcdir="{$src.public}"
+               destdir="{$build.public.classes}"
+               debug="{$compiler.debug}"
+               optimize="{$compiler.optimize}"
+               deprecation="{$compiler.deprecation}"
+               target="{$target.vm}"
+               source="{$source.vm}"
+               nowarn="{$compiler.nowarn}"
+               compiler="{$compiler}"
+               classpathref="classpath"/>
+       </target>    
+       
+      <target name="package" depends="init">
+          <!-- here is the root of a small bug: because of recursive calls 
this is also called on 
+               targets that block depends on what's unnecessary but doesn't 
really harm because 
+               the javac task recognizes that nothing has changed and doesn't 
compile again -->
+          <antcall target="compile"/>
+        
+               <antcall target="package-required-blocks">
+                 <param name="toplevelcall" value="{$cond.toplevelcall}"/>
+               </antcall>     
+               
+               <xsl:call-template name="info">
+                 <xsl:with-param name="msg">Packaging block <xsl:value-of 
select="name"/></xsl:with-param>
+               </xsl:call-template>                    
+                  
+          <jar jarfile="{$build.public}/public.jar" index="true">
+            <fileset dir="{$build.public.classes}"/>
+          </jar>               
+      </target>         
+       
+       <target depends="init" name="clean" description="Clean the build 
directory of this block and all blocks it depends on">  
+         <!-- clean all dependand blocks -->
+               <antcall target="clean-required-blocks">
+                 <param name="toplevelcall" value="{$cond.toplevelcall}"/>
+               </antcall>
+               
+               <antcall target="clean-block"/>
+               
+      </target>
+
+       <target depends="init" name="clean-block" description="Clean the build 
directory of this block only">           
+               <xsl:variable name="build.root">${build.root}</xsl:variable>   
+               <xsl:call-template name="info">
+                 <xsl:with-param name="msg">Cleaning block <xsl:value-of 
select="name"/></xsl:with-param>
+               </xsl:call-template>
+               <delete dir="{$build.root}"/>
+      </target>      
+       
+       <xsl:call-template name="multi-block-operation">
+         <xsl:with-param name="action">compile</xsl:with-param>
+       </xsl:call-template>
+
+       <xsl:call-template name="multi-block-operation">
+         <xsl:with-param name="action">package</xsl:with-param>
+       </xsl:call-template>
+
+       <xsl:call-template name="multi-block-operation">
+         <xsl:with-param name="action">clean</xsl:with-param>
+       </xsl:call-template>
+       
+       <target name="compile-eclipse-task" depends="init">
+               <mkdir dir="{$build.temp.tasks}"/>
+        <javac srcdir="{$blockbuilder.root}/java"
+               destdir="{$build.temp.tasks}"
+               debug="{$compiler.debug}"
+               optimize="{$compiler.optimize}"
+               deprecation="{$compiler.deprecation}"
+               target="{$target.vm}"
+               source="{$source.vm}"
+               nowarn="{$compiler.nowarn}"
+               compiler="{$compiler}"
+               classpathref="classpath"/>                
+       </target>
+       
+       <target depends="compile-eclipse-task" name="eclipse-project" 
description="Create Eclipse project files">
+         <antcall target="package"/>
+         
+         <!-- include custom build task that generates the .classpath
+              That is necessary as the library paths are decoupled from block 
descriptor.
+              Using XSLT would require writing an XSLT that creates an XSLT 
that generates an Ant script *grrr* -->
+        <path id="task.classpath">     
+          <pathelement location="{$build.temp.tasks}"/>
+        </path>                
+        <!-- define the task -->
+        <taskdef name="eclipse" 
+          
classname="org.apache.cocoon.blockbuilder.ant.EclipseClasspathBuilderTask"
+               classpathref="task.classpath"/>
+        <!-- calling the task -->
+        <eclipse
+               corejars="{$lib.dir}/jars.xml"
+               corejardir="{$lib.dir}"
+               outfile=".classpath"
+               container="org.eclipse.jdt.launching.JRE_CONTAINER"
+               >
+          <!-- all external libraries - simply copied from descriptor -->
+               <xsl:copy-of select="libraries/*"/>
+               <!-- list all blocks that this block depends on - this creates 
references to
+                    these blocks public jars -->
+               <xsl:for-each select="requirements/requires">
+                 <block name="[EMAIL PROTECTED]" jardir="build/public">
+                   <xsl:attribute name="path">${root.block.<xsl:value-of 
select="@name"/>}</xsl:attribute>
+                 </block>
+               </xsl:for-each>
+               <!-- local soure files -->
+               <source dir="{$src.public}" out="{$build.public.classes}"/>
+          <!-- name the cocoon JARs -->
+               <cocoon jar="{$root.core}/{$path.to.cocoon.public.jar}"/>
+        </eclipse>        
+        <!-- create .project file -->
+        <!-- TBD -->
+           </target>
+    </project>
+  
+  </xsl:template>
+  
+  <xsl:template name="info">
+    <xsl:param name="msg"/>
+    
<echo>+-----------------------------------------------------------------+</echo>
+    <echo>| <xsl:value-of select="$msg"/>                                    
</echo>
+    
<echo>+-----------------------------------------------------------------+</echo>
+  </xsl:template>
+  
+  <!-- create a target for multi-block operations - necessary for recursions 
-->
+  <xsl:template name="multi-block-operation">
+    <xsl:param name="action"/>
+       <target name="{$action}-required-blocks" depends="init, {$action}-core">
+               <xsl:for-each select="requirements/requires">
+                  <xsl:variable name="root.block">${root.block.<xsl:value-of 
select="@name"/>}</xsl:variable>
+                  <ant antfile="{$root.block}/build.xml" target="{$action}" 
inheritall="false">
+                    <property name="toplevelcall" value="false"/>
+                  </ant>
+               </xsl:for-each>             
+           </target>   
+       <target name="{$action}-core" depends="init" if="cond.toplevelcall">
+         <xsl:variable name="root.core">${root.core}</xsl:variable>
+                   <ant antfile="{$root.core}/build.xml" target="{$action}" 
inheritall="false"/>           
+           </target>           
+  </xsl:template>
+  
+</xsl:stylesheet>
\ No newline at end of file

Added: cocoon/whiteboard/block-builder/targets/eclipse-project.xml
==============================================================================
--- (empty file)
+++ cocoon/whiteboard/block-builder/targets/eclipse-project.xml Thu Oct 28 
05:30:30 2004
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<classpath>
+    <classpathentry kind="src" path="java"/>
+    <classpathentry kind="src" path="test"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\blocks\authentication-fw\trunk\build\public\public.jar"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\trunk\lib\core\avalon-framework-api-4.1.5.jar"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\trunk\lib\core\avalon-framework-impl-4.1.5.jar"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\trunk\lib\core\excalibur-xmlutil-1.0.jar"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\trunk\lib\core\excalibur-pool-1.2.jar"/>
+    <classpathentry kind="lib" 
path="F:\os\block-builder\test\trunk\lib\core\excalibur-sourceresolve-1.1.jar"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>

Added: cocoon/whiteboard/block-builder/targets/global.build.properties
==============================================================================
--- (empty file)
+++ cocoon/whiteboard/block-builder/targets/global.build.properties     Thu Oct 
28 05:30:30 2004
@@ -0,0 +1,36 @@
+#  Copyright 1999-2004 The Apache Software Foundation
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+#----------------------------------------------
+#  Build Properties
+#----------------------------------------------
+
+# ---- Build 
-------------------------------------------------------------------
+
+build.root=build
+build.temp=${build.root}/temp
+build.temp.tasks=${build.temp}/tasks
+
+build.public=${build.root}/public
+build.public.classes=${build.public}/classes
+
+# ---- Compiler 
----------------------------------------------------------------
+
+compiler=modern
+compiler.debug=on
+compiler.optimize=on
+compiler.deprecation=off
+compiler.nowarn=on
+source.vm=1.3
+target.vm=1.3
\ No newline at end of file

Reply via email to