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 2006/12/07 11:50:48 UTC

svn commit: r483413 - in /cocoon/trunk/tools/cocoon-rcl: cocoon-rcl-plugin-demo/ cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/

Author: reinhard
Date: Thu Dec  7 02:50:47 2006
New Revision: 483413

URL: http://svn.apache.org/viewvc?view=rev&rev=483413
Log:
invoke the plugin after the 'process-classes' phase; javadocs; support relative paths in the configuration and translate them to absolute paths for the classloader and the spring properties; add a configuration for the demo module that uses a relative path

Added:
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties   (with props)
Modified:
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java
    cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java

Added: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties?view=auto&rev=483413
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties (added)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties Thu Dec  7 02:50:47 2006
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+org.apache.cocoon.cocoon-rcl-plugin-demo.block%classes-dir=./target/classes
\ No newline at end of file

Propchange: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin-demo/rcl.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java?view=diff&rev=483413&r1=483412&r2=483413
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java Thu Dec  7 02:50:47 2006
@@ -58,7 +58,8 @@
  * @goal webapp
  * @requiresProject true
  * @requiresDependencyResolution runtime
- * @phase package
+ * @execute phase="process-classes"
+ * @version $Id$ 
  */
 public class ReloadingWebappMojo extends AbstractMojo {
 
@@ -183,7 +184,7 @@
         createUrlClassLoaderConf(webAppBaseDir, props);   
         
         // create a file that contains the URLs of all classes directories (config for the ReloadingClassLoader)
-        createReloadingClassLoaderconf(webAppBaseDir, props);
+        createReloadingClassLoaderConf(webAppBaseDir, props);
         
         // based on the RCL configuration file, create a Spring properties file
         createSpringProperties(webAppBaseDir, props);
@@ -200,13 +201,13 @@
         return props;
     }
 
-    protected void createReloadingClassLoaderconf(File webAppBaseDir, RwmProperties props) throws MojoExecutionException {
+    protected void createReloadingClassLoaderConf(File webAppBaseDir, RwmProperties props) throws MojoExecutionException {
         File urlClConfFile = createPath(new File(webAppBaseDir, WEB_INF_RCLWRAPPER_RCL_CONF));
         try {
             FileWriter fw = new FileWriter(urlClConfFile);
             for(Iterator aIt = props.getClassesDirs().iterator(); aIt.hasNext();) {
                 String dir = (String) aIt.next();
-                fw.write(dir + "\n");            
+                fw.write(new File(dir).getCanonicalPath() + "\n");            
                 this.getLog().debug("Adding classes-dir to RCLClassLoader configuration: " + dir);
             }
             fw.close();
@@ -373,4 +374,4 @@
         }    
     }
     
-}
+}
\ No newline at end of file

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java?view=diff&rev=483413&r1=483412&r2=483413
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java Thu Dec  7 02:50:47 2006
@@ -20,11 +20,14 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.maven.plugin.MojoExecutionException;
+
 public class RwmProperties {
 
     private static final String COB_INF_DIR = "/COB-INF";
@@ -50,7 +53,7 @@
         return getFilteredPropertiesValuesAsSet(CLASSES_DIR);
     }
     
-    public Properties getSpringProperties() {
+    public Properties getSpringProperties() throws MojoExecutionException {
         Properties springProps = new Properties();
         for(Enumeration rclEnum = rclProps.keys(); rclEnum.hasMoreElements();) {
             String key = (String) rclEnum.nextElement();
@@ -59,7 +62,12 @@
             }
             if(key.endsWith(CLASSES_DIR)) {
                 String newKey = key.substring(0, key.length() - CLASSES_DIR.length()) + BLOCK_CONTEXT_URL_PARAM;
-                springProps.put(newKey, this.rclProps.getProperty(key) + COB_INF_DIR);
+                File blockContext = new File(this.rclProps.getProperty(key) + COB_INF_DIR);
+                try {
+                    springProps.put(newKey, blockContext.toURL().toExternalForm());
+                } catch (MalformedURLException e) {
+                    throw new MojoExecutionException("Can't create URL to  " + blockContext, e);
+                }
             }
         } 
         return springProps;

Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java?view=diff&rev=483413&r1=483412&r2=483413
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java Thu Dec  7 02:50:47 2006
@@ -29,8 +29,8 @@
         Properties springProps = p.getSpringProperties();
         assertEquals(5, springProps.size());
         assertTrue(springProps.containsKey("org.apache.cocoon.cocoon-rcl-plugin-demo.block/blockContextURL"));
-        assertEquals("file:/F:/blocks/myBlock1/target/classes/COB-INF", 
-            springProps.getProperty("org.apache.cocoon.cocoon-rcl-plugin-demo.block1/blockContextURL"));
+        assertTrue(springProps.getProperty("org.apache.cocoon.cocoon-rcl-plugin-demo.block1/blockContextURL")
+                .indexOf("target/classes/COB-INF") > 0);
     }
     
     public void testLoadingArtifactValues() throws Exception {