You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2011/01/17 18:15:19 UTC

svn commit: r1060000 - in /cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven: deployer/DeployExplodedMojo.java deployer/utils/XMLUtils.java rcl/RCLMojo.java rcl/RwmProperties.java

Author: reinhard
Date: Mon Jan 17 17:15:18 2011
New Revision: 1060000

URL: http://svn.apache.org/viewvc?rev=1060000&view=rev
Log:
remove deprecated 'rcl' goal
cleanup & formatting

Removed:
    cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RCLMojo.java
Modified:
    cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
    cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/XMLUtils.java
    cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java

Modified: cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java?rev=1060000&r1=1059999&r2=1060000&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java (original)
+++ cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java Mon Jan 17 17:15:18 2011
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -20,12 +20,10 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.plugin.MojoFailureException;
 
 /**
- * Create a web application that makes use of Cocoon blocks. In the case of a
- * web application module, (packaging: war) all referenced blocks are added, in
- * the case of block (packaging: jar) additionally a minimal Cocoon environemt
- * is created and it is also possible to reference <i>other</i> locally
- * available blocks and to set custom properties to make development highly
- * dynamic.
+ * Create a web application that makes use of Cocoon blocks. In the case of a web application module, (packaging: war)
+ * all referenced blocks are added, in the case of block (packaging: jar) additionally a minimal Cocoon environemt is
+ * created and it is also possible to reference <i>other</i> locally available blocks and to set custom properties to
+ * make development highly dynamic.
  * 
  * @goal deploy
  * @requiresProject true
@@ -41,5 +39,4 @@ public class DeployExplodedMojo extends 
             throw new MojoExecutionException("This goal requires a project of packaging type 'war'.");
         }
     }
-
 }
\ No newline at end of file

Modified: cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/XMLUtils.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/XMLUtils.java?rev=1060000&r1=1059999&r2=1060000&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/XMLUtils.java (original)
+++ cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/XMLUtils.java Mon Jan 17 17:15:18 2011
@@ -50,6 +50,53 @@ import org.xml.sax.SAXException;
  */
 public class XMLUtils {
 
+    public static Element getChildNode(Element parent, String nodeName) {
+        final List children = getChildNodes(parent, nodeName);
+        if (children.size() > 0) {
+            return (Element) children.get(0);
+        }
+
+        return null;
+    }
+
+    public static List getChildNodes(Element parent, String nodeName) {
+        final List nodes = new ArrayList();
+
+        if (parent != null && nodeName != null) {
+            final NodeList children = parent.getChildNodes();
+            if (children != null) {
+                for (int i = 0; i < children.getLength(); i++) {
+                    if (nodeName.equals(children.item(i).getLocalName())) {
+                        nodes.add(children.item(i));
+                    }
+                }
+            }
+        }
+
+        return nodes;
+    }
+
+    public static String getValue(Element node) {
+        if (node != null) {
+            if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+                return node.getNodeValue();
+            }
+
+            node.normalize();
+            NodeList childs = node.getChildNodes();
+            int i = 0;
+            int length = childs.getLength();
+            while (i < length) {
+                if (childs.item(i).getNodeType() == Node.TEXT_NODE) {
+                    return childs.item(i).getNodeValue().trim();
+                }
+
+                i++;
+            }
+        }
+        return null;
+    }
+
     public static Document parseXml(File file) throws IOException, SAXException {
         InputStream is = null;
         try {
@@ -64,7 +111,6 @@ public class XMLUtils {
                 }
             }
         }
-
     }
 
     public static Document parseXml(InputStream source) throws IOException, SAXException {
@@ -77,9 +123,9 @@ public class XMLUtils {
             // allows to deploy the application offline
             docBuilder.setEntityResolver(new EntityResolver() {
                 public InputSource resolveEntity(String publicId, String systemId) throws SAXException,
-                        java.io.IOException {
+                java.io.IOException {
                     if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd")) {
-                        return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
+                        return new InputSource(this.getClass().getResourceAsStream("web-app_2_3.dtd"));
                     }
                     return null;
                 }
@@ -91,11 +137,22 @@ public class XMLUtils {
         }
     }
 
+    public static void setValue(Element node, String value) {
+        if (node != null) {
+            // remove all children
+            while (node.hasChildNodes()) {
+                node.removeChild(node.getFirstChild());
+            }
+            node.appendChild(node.getOwnerDocument().createTextNode(value));
+        }
+    }
+
     public static void write(Document node, OutputStream out) throws TransformerFactoryConfigurationError, TransformerException {
         final Properties format = new Properties();
         format.put(OutputKeys.METHOD, "xml");
         format.put(OutputKeys.OMIT_XML_DECLARATION, "no");
         format.put(OutputKeys.INDENT, "yes");
+
         if (node.getDoctype() != null) {
             if (node.getDoctype().getPublicId() != null) {
                 format.put(OutputKeys.DOCTYPE_PUBLIC, node.getDoctype().getPublicId());
@@ -104,64 +161,10 @@ public class XMLUtils {
                 format.put(OutputKeys.DOCTYPE_SYSTEM, node.getDoctype().getSystemId());
             }
         }
+
         Transformer transformer;
         transformer = TransformerFactory.newInstance().newTransformer();
         transformer.setOutputProperties(format);
         transformer.transform(new DOMSource(node), new StreamResult(out));
     }
-
-    public static List getChildNodes(Element parent, String nodeName) {
-        final List nodes = new ArrayList();
-        if (parent != null && nodeName != null) {
-            final NodeList children = parent.getChildNodes();
-            if (children != null) {
-                for (int i = 0; i < children.getLength(); i++) {
-                    if (nodeName.equals(children.item(i).getLocalName())) {
-                        nodes.add(children.item(i));
-                    }
-                }
-            }
-        }
-        return nodes;
-    }
-
-    public static Element getChildNode(Element parent, String nodeName) {
-        final List children = getChildNodes(parent, nodeName);
-        if (children.size() > 0) {
-            return (Element) children.get(0);
-        }
-
-        return null;
-    }
-
-    public static String getValue(Element node) {
-        if (node != null) {
-            if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
-                return node.getNodeValue();
-            } else {
-                node.normalize();
-                NodeList childs = node.getChildNodes();
-                int i = 0;
-                int length = childs.getLength();
-                while (i < length) {
-                    if (childs.item(i).getNodeType() == Node.TEXT_NODE) {
-                        return childs.item(i).getNodeValue().trim();
-                    } else {
-                        i++;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    public static void setValue(Element node, String value) {
-        if (node != null) {
-            // remove all children
-            while (node.hasChildNodes()) {
-                node.removeChild(node.getFirstChild());
-            }
-            node.appendChild(node.getOwnerDocument().createTextNode(value));
-        }
-    }
 }
\ No newline at end of file

Modified: cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java?rev=1060000&r1=1059999&r2=1060000&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java (original)
+++ cocoon/trunk/tools/cocoon-maven-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java Mon Jan 17 17:15:18 2011
@@ -32,21 +32,31 @@ public class RwmProperties {
 
     private static final String COB_INF_DIR = "src/main/resources/COB-INF";
     private static final String BLOCK_CONTEXT_URL_PARAM = "/contextPath";
-    private static final String CLASSES_DIR = "%classes-dir"; 
-    private static final String EXCLUDE_LIB = "%exclude-lib"; 
+    private static final String CLASSES_DIR = "%classes-dir";
+    private static final String EXCLUDE_LIB = "%exclude-lib";
     private static final String TARGET_CLASSES_DIR = "target/classes";
-    
+
     private Configuration props;
     private File basedir;
-    
+
     public RwmProperties(File propsFile, File basedir) throws ConfigurationException {
         this.props = new PropertiesConfiguration(propsFile);
         this.basedir = basedir;
     }
-    
+
+    public static String calcRootDir(String path) {
+        // path calculation
+        if(path.endsWith("/")) {
+            path = path.substring(0, path.length() - 1);
+        }
+        path = path.substring(0, path.length() - "target/classes".length());
+        return path;
+    }
+
     public Set getClassesDirs() throws MojoExecutionException {
         Set returnSet = new HashSet();
-        for (Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
+
+        for (Iterator rclIt = this.props.getKeys(); rclIt.hasNext();) {
             String key = (String) rclIt.next();
             if (key.endsWith(CLASSES_DIR)) {
                 String[] values = this.props.getStringArray(key);
@@ -54,20 +64,34 @@ public class RwmProperties {
                     String path = values[i];
                     String url = null;
                     try {
-                        url = getUrlAsString(path);
+                        url = this.getUrlAsString(path);
                     } catch (MalformedURLException e) {
                         throw new MojoExecutionException("Can't create URL to  " + path, e);
                     }
                     returnSet.add(url);
                 }
             }
-        }        
+        }
+
         return returnSet;
     }
-    
+
+    public Properties getCocoonProperties() {
+        Properties cocoonProps = new Properties();
+        for(Iterator rclIt = this.props.getKeys(); rclIt.hasNext();) {
+            String key = (String) rclIt.next();
+            if(key.indexOf(CLASSES_DIR) == -1 &&
+                    key.indexOf(EXCLUDE_LIB) == -1 &&
+                    key.indexOf('/') == -1) {
+                cocoonProps.put(key, this.props.getString(key));
+            }
+        }
+        return cocoonProps;
+    }
+
     public Set getExcludedLibProps() throws MojoExecutionException {
         Set returnSet = new HashSet();
-        for (Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
+        for (Iterator rclIt = this.props.getKeys(); rclIt.hasNext();) {
             String key = (String) rclIt.next();
             if (key.endsWith(EXCLUDE_LIB)) {
                 String[] values = this.props.getStringArray(key);
@@ -75,15 +99,15 @@ public class RwmProperties {
                     returnSet.add(values[i]);
                 }
             }
-        }        
+        }
         return returnSet;
-    }    
-    
+    }
+
     public Properties getSpringProperties() throws MojoExecutionException {
         Properties springProps = new Properties();
-        for(Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
+        for(Iterator rclIt = this.props.getKeys(); rclIt.hasNext();) {
             String key = (String) rclIt.next();
-            
+
             // a [block-id]/COB-INF property was set explicitly
             if(key.endsWith(BLOCK_CONTEXT_URL_PARAM)) {
                 String path = null;
@@ -91,10 +115,10 @@ public class RwmProperties {
                     path = this.getUrlAsString(this.props.getString(key));
                 } catch (MalformedURLException e) {
                     throw new MojoExecutionException("Can't create URL to  " + path, e);
-                }            
+                }
                 springProps.put(key, path);
             }
-            
+
             // a %CLASSES_DIR property --> generate a */COB-INF property out of it
             else if(key.endsWith(CLASSES_DIR) && !CLASSES_DIR.equals(key)) {
                 String path = null;
@@ -102,54 +126,32 @@ public class RwmProperties {
                     path = this.getUrlAsString(this.props.getString(key));
                 } catch (MalformedURLException e) {
                     throw new MojoExecutionException("Can't create URL to  " + this.props.getString(key), e);
-                }  
-                
+                }
+
                 if(path.endsWith(TARGET_CLASSES_DIR)) {
                     path = path + "/";
                 }
-                
+
                 if(!path.endsWith(TARGET_CLASSES_DIR + "/")) {
-                    throw new MojoExecutionException("A */" + CLASSES_DIR + 
+                    throw new MojoExecutionException("A */" + CLASSES_DIR +
                             " property can only point to a directory that ends with " + TARGET_CLASSES_DIR + ".");
                 }
-                
+
                 path = calcRootDir(path);
-                
-                String newKey = key.substring(0, key.length() - CLASSES_DIR.length()) + BLOCK_CONTEXT_URL_PARAM;                
+
+                String newKey = key.substring(0, key.length() - CLASSES_DIR.length()) + BLOCK_CONTEXT_URL_PARAM;
                 springProps.put(newKey, path + COB_INF_DIR);
             }
-            
+
             // copy all other properties
             else if(!key.endsWith(CLASSES_DIR) && key.indexOf('/') > -1) {
                 springProps.put(key, this.props.getString(key));
             }
-            
-        } 
-        return springProps;
-    }
 
-    public static String calcRootDir(String path) {
-        // path calculation
-        if(path.endsWith("/")) {
-            path = path.substring(0, path.length() - 1);
         }
-        path = path.substring(0, path.length() - "target/classes".length());
-        return path;
-    }    
-
-    public Properties getCocoonProperties() {
-        Properties cocoonProps = new Properties();
-        for(Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
-            String key = (String) rclIt.next();
-            if(key.indexOf(CLASSES_DIR) == -1 &&
-                    key.indexOf(EXCLUDE_LIB) == -1 &&
-                    key.indexOf('/') == -1) {
-                cocoonProps.put(key, this.props.getString(key));
-            }
-        }
-        return cocoonProps;
+        return springProps;
     }
-    
+
     private String getUrlAsString(String path) throws MalformedURLException {
         // find out if the path is relative or absolute
         boolean absolute = false;
@@ -164,5 +166,5 @@ public class RwmProperties {
         }
         return p.toURI().toASCIIString();
     }
-    
-}    
\ No newline at end of file
+
+}