You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/09/09 07:46:19 UTC

svn commit: r693373 - /servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java

Author: ffang
Date: Mon Sep  8 22:46:18 2008
New Revision: 693373

URL: http://svn.apache.org/viewvc?rev=693373&view=rev
Log:
[SM-1559] features-maven-plugin can't deal with the windows file uri rightly

Modified:
    servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java

Modified: servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java?rev=693373&r1=693372&r2=693373&view=diff
==============================================================================
--- servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java (original)
+++ servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/AddFeaturesToRepoMojo.java Mon Sep  8 22:46:18 2008
@@ -114,7 +114,7 @@
                 String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
                 String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
                 System.out.println("Copy:      " + dir + name);
-                copy(new URL(localRepo.getUrl() + "/" + dir + name).openStream(),
+                copy(new URL(getLocalRepoUrl() + "/" + dir + name).openStream(),
                      repository,
                      name,
                      dir,
@@ -149,11 +149,29 @@
             }
             String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
             String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
-            return localRepo.getUrl() + "/" + dir + name;
+
+            return getLocalRepoUrl() + "/" + dir + name;
+        }
+        if (System.getProperty("os.name").startsWith("Windows") && uri.startsWith("file:")) {
+        	String baseDir = uri.substring(5).replace('\\', '/');
+        	String result = "file:" + baseDir;;
+        	if (baseDir.indexOf(":") > 0) {
+        		result = "file:///" + baseDir;
+        	}
+        	return result;
         }
         return uri;
     }
 
+    private String getLocalRepoUrl() {
+    	 if (System.getProperty("os.name").startsWith("Windows")) {
+    		 return localRepo.getProtocol() + ":///" + localRepo.getBasedir().replace('\\', '/');
+
+    	 } else {
+    		 return localRepo.getUrl();
+    	 }
+    }
+
     private void addFeatures(List<String> features, Set<String> transitiveFeatures, Map<String, Feature> featuresMap) {
         for (String feature : features) {
             Feature f = featuresMap.get(feature);