1. Sebastian Sdorra
  2. maven-plugins

Commits

Sebastian Sdorra  committed 6030873

fix resource pathes on windows

  • Participants
  • Parent commits 4efbed5
  • Branches default

Comments (0)

Files changed (4)

File web-compressor/src/main/java/sonia/maven/web/template/AbstractTemplateCompressor.java

View file
    * Method description
    *
    *
+   * @param path
+   *
+   * @return
+   */
+  protected String convertToFilePath(String path)
+  {
+    return path.replaceAll("/", File.separator);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @param path
+   *
+   * @return
+   */
+  protected String convertToWebPath(String path)
+  {
+    return path.replaceAll(File.separator, "/");
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param document
    * @param targetBaseDirectory
    * @param targetReosurceDirectory
 
     String path = resourceFile.getCanonicalPath().substring(
                       targetBaseDirectory.getCanonicalPath().length());
+    String s = File.separator;
 
-    if (path.startsWith("/"))
+    if (path.startsWith(s))
     {
-      path = path.substring(1);
+      path = path.substring(s.length());
     }
 
     Element element = createElement(document, path);

File web-compressor/src/main/java/sonia/maven/web/template/ClosureTemplateCompressor.java

View file
   @Override
   protected Element createElement(Document document, String path)
   {
+    path = convertToWebPath(path);
+
     return document.createElement("script").attr("type",
                                   "text/javascript").attr("src", path);
   }
   @Override
   protected File getFile(File inputDirectory, Element element)
   {
-    return new File(inputDirectory, element.attr("src"));
+    String path = convertToFilePath(element.attr("src"));
+
+    return new File(inputDirectory, path);
   }
 }

File web-compressor/src/main/java/sonia/maven/web/template/PartialTemplateCompressorMojo.java

View file
  * @goal partial-compress-template
  * @author Sebastian Sdorra
  */
-public class PartialTemplateCompressorMojo extends AbstractTemplateCompressorMojo
+public class PartialTemplateCompressorMojo
+        extends AbstractTemplateCompressorMojo
 {
 
   /**

File web-compressor/src/main/java/sonia/maven/web/template/YuiTemplateCompressor.java

View file
   @Override
   protected Element createElement(Document document, String path)
   {
+    path = convertToWebPath(path);
+
     return document.createElement("link").attr("type", "text/css").attr("rel",
                                   "stylesheet").attr("href", path);
   }
   @Override
   protected File getFile(File inputDirectory, Element element)
   {
-    return new File(inputDirectory, element.attr("href"));
+    String path = convertToFilePath(element.attr("href"));
+
+    return new File(inputDirectory, path);
   }
 }