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 2007/03/29 15:43:07 UTC

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

Author: reinhard
Date: Thu Mar 29 06:43:06 2007
New Revision: 523706

URL: http://svn.apache.org/viewvc?view=rev&rev=523706
Log:
- make sure that all generated paths are correct when
  the plugin is executed as part of an aggregated build
- use toUri().toAscii() instead of toUrl().toExternalForm() as 
  suggested by Jorg in a separate thread

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

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=523706&r1=523705&r2=523706
==============================================================================
--- 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 Mar 29 06:43:06 2007
@@ -91,9 +91,9 @@
     /**
      * The directory that contains the Cocoon web application.
      * 
-     * @parameter expression="${cocoon.rcl.properties}"
+     * @parameter expression="./rcl.properties"
      */
-    private File rclPropertiesFile = new File("./rcl.properties");    
+    private File rclPropertiesFile;    
 
     /**
      * Use socket appender
@@ -211,7 +211,7 @@
     protected RwmProperties readProperties() throws MojoExecutionException {
         RwmProperties props = null;
         try {
-            props  = new RwmProperties(this.rclPropertiesFile);
+            props  = new RwmProperties(this.rclPropertiesFile, this.project.getBasedir());
         } catch (ConfigurationException e) {
             throw new MojoExecutionException("Can't read " + this.rclPropertiesFile.getAbsolutePath(), e);
         }

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=523706&r1=523705&r2=523706
==============================================================================
--- 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 Mar 29 06:43:06 2007
@@ -37,9 +37,11 @@
     private static final String TARGET_CLASSES_DIR = "target/classes";
     
     private Configuration props;
-
-    public RwmProperties(File propsFile) throws ConfigurationException {
-        props = new PropertiesConfiguration(propsFile);
+    private File basedir;
+    
+    public RwmProperties(File propsFile, File basedir) throws ConfigurationException {
+        this.props = new PropertiesConfiguration(propsFile);
+        this.basedir = basedir;
     }
     
     public Set getClassesDirs() throws MojoExecutionException {
@@ -52,7 +54,7 @@
                     String path = values[i];
                     String url = null;
                     try {
-                        url = new File(path).toURL().toExternalForm();
+                        url = getUrlAsString(path);
                     } catch (MalformedURLException e) {
                         throw new MojoExecutionException("Can't create URL to  " + path, e);
                     }
@@ -86,7 +88,7 @@
             if(key.endsWith(BLOCK_CONTEXT_URL_PARAM)) {
                 String path = null;
                 try {
-                    path = new File(this.props.getString(key)).toURL().toExternalForm();
+                    path = this.getUrlAsString(this.props.getString(key));
                 } catch (MalformedURLException e) {
                     throw new MojoExecutionException("Can't create URL to  " + path, e);
                 }            
@@ -97,7 +99,7 @@
             else if(key.endsWith(CLASSES_DIR) && !CLASSES_DIR.equals(key)) {
                 String path = null;
                 try {
-                    path = new File(this.props.getString(key)).toURL().toExternalForm();
+                    path = this.getUrlAsString(this.props.getString(key));
                 } catch (MalformedURLException e) {
                     throw new MojoExecutionException("Can't create URL to  " + this.props.getString(key), e);
                 }  
@@ -141,6 +143,21 @@
             }
         }
         return cocoonProps;
+    }
+    
+    private String getUrlAsString(String path) throws MalformedURLException {
+        // find out if the path is relative or absolute
+        boolean absolute = false;
+        if(path.indexOf(':') == 1 || path.startsWith("/")) {
+            absolute = true;
+        }
+        File p = null;
+        if(absolute) {
+            p = new File(path);
+        } else {
+            p = new File(this.basedir, path);
+        }
+        return p.toURI().toASCIIString();
     }
     
 }    

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=523706&r1=523705&r2=523706
==============================================================================
--- 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 Mar 29 06:43:06 2007
@@ -80,7 +80,7 @@
     }      
     
     protected RwmProperties createTestProperties() throws Exception {    
-        return new RwmProperties(getResourcesFromClassLoaderAsFile("rcl.properties"));
+        return new RwmProperties(getResourcesFromClassLoaderAsFile("rcl.properties"), new File(""));
     }
     
     protected File getResourcesFromClassLoaderAsFile(String fileName) throws IOException {