Latest bnd sync

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1370165 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
index 7fb4dfd..b1bdc42 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
@@ -60,7 +60,9 @@
 
 		trace("temp dir " + temp);
 		IO.delete(temp);
-		temp.mkdirs();
+		if (!temp.exists() && !temp.mkdirs()) {
+			throw new IOException("Could not create directory " + temp);
+		}
 		if (!temp.isDirectory())
 			throw new IOException("Cannot create temp directory");
 
@@ -210,7 +212,9 @@
 		}
 
 		File original = getFile(temp, "original");
-		original.mkdirs();
+		if (!original.exists() && !original.mkdirs()) {
+			throw new IOException("Could not create directory " + original);
+		}
 		binaryJar.expand(original);
 		binaryJar.calcChecksums(null);
 
@@ -272,7 +276,9 @@
 
 		trace("creating bundle dir");
 		File bundle = new File(temp, "bundle");
-		bundle.mkdirs();
+		if (!bundle.exists() && !bundle.mkdirs()) {
+			throw new IOException("Could not create directory " + bundle);
+		}
 
 		String prefix = pom.getArtifactId() + "-" + pom.getVersion();
 		File binaryFile = new File(bundle, prefix + ".jar");
@@ -400,7 +406,9 @@
 
 	private Jar javadoc(File source, Set<String> exports, Manifest m, Properties p) throws Exception {
 		File tmp = new File(temp, "javadoc");
-		tmp.mkdirs();
+		if (!tmp.exists() && !tmp.mkdirs()) {
+			throw new IOException("Could not create directory " + tmp);
+		}
 
 		Command command = new Command();
 		command.add(getProperty("javadoc", "javadoc"));
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
index bbc45b8..e9e928e 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
@@ -63,6 +63,7 @@
 			dependencies.add(artifact);
 		}
 
+		@Override
 		public String toString() {
 			return groupId + "." + artifactId + "-" + version + "[" + scope + "," + optional + "]";
 		}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
index ff383b4..592b3f9 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
@@ -40,56 +40,64 @@
 
 	/**
 	 */
-	public boolean deploy(Project project, Jar original) throws Exception {
+	public boolean deploy(Project project, String jarName, InputStream jarStream) throws Exception {
 		Parameters deploy = project.parseHeader(project.getProperty(Constants.DEPLOY));
 
 		Map<String,String> maven = deploy.get(repository);
 		if (maven == null)
 			return false; // we're not playing for this bundle
 
-		project.progress("deploying %s to Maven repo: %s", original, repository);
+		project.progress("deploying %s to Maven repo: %s", jarName, repository);
 		File target = project.getTarget();
 		File tmp = Processor.getFile(target, repository);
-		tmp.mkdirs();
+		if (!tmp.exists() && !tmp.mkdirs()) {
+			throw new IOException("Could not create directory " + tmp);
+		}
 
-		Manifest manifest = original.getManifest();
-		if (manifest == null)
-			project.error("Jar has no manifest: %s", original);
-		else {
-			project.progress("Writing pom.xml");
-			PomResource pom = new PomResource(manifest);
-			pom.setProperties(maven);
-			File pomFile = write(tmp, pom, "pom.xml");
+		Jar original = new Jar(jarName, jarStream);
+		try {
+			Manifest manifest = original.getManifest();
+			if (manifest == null)
+				project.error("Jar has no manifest: %s", original);
+			else {
+				project.progress("Writing pom.xml");
+				PomResource pom = new PomResource(manifest);
+				pom.setProperties(maven);
+				File pomFile = write(tmp, pom, "pom.xml");
 
-			Jar main = new Jar("main");
-			Jar src = new Jar("src");
-			try {
-				split(original, main, src);
-				Parameters exports = project.parseHeader(manifest.getMainAttributes()
-						.getValue(Constants.EXPORT_PACKAGE));
-				File jdoc = new File(tmp, "jdoc");
-				jdoc.mkdirs();
-				project.progress("Generating Javadoc for: " + exports.keySet());
-				Jar javadoc = javadoc(jdoc, project, exports.keySet());
-				project.progress("Writing javadoc jar");
-				File javadocFile = write(tmp, new JarResource(javadoc), "javadoc.jar");
-				project.progress("Writing main file");
-				File mainFile = write(tmp, new JarResource(main), "main.jar");
-				project.progress("Writing sources file");
-				File srcFile = write(tmp, new JarResource(main), "src.jar");
+				Jar main = new Jar("main");
+				Jar src = new Jar("src");
+				try {
+					split(original, main, src);
+					Parameters exports = project.parseHeader(manifest.getMainAttributes().getValue(
+							Constants.EXPORT_PACKAGE));
+					File jdoc = new File(tmp, "jdoc");
+					jdoc.mkdirs();
+					project.progress("Generating Javadoc for: " + exports.keySet());
+					Jar javadoc = javadoc(jdoc, project, exports.keySet());
+					project.progress("Writing javadoc jar");
+					File javadocFile = write(tmp, new JarResource(javadoc), "javadoc.jar");
+					project.progress("Writing main file");
+					File mainFile = write(tmp, new JarResource(main), "main.jar");
+					project.progress("Writing sources file");
+					File srcFile = write(tmp, new JarResource(main), "src.jar");
 
-				project.progress("Deploying main file");
-				maven_gpg_sign_and_deploy(project, mainFile, null, pomFile);
-				project.progress("Deploying main sources file");
-				maven_gpg_sign_and_deploy(project, srcFile, "sources", null);
-				project.progress("Deploying main javadoc file");
-				maven_gpg_sign_and_deploy(project, javadocFile, "javadoc", null);
+					project.progress("Deploying main file");
+					maven_gpg_sign_and_deploy(project, mainFile, null, pomFile);
+					project.progress("Deploying main sources file");
+					maven_gpg_sign_and_deploy(project, srcFile, "sources", null);
+					project.progress("Deploying main javadoc file");
+					maven_gpg_sign_and_deploy(project, javadocFile, "javadoc", null);
 
+				}
+				finally {
+					main.close();
+					src.close();
+				}
 			}
-			finally {
-				main.close();
-				src.close();
-			}
+		}
+		finally {
+			original.close();
 		}
 		return true;
 	}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
index 10829ca..8d19093 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
@@ -85,7 +85,9 @@
 		project.progress("deploying %s to Maven repo: %s", original, repository);
 		File target = project.getTarget();
 		File tmp = Processor.getFile(target, repository);
-		tmp.mkdirs();
+		if (!tmp.exists() && !tmp.mkdirs()) {
+			throw new IOException("Could not create directory " + tmp);
+		}
 
 		Manifest manifest = original.getManifest();
 		if (manifest == null)
@@ -103,7 +105,9 @@
 				Parameters exports = project.parseHeader(manifest.getMainAttributes()
 						.getValue(Constants.EXPORT_PACKAGE));
 				File jdoc = new File(tmp, "jdoc");
-				jdoc.mkdirs();
+				if (!jdoc.exists() && !jdoc.mkdirs()) {
+					throw new IOException("Could not create directory " + jdoc);
+				}
 				project.progress("Generating Javadoc for: " + exports.keySet());
 				Jar javadoc = javadoc(jdoc, project, exports.keySet());
 				project.progress("Writing javadoc jar");
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
index 7a6ff20..33d21e0 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
@@ -17,6 +17,7 @@
 	Reporter					reporter;
 	String						name;
 
+	@Override
 	public String toString() {
 		return "maven:" + root;
 	}
@@ -112,7 +113,7 @@
 		}
 	}
 
-	public File put(Jar jar) throws Exception {
+	public PutResult put(InputStream stream, PutOptions options) throws Exception {
 		throw new IllegalStateException("Maven does not support the put command");
 	}
 
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java
index 5787e29..d784767 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java
@@ -11,6 +11,7 @@
 		this.maven = mavenEntry;
 	}
 
+	@Override
 	public File getArtifact() throws Exception {
 		return maven.getArtifact();
 	}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java
index fe185a1..4e153c3 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java
@@ -43,7 +43,9 @@
 		this.pomPath = path + ".pom";
 		this.artifactPath = path + ".jar";
 		this.dir = IO.getFile(maven.repository, path).getParentFile();
-		this.dir.mkdirs();
+		if (!this.dir.exists() && !this.dir.mkdirs()) {
+			throw new ExceptionInInitializerError("Could not create directory " + this.dir);
+		}
 		this.pomFile = new File(maven.repository, pomPath);
 		this.artifactFile = new File(maven.repository, artifactPath);
 		this.propertiesFile = new File(dir, "bnd.properties");
@@ -98,7 +100,9 @@
 				// the file.
 
 			} else {
-				dir.mkdirs();
+				if (!dir.exists() && !dir.mkdirs()) {
+					throw new IOException("Could not create directory " + dir);
+				}
 				// We really do not have the file
 				// so we have to find out who has it.
 				for (final URI url : urls) {
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java
index 93f169b..4609e32 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java
@@ -4,7 +4,6 @@
 import java.net.*;
 import java.util.*;
 
-import aQute.bnd.osgi.*;
 import aQute.bnd.service.*;
 import aQute.bnd.version.*;
 import aQute.lib.io.*;
@@ -68,7 +67,7 @@
 		return false;
 	}
 
-	public File put(Jar jar) throws Exception {
+	public PutResult put(InputStream stream, PutOptions options) throws Exception {
 		throw new UnsupportedOperationException("cannot do put");
 	}
 
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java
index 0055d19..a778d8b 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java
@@ -296,6 +296,7 @@
 		return in;
 	}
 
+	@Override
 	public String toString() {
 		return groupId + "+" + artifactId + "-" + version;
 	}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java
index 07e10c6..eedff8c 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java
@@ -136,6 +136,7 @@
 	// Match any macros
 	final static Pattern	MACRO	= Pattern.compile("(\\$\\{\\s*([^}\\s]+)\\s*\\})");
 
+	@Override
 	protected String replace(String in) {
 		System.err.println("Replce: " + in);
 		if (in == null) {
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/packageinfo b/bundleplugin/src/main/java/aQute/bnd/maven/support/packageinfo
index 7c8de03..a3d9bcc 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/packageinfo
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/packageinfo
@@ -1 +1 @@
-version 1.0
+version 2.0