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/build/Container.java b/bundleplugin/src/main/java/aQute/bnd/build/Container.java
index 8a721c9..0de335d 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/Container.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/Container.java
@@ -103,12 +103,14 @@
return error;
}
+ @Override
public boolean equals(Object other) {
if (other instanceof Container)
return file.equals(((Container) other).file);
return false;
}
+ @Override
public int hashCode() {
return file.hashCode();
}
@@ -122,6 +124,7 @@
*
* @return
*/
+ @Override
public String toString() {
if (getError() != null)
return "/error/" + getError();
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/Project.java b/bundleplugin/src/main/java/aQute/bnd/build/Project.java
index 06a4f8e..9c5c2ec 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/Project.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/Project.java
@@ -14,6 +14,7 @@
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.eclipse.*;
import aQute.bnd.service.*;
+import aQute.bnd.service.RepositoryPlugin.PutResult;
import aQute.bnd.service.RepositoryPlugin.Strategy;
import aQute.bnd.service.action.*;
import aQute.bnd.version.*;
@@ -146,6 +147,7 @@
return workspace;
}
+ @Override
public String toString() {
return getBase().getName();
}
@@ -202,7 +204,9 @@
// Set default bin directory
output = getOutput0();
if (!output.exists()) {
- output.mkdirs();
+ if (!output.mkdirs()) {
+ throw new IOException("Could not create directory " + output);
+ }
getWorkspace().changedFile(output);
}
if (!output.isDirectory())
@@ -296,10 +300,12 @@
/**
*
*/
- private File getTarget0() {
+ private File getTarget0() throws IOException {
File target = getFile(getProperty("target", "generated"));
if (!target.exists()) {
- target.mkdirs();
+ if (!target.mkdirs()) {
+ throw new IOException("Could not create directory " + target);
+ }
getWorkspace().changedFile(target);
}
return target;
@@ -809,15 +815,16 @@
return join(list, separator);
}
+ @Override
protected Object[] getMacroDomains() {
return new Object[] {
workspace
};
}
- public File release(Jar jar) throws Exception {
+ public File release(String jarName, InputStream jarStream) throws Exception {
String name = getProperty(Constants.RELEASEREPO);
- return release(name, jar);
+ return release(name, jarName, jarStream);
}
/**
@@ -825,11 +832,12 @@
*
* @param name
* The repository name
- * @param jar
+ * @param jarName
+ * @param jarStream
* @return
* @throws Exception
*/
- public File release(String name, Jar jar) throws Exception {
+ public File release(String name, String jarName, InputStream jarStream) throws Exception {
trace("release %s", name);
List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class);
RepositoryPlugin rp = null;
@@ -848,14 +856,11 @@
if (rp != null) {
try {
- File file = rp.put(jar);
- trace("Released %s to file %s in repository %s", jar.getName(), file, rp);
+ PutResult r = rp.put(jarStream, new RepositoryPlugin.PutOptions());
+ trace("Released %s to %s in repository %s", jarName, r.artifact, rp);
}
catch (Exception e) {
- msgs.Release_Into_Exception_(jar, rp, e);
- }
- finally {
- jar.close();
+ msgs.Release_Into_Exception_(jarName, rp, e);
}
} else if (name == null)
msgs.NoNameForReleaseRepository();
@@ -890,15 +895,8 @@
}
trace("build ", Arrays.toString(jars));
for (File jar : jars) {
- Jar j = new Jar(jar);
- try {
- release(name, j);
- }
- finally {
- j.close();
- }
+ release(name, jar.getName(), new BufferedInputStream(new FileInputStream(jar)));
}
-
}
/**
@@ -1114,17 +1112,13 @@
}
if (rp != null) {
- Jar jar = new Jar(file);
try {
- rp.put(jar);
+ rp.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions());
return;
}
catch (Exception e) {
msgs.DeployingFile_On_Exception_(file, rp.getName(), e);
}
- finally {
- jar.close();
- }
return;
}
trace("No repo found " + file);
@@ -1155,22 +1149,16 @@
}
File[] outputs = getBuildFiles();
for (File output : outputs) {
- Jar jar = new Jar(output);
- try {
for (Deploy d : getPlugins(Deploy.class)) {
- trace("Deploying %s to: %s", jar, d);
+ trace("Deploying %s to: %s", output.getName(), d);
try {
- if (d.deploy(this, jar))
+ if (d.deploy(this, output.getName(), new BufferedInputStream(new FileInputStream(output))))
trace("deployed %s successfully to %s", output, d);
}
catch (Exception e) {
msgs.Deploying(e);
}
}
- }
- finally {
- jar.close();
- }
}
}
@@ -1452,8 +1440,12 @@
if (!f.exists() || f.lastModified() < jar.lastModified()) {
reportNewer(f.lastModified(), jar);
f.delete();
- if (!f.getParentFile().isDirectory())
- f.getParentFile().mkdirs();
+ File fp = f.getParentFile();
+ if (!fp.isDirectory()) {
+ if (!fp.exists() && !fp.mkdirs()) {
+ throw new IOException("Could not create directory " + fp);
+ }
+ }
jar.write(f);
getWorkspace().changedFile(f);
@@ -1491,6 +1483,7 @@
/**
* Refresh if we are based on stale data. This also implies our workspace.
*/
+ @Override
public boolean refresh() {
boolean changed = false;
if (isCnf()) {
@@ -1503,6 +1496,7 @@
return getBase().getName().equals(Workspace.CNFDIR);
}
+ @Override
public void propertiesChanged() {
super.propertiesChanged();
preparedPaths = false;
@@ -1568,12 +1562,16 @@
File target = getTarget0();
if (target.isDirectory() && target.getParentFile() != null) {
IO.delete(target);
- target.mkdirs();
+ if (!target.exists() && !target.mkdirs()) {
+ throw new IOException("Could not create directory " + target);
+ }
}
File output = getOutput0();
if (getOutput().isDirectory())
IO.delete(output);
- output.mkdirs();
+ if (!output.exists() && !output.mkdirs()) {
+ throw new IOException("Could not create directory " + output);
+ }
}
public File[] build() throws Exception {
@@ -2052,7 +2050,10 @@
String path = packageName.replace('.', '/') + "/packageinfo";
File binary = IO.getFile(getOutput(), path);
- binary.getParentFile().mkdirs();
+ File bp = binary.getParentFile();
+ if (!bp.exists() && !bp.mkdirs()) {
+ throw new IOException("Could not create directory " + bp);
+ }
IO.copy(file, binary);
refresh();
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/ProjectBuilder.java b/bundleplugin/src/main/java/aQute/bnd/build/ProjectBuilder.java
index 5cf4f0e..774934a 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/ProjectBuilder.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/ProjectBuilder.java
@@ -27,12 +27,14 @@
/**
* We put our project and our workspace on the macro path.
*/
+ @Override
protected Object[] getMacroDomains() {
return new Object[] {
project, project.getWorkspace()
};
}
+ @Override
public Builder getSubBuilder() throws Exception {
return project.getBuilder(this);
}
@@ -41,6 +43,7 @@
return project;
}
+ @Override
public void init() {
try {
if (!initialized) {
@@ -68,6 +71,7 @@
}
}
+ @Override
public List<Jar> getClasspath() {
init();
return super.getClasspath();
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/ProjectMessages.java b/bundleplugin/src/main/java/aQute/bnd/build/ProjectMessages.java
index 57367f6..f692abb 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/ProjectMessages.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/ProjectMessages.java
@@ -3,7 +3,6 @@
import java.io.*;
import java.util.*;
-import aQute.bnd.osgi.*;
import aQute.bnd.service.*;
import aQute.bnd.service.RepositoryPlugin.Strategy;
import aQute.bnd.version.*;
@@ -39,7 +38,7 @@
ERROR ReleaseRepository_NotFoundIn_(String name, List<RepositoryPlugin> plugins);
- ERROR Release_Into_Exception_(Jar jar, RepositoryPlugin rp, Exception e);
+ ERROR Release_Into_Exception_(String jar, RepositoryPlugin rp, Exception e);
ERROR NoScripters_(String script);
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/ProjectTester.java b/bundleplugin/src/main/java/aQute/bnd/build/ProjectTester.java
index 86ce2e3..4549624 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/ProjectTester.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/ProjectTester.java
@@ -63,7 +63,9 @@
}
public boolean prepare() throws Exception {
- reportDir.mkdirs();
+ if (!reportDir.exists() && !reportDir.mkdirs()) {
+ throw new IOException("Could not create directory " + reportDir);
+ }
for (File file : reportDir.listFiles()) {
file.delete();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/ReflectAction.java b/bundleplugin/src/main/java/aQute/bnd/build/ReflectAction.java
index 3c3ee16..7a0f855 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/ReflectAction.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/ReflectAction.java
@@ -16,6 +16,7 @@
m.invoke(project);
}
+ @Override
public String toString() {
return "ra:" + what;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/Workspace.java b/bundleplugin/src/main/java/aQute/bnd/build/Workspace.java
index 9111773..0044b11 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/Workspace.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/Workspace.java
@@ -81,7 +81,9 @@
public Workspace(File dir) throws Exception {
dir = dir.getAbsoluteFile();
- dir.mkdirs();
+ if (!dir.exists() && !dir.mkdirs()) {
+ throw new IOException("Could not create directory " + dir);
+ }
assert dir.isDirectory();
File buildDir = new File(dir, BNDDIR).getAbsoluteFile();
@@ -123,6 +125,7 @@
return models.values();
}
+ @Override
public boolean refresh() {
if (super.refresh()) {
for (Project project : getCurrentProjects()) {
@@ -261,19 +264,23 @@
super("cache", getFile(buildDir, CACHEDIR), false);
}
+ @Override
public String toString() {
return "bnd-cache";
}
+ @Override
protected void init() throws Exception {
if (lock.tryLock(50, TimeUnit.SECONDS) == false)
throw new TimeLimitExceededException("Cached File Repo is locked and can't acquire it");
try {
if (!inited) {
inited = true;
- root.mkdirs();
+ if (!root.exists() && !root.mkdirs()) {
+ throw new IOException("Could not create cache directory " + root);
+ }
if (!root.isDirectory())
- throw new IllegalArgumentException("Cannot create cache dir " + root);
+ throw new IllegalArgumentException("Cache directory " + root + " not a directory");
InputStream in = getClass().getResourceAsStream(EMBEDDED_REPO);
if (in != null)
@@ -296,7 +303,10 @@
if (!jentry.isDirectory()) {
File dest = Processor.getFile(dir, jentry.getName());
if (!dest.isFile() || dest.lastModified() < jentry.getTime() || jentry.getTime() == 0) {
- dest.getParentFile().mkdirs();
+ File dp = dest.getParentFile();
+ if (!dp.exists() && !dp.mkdirs()) {
+ throw new IOException("Could not create directory " + dp);
+ }
FileOutputStream out = new FileOutputStream(dest);
try {
copy(jin, out);
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/WorkspaceRepository.java b/bundleplugin/src/main/java/aQute/bnd/build/WorkspaceRepository.java
index 451bd77..c52b7f1 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/WorkspaceRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/build/WorkspaceRepository.java
@@ -86,7 +86,7 @@
return false;
}
- public File put(Jar jar) throws Exception {
+ public PutResult put(InputStream stream, PutOptions options) throws Exception {
return null;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/build/packageinfo b/bundleplugin/src/main/java/aQute/bnd/build/packageinfo
index 0ff7674..084a0d4 100644
--- a/bundleplugin/src/main/java/aQute/bnd/build/packageinfo
+++ b/bundleplugin/src/main/java/aQute/bnd/build/packageinfo
@@ -1 +1 @@
-version 1.45.0
+version 2.0.0
diff --git a/bundleplugin/src/main/java/aQute/bnd/compatibility/Access.java b/bundleplugin/src/main/java/aQute/bnd/compatibility/Access.java
index ac8bb37..1fcb640 100644
--- a/bundleplugin/src/main/java/aQute/bnd/compatibility/Access.java
+++ b/bundleplugin/src/main/java/aQute/bnd/compatibility/Access.java
@@ -19,6 +19,7 @@
return PACKAGE;
}
+ @Override
public String toString() {
return super.toString().toLowerCase();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/compatibility/GenericParameter.java b/bundleplugin/src/main/java/aQute/bnd/compatibility/GenericParameter.java
index 5118bf3..e801a8a 100644
--- a/bundleplugin/src/main/java/aQute/bnd/compatibility/GenericParameter.java
+++ b/bundleplugin/src/main/java/aQute/bnd/compatibility/GenericParameter.java
@@ -13,6 +13,7 @@
};
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(name);
diff --git a/bundleplugin/src/main/java/aQute/bnd/compatibility/Kind.java b/bundleplugin/src/main/java/aQute/bnd/compatibility/Kind.java
index 42626f1..2e9f5cd 100644
--- a/bundleplugin/src/main/java/aQute/bnd/compatibility/Kind.java
+++ b/bundleplugin/src/main/java/aQute/bnd/compatibility/Kind.java
@@ -6,6 +6,7 @@
public enum Kind {
ROOT, CLASS, FIELD, CONSTRUCTOR, METHOD, UNKNOWN;
+ @Override
public String toString() {
return super.toString().toLowerCase();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/compatibility/Scope.java b/bundleplugin/src/main/java/aQute/bnd/compatibility/Scope.java
index 43dccbd..c44f3bf 100644
--- a/bundleplugin/src/main/java/aQute/bnd/compatibility/Scope.java
+++ b/bundleplugin/src/main/java/aQute/bnd/compatibility/Scope.java
@@ -68,6 +68,7 @@
base = typeSignature;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/AnnotationReader.java b/bundleplugin/src/main/java/aQute/bnd/component/AnnotationReader.java
index 1ca3af7..09c5f25 100644
--- a/bundleplugin/src/main/java/aQute/bnd/component/AnnotationReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/component/AnnotationReader.java
@@ -129,6 +129,7 @@
return null;
}
+ @Override
public void annotation(Annotation annotation) {
try {
java.lang.annotation.Annotation a = annotation.getAnnotation();
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java b/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java
index e66ad0c..f3840f3 100644
--- a/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java
+++ b/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java
@@ -29,15 +29,13 @@
if (instruction.matches(c.getFQN())) {
if (instruction.isNegated())
break;
- else {
- ComponentDef definition = AnnotationReader.getDefinition(c, analyzer);
- if (definition != null) {
- definition.sortReferences();
- definition.prepare(analyzer);
- String name = "OSGI-INF/" + definition.name + ".xml";
- names.add(name);
- analyzer.getJar().putResource(name, new TagResource(definition.getTag()));
- }
+ ComponentDef definition = AnnotationReader.getDefinition(c, analyzer);
+ if (definition != null) {
+ definition.sortReferences();
+ definition.prepare(analyzer);
+ String name = "OSGI-INF/" + definition.name + ".xml";
+ names.add(name);
+ analyzer.getJar().putResource(name, new TagResource(definition.getTag()));
}
}
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java b/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java
index a794027..aa1e6e7 100644
--- a/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java
@@ -91,6 +91,7 @@
clazz.parseClassFileWithCollector(new ClassDataCollector() {
+ @Override
public void method(MethodDef md) {
Set<String> allowedParams = allowed;
String lifecycleName = null;
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/ReferenceDef.java b/bundleplugin/src/main/java/aQute/bnd/component/ReferenceDef.java
index fc09c52..cb4d489 100644
--- a/bundleplugin/src/main/java/aQute/bnd/component/ReferenceDef.java
+++ b/bundleplugin/src/main/java/aQute/bnd/component/ReferenceDef.java
@@ -88,6 +88,7 @@
return b;
}
+ @Override
public String toString() {
return name;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/TagResource.java b/bundleplugin/src/main/java/aQute/bnd/component/TagResource.java
index 1155d99..814a2b6 100644
--- a/bundleplugin/src/main/java/aQute/bnd/component/TagResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/component/TagResource.java
@@ -12,6 +12,7 @@
this.tag = tag;
}
+ @Override
public void write(OutputStream out) throws UnsupportedEncodingException {
OutputStreamWriter ow = new OutputStreamWriter(out, "UTF-8");
PrintWriter pw = new PrintWriter(ow);
@@ -24,6 +25,7 @@
}
}
+ @Override
public long lastModified() {
return 0;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/differ/DiffImpl.java b/bundleplugin/src/main/java/aQute/bnd/differ/DiffImpl.java
index 57c7da5..ef21f65 100644
--- a/bundleplugin/src/main/java/aQute/bnd/differ/DiffImpl.java
+++ b/bundleplugin/src/main/java/aQute/bnd/differ/DiffImpl.java
@@ -180,10 +180,12 @@
return children;
}
+ @Override
public String toString() {
return String.format("%-10s %-10s %s", getDelta(), getType(), getName());
}
+ @Override
public boolean equals(Object other) {
if (other instanceof DiffImpl) {
DiffImpl o = (DiffImpl) other;
@@ -192,6 +194,7 @@
return false;
}
+ @Override
public int hashCode() {
return getDelta().hashCode() ^ getType().hashCode() ^ getName().hashCode();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/differ/Element.java b/bundleplugin/src/main/java/aQute/bnd/differ/Element.java
index 3d27f62..6b74b4d 100644
--- a/bundleplugin/src/main/java/aQute/bnd/differ/Element.java
+++ b/bundleplugin/src/main/java/aQute/bnd/differ/Element.java
@@ -100,6 +100,7 @@
return type.compareTo(other.getType());
}
+ @Override
public boolean equals(Object other) {
if (other == null || getClass() != other.getClass())
return false;
@@ -107,6 +108,7 @@
return compareTo((Element) other) == 0;
}
+ @Override
public int hashCode() {
return type.hashCode() ^ name.hashCode();
}
@@ -135,6 +137,7 @@
return null;
}
+ @Override
public String toString() {
return type + " " + name + " (" + add + "/" + remove + ")";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/filerepo/FileRepo.java b/bundleplugin/src/main/java/aQute/bnd/filerepo/FileRepo.java
index 4f5a436..a8966a4 100644
--- a/bundleplugin/src/main/java/aQute/bnd/filerepo/FileRepo.java
+++ b/bundleplugin/src/main/java/aQute/bnd/filerepo/FileRepo.java
@@ -4,7 +4,6 @@
import java.util.*;
import java.util.regex.*;
-import aQute.bnd.osgi.*;
import aQute.bnd.version.*;
public class FileRepo {
@@ -97,9 +96,11 @@
return files[files.length - 1];
}
- public File put(String bsn, Version version) {
+ public File put(String bsn, Version version) throws IOException {
File dir = new File(root, bsn);
- dir.mkdirs();
+ if (!dir.exists() && !dir.mkdirs()) {
+ throw new IOException("Could not create directory " + dir);
+ }
File file = new File(dir, bsn + "-" + version.getMajor() + "." + version.getMinor() + "." + version.getMicro()
+ ".jar");
return file;
diff --git a/bundleplugin/src/main/java/aQute/bnd/header/Attrs.java b/bundleplugin/src/main/java/aQute/bnd/header/Attrs.java
index 0124ff1..d0c41ba 100644
--- a/bundleplugin/src/main/java/aQute/bnd/header/Attrs.java
+++ b/bundleplugin/src/main/java/aQute/bnd/header/Attrs.java
@@ -3,7 +3,6 @@
import java.util.*;
import java.util.regex.*;
-import aQute.bnd.osgi.*;
import aQute.bnd.version.*;
import aQute.lib.collections.*;
@@ -220,6 +219,7 @@
return get("version");
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
append(sb);
@@ -237,11 +237,13 @@
}
}
+ @Override
@Deprecated
public boolean equals(Object other) {
return super.equals(other);
}
+ @Override
@Deprecated
public int hashCode() {
return super.hashCode();
diff --git a/bundleplugin/src/main/java/aQute/bnd/header/Parameters.java b/bundleplugin/src/main/java/aQute/bnd/header/Parameters.java
index 413b6a5..7666f4b 100644
--- a/bundleplugin/src/main/java/aQute/bnd/header/Parameters.java
+++ b/bundleplugin/src/main/java/aQute/bnd/header/Parameters.java
@@ -148,6 +148,7 @@
return map.values();
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
append(sb);
@@ -168,11 +169,13 @@
}
}
+ @Override
@Deprecated
public boolean equals(Object other) {
return super.equals(other);
}
+ @Override
@Deprecated
public int hashCode() {
return super.hashCode();
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java b/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
index 505cfc2..14cba4b 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
@@ -47,6 +47,7 @@
* We set the last modified to 0 so this resource does not force a new JAR
* if all other resources are up to date.
*/
+ @Override
public long lastModified() {
return 0;
}
@@ -55,6 +56,7 @@
* The write method is called to write the resource. We just call the static
* method.
*/
+ @Override
public void write(OutputStream out) throws Exception {
OutputStreamWriter osw = new OutputStreamWriter(out, Constants.DEFAULT_CHARSET);
PrintWriter pw = new PrintWriter(osw);
@@ -87,6 +89,7 @@
Clazz.MethodDef source;
// Before a method is parsed
+ @Override
public void method(Clazz.MethodDef source) {
this.source = source;
xref(using, source, null);
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java b/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
index c9d60b3..b9d7e4f 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
@@ -80,6 +80,7 @@
return r.map;
}
+ @Override
public void annotation(Annotation annotation) {
String fqn = annotation.getName().getFQN();
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java b/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
index af863c6..5367c93 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
@@ -11,11 +11,9 @@
import aQute.bnd.header.*;
import aQute.bnd.make.metatype.*;
import aQute.bnd.osgi.*;
-import aQute.bnd.osgi.Clazz.MethodDef;
import aQute.bnd.osgi.Clazz.QUERY;
import aQute.bnd.osgi.Descriptors.TypeRef;
import aQute.bnd.service.*;
-import aQute.bnd.version.*;
import aQute.lib.tag.Tag;
/**
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java b/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
index 6ca638c..2878248 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
@@ -37,6 +37,7 @@
clazz.parseClassFileWithCollector(new ClassDataCollector() {
MethodDef source;
+ @Override
public void implementsInterfaces(TypeRef names[]) {
MethodDef def = clazz.getMethodDef(0, "<implements>", "()V");
// TODO
@@ -53,6 +54,7 @@
}
// Method definitions
+ @Override
public void method(MethodDef source) {
this.source = source;
}
@@ -77,10 +79,12 @@
for (final Clazz clazz : sources) {
clazz.parseClassFileWithCollector(new ClassDataCollector() {
+ @Override
public boolean classStart(int access, TypeRef name) {
return clazz.isPublic();
}
+ @Override
public void method(MethodDef source) {
if (source.isPublic() || source.isProtected())
catalog.put(source, new ArrayList<MethodDef>());
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
index 4f57467..be717e2 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
@@ -171,6 +171,7 @@
final List<String> values = Create.list();
c.parseClassFileWithCollector(new ClassDataCollector() {
+ @Override
public void field(Clazz.FieldDef def) {
if (def.isEnum()) {
values.add(def.getName());
@@ -236,6 +237,7 @@
}
+ @Override
public void write(OutputStream out) throws IOException {
try {
finish();
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
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java
index c490e66..135f96c 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java
@@ -769,6 +769,7 @@
}
}
+ @Override
public void setBase(File file) {
super.setBase(file);
getProperties().put("project.dir", getBase().getAbsolutePath());
@@ -840,6 +841,7 @@
return jar;
}
+ @Override
protected void begin() {
if (inited == false) {
inited = true;
@@ -1466,6 +1468,7 @@
}
}
+ @Override
public void close() {
if (diagnostics) {
PrintStream out = System.err;
@@ -1612,6 +1615,7 @@
classpath.add(jar);
}
+ @Override
public void clear() {
classpath.clear();
}
@@ -2447,7 +2451,10 @@
jar.lastModified() - output.lastModified());
if (!output.exists() || output.lastModified() <= jar.lastModified() || force) {
- output.getParentFile().mkdirs();
+ File op = output.getParentFile();
+ if (!op.exists() && !op.mkdirs()) {
+ throw new IOException("Could not create directory " + op);
+ }
if (source != null && output.getCanonicalPath().equals(source.getCanonicalPath())) {
File bak = new File(source.getParentFile(), source.getName() + ".bak");
if (!source.renameTo(bak)) {
@@ -2545,11 +2552,13 @@
clazz.parseClassFileWithCollector(new ClassDataCollector() {
Clazz.Def member;
+ @Override
public void extendsClass(TypeRef zuper) throws Exception {
if (dest.contains(zuper.getPackageRef()))
xref.add(clazz.getExtends(zuper), zuper);
}
+ @Override
public void implementsInterfaces(TypeRef[] interfaces) throws Exception {
for (TypeRef i : interfaces) {
if (dest.contains(i.getPackageRef()))
@@ -2557,6 +2566,7 @@
}
}
+ @Override
public void referTo(TypeRef to, int modifiers) {
if (to.isJava())
return;
@@ -2570,10 +2580,12 @@
}
+ @Override
public void method(Clazz.MethodDef defined) {
member = defined;
}
+ @Override
public void field(Clazz.FieldDef defined) {
member = defined;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Annotation.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Annotation.java
index 37c4cad..0383962 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Annotation.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Annotation.java
@@ -34,6 +34,7 @@
return policy;
}
+ @Override
public String toString() {
return name + ":" + member + ":" + policy + ":" + elements;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java
index 912bad3..2ee603a 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java
@@ -238,7 +238,10 @@
f = new File(f, "MANIFEST.MF");
}
f.delete();
- f.getParentFile().mkdirs();
+ File fp = f.getParentFile();
+ if (!fp.exists() && !fp.mkdirs()) {
+ throw new IOException("Could not create directory " + fp);
+ }
OutputStream out = new FileOutputStream(f);
try {
Jar.writeManifest(dot.getManifest(), out);
@@ -281,6 +284,7 @@
/**
* Answer extra packages. In this case we implement conditional package. Any
*/
+ @Override
protected Jar getExtra() throws Exception {
Parameters conditionals = getParameters(CONDITIONAL_PACKAGE);
if (conditionals.isEmpty())
@@ -315,6 +319,7 @@
* the setup. We do not want to cleanup if we are going to verify.
*/
+ @Override
public void analyze() throws Exception {
super.analyze();
cleanupVersion(getImports(), null);
@@ -1078,6 +1083,7 @@
sourcePath.add(cp);
}
+ @Override
public void close() {
super.close();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/BundleId.java b/bundleplugin/src/main/java/aQute/bnd/osgi/BundleId.java
index 2d711ad..67f9b4a 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/BundleId.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/BundleId.java
@@ -24,10 +24,12 @@
return Verifier.isVersion(version) && Verifier.isBsn(bsn);
}
+ @Override
public boolean equals(Object o) {
return this == o || ((o instanceof BundleId) && compareTo((BundleId) o) == 0);
}
+ @Override
public int hashCode() {
return bsn.hashCode() ^ version.hashCode();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Clazz.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Clazz.java
index e03865a..1a325e6 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Clazz.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Clazz.java
@@ -251,11 +251,13 @@
this.descriptor = analyzer.getDescriptor(descriptor);
}
+ @Override
public String getName() {
return name;
}
+ @Override
public TypeRef getType() {
return descriptor.getType();
}
@@ -290,6 +292,7 @@
return objectDescriptorToFQN(returnType);
}
+ @Override
public TypeRef[] getPrototype() {
return null;
}
@@ -297,6 +300,7 @@
return signature;
}
+ @Override
public String toString() {
return name;
}
@@ -311,6 +315,7 @@
return name.equals("<init>") || name.equals("<clinit>");
}
+ @Override
public TypeRef[] getPrototype() {
return descriptor.getPrototype();
}
@@ -335,16 +340,18 @@
}
+ @Override
public String getName() {
if (interf)
return "<implements>";
- else
- return "<extends>";
+ return "<extends>";
}
+ @Override
public TypeRef getType() {
return type;
}
+ @Override
public TypeRef[] getPrototype() {
return null;
}
@@ -1527,6 +1534,7 @@
return clazz.is(query, instr, analyzer);
}
+ @Override
public String toString() {
return className.getFQN();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/CombinedResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/CombinedResource.java
index d38f416..1b10348 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/CombinedResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/CombinedResource.java
@@ -10,6 +10,7 @@
@Override
public void write(final OutputStream out) throws IOException, Exception {
OutputStream unclosable = new FilterOutputStream(out) {
+ @Override
public void close() {
// Ignore
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Descriptors.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Descriptors.java
index b435b27..683f96d 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Descriptors.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Descriptors.java
@@ -95,6 +95,7 @@
return java;
}
+ @Override
public String toString() {
return fqn;
}
@@ -111,11 +112,13 @@
return fqn.compareTo(other.fqn);
}
+ @Override
public boolean equals(Object o) {
assert o instanceof PackageRef;
return o == this;
}
+ @Override
public int hashCode() {
return super.hashCode();
}
@@ -207,6 +210,7 @@
return packageRef.isJava();
}
+ @Override
public String toString() {
return fqn;
}
@@ -215,6 +219,7 @@
return fqn.equals("java.lang.Object");
}
+ @Override
public boolean equals(Object other) {
assert other instanceof TypeRef;
return this == other;
@@ -268,6 +273,7 @@
return component.getClassRef();
}
+ @Override
public boolean equals(Object other) {
if (other == null || other.getClass() != getClass())
return false;
@@ -287,6 +293,7 @@
return component.isJava();
}
+ @Override
public String toString() {
return component.toString() + "[]";
}
@@ -457,6 +464,7 @@
return prototype;
}
+ @Override
public boolean equals(Object other) {
if (other == null || other.getClass() != getClass())
return false;
@@ -464,10 +472,12 @@
return Arrays.equals(prototype, ((Descriptor) other).prototype) && type == ((Descriptor) other).type;
}
+ @Override
public int hashCode() {
return prototype == null ? type.hashCode() : type.hashCode() ^ Arrays.hashCode(prototype);
}
+ @Override
public String toString() {
return descriptor;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/EmbeddedResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/EmbeddedResource.java
index 0aad605..ae3c449 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/EmbeddedResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/EmbeddedResource.java
@@ -23,6 +23,7 @@
out.write(data);
}
+ @Override
public String toString() {
return ":" + data.length + ":";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/FileResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/FileResource.java
index cd18cf5..66635d1 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/FileResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/FileResource.java
@@ -19,6 +19,7 @@
traverse(jar, directory.getAbsolutePath().length(), directory, doNotCopy);
}
+ @Override
public String toString() {
return ":" + file.getName() + ":";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Instruction.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Instruction.java
index a660169..d350c8a 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Instruction.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Instruction.java
@@ -145,6 +145,7 @@
return input;
}
+ @Override
public String toString() {
return input;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Instructions.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Instructions.java
index bfb7e28..b157f88 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Instructions.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Instructions.java
@@ -145,6 +145,7 @@
return map.values();
}
+ @Override
public String toString() {
return map == null ? "{}" : map.toString();
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Jar.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Jar.java
index 11c0dab..93c55a1 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Jar.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Jar.java
@@ -97,6 +97,7 @@
this.name = name;
}
+ @Override
public String toString() {
return "Jar:" + name;
}
@@ -768,14 +769,19 @@
public void expand(File dir) throws Exception {
check();
dir = dir.getAbsoluteFile();
- dir.mkdirs();
+ if (!dir.exists() && !dir.mkdirs()) {
+ throw new IOException("Could not create directory " + dir);
+ }
if (!dir.isDirectory()) {
throw new IllegalArgumentException("Not a dir: " + dir.getAbsolutePath());
}
for (Map.Entry<String,Resource> entry : getResources().entrySet()) {
File f = getFile(dir, entry.getKey());
- f.getParentFile().mkdirs();
+ File fp = f.getParentFile();
+ if (!fp.exists() && !fp.mkdirs()) {
+ throw new IOException("Could not create directory " + fp);
+ }
IO.copy(entry.getValue().openInputStream(), f);
}
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/JarResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/JarResource.java
index 2fb5c54..1734fc9 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/JarResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/JarResource.java
@@ -10,10 +10,12 @@
this.jar = jar;
}
+ @Override
public long lastModified() {
return jar.lastModified();
}
+ @Override
public void write(OutputStream out) throws Exception {
try {
jar.write(out);
@@ -28,6 +30,7 @@
return jar;
}
+ @Override
public String toString() {
return ":" + jar.getName() + ":";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Macro.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Macro.java
index 20cc4a4..d706596 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Macro.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Macro.java
@@ -895,6 +895,7 @@
return previous.contains(key);
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
String del = "[";
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Packages.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Packages.java
index 53a92da..a7f6290 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Packages.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Packages.java
@@ -179,6 +179,7 @@
return getByFQN(s) != null;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
append(sb);
@@ -219,11 +220,13 @@
return deflt;
}
+ @Override
@Deprecated
public boolean equals(Object other) {
return super.equals(other);
}
+ @Override
@Deprecated
public int hashCode() {
return super.hashCode();
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/PreprocessResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/PreprocessResource.java
index a1b5095..c1f847c 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/PreprocessResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/PreprocessResource.java
@@ -13,6 +13,7 @@
setExtra(resource.getExtra());
}
+ @Override
protected byte[] getBytes() throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream(2000);
OutputStreamWriter osw = new OutputStreamWriter(bout, Constants.DEFAULT_CHARSET);
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Processor.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Processor.java
index b153cb9..5958a9d 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Processor.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Processor.java
@@ -127,12 +127,10 @@
try {
if (p.isFailOk())
return p.warning(string, args);
- else {
- String s = formatArrays(string, args == null ? new Object[0] : args);
- if (!p.errors.contains(s))
- p.errors.add(s);
- return location(s);
- }
+ String s = formatArrays(string, args == null ? new Object[0] : args);
+ if (!p.errors.contains(s))
+ p.errors.add(s);
+ return location(s);
}
finally {
p.signal();
@@ -160,13 +158,11 @@
if (p.isFailOk()) {
return p.warning(string + ": " + t, args);
}
- else {
- p.errors.add("Exception: " + t.getMessage());
- String s = formatArrays(string, args == null ? new Object[0] : args);
- if (!p.errors.contains(s))
- p.errors.add(s);
- return location(s);
- }
+ p.errors.add("Exception: " + t.getMessage());
+ String s = formatArrays(string, args == null ? new Object[0] : args);
+ if (!p.errors.contains(s))
+ p.errors.add(s);
+ return location(s);
}
finally {
p.signal();
@@ -408,6 +404,7 @@
return plugin;
}
+ @Override
public boolean isFailOk() {
String v = getProperty(Analyzer.FAIL_OK, null);
return v != null && v.equalsIgnoreCase("true");
@@ -1184,6 +1181,7 @@
super.addURL(url);
}
+ @Override
public Class< ? > loadClass(String name) throws NoClassDefFoundError {
try {
Class< ? > c = super.loadClass(name);
@@ -1581,6 +1579,7 @@
* Printout of the status of this processor for toString()
*/
+ @Override
public String toString() {
try {
StringBuilder sb = new StringBuilder();
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/URLResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/URLResource.java
index 2cd2375..5d47067 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/URLResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/URLResource.java
@@ -18,6 +18,7 @@
return url.openStream();
}
+ @Override
public String toString() {
return ":" + url.getPath() + ":";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/Verifier.java b/bundleplugin/src/main/java/aQute/bnd/osgi/Verifier.java
index eac2f6f..b5bd72c 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/Verifier.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/Verifier.java
@@ -47,6 +47,7 @@
this.target = target;
}
+ @Override
public String toString() {
return name + "(" + target + ")";
}
@@ -814,6 +815,7 @@
return true;
}
+ @Override
public String getProperty(String key, String deflt) {
if (properties == null)
return deflt;
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/WriteResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/WriteResource.java
index 494c678..ed72c41 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/WriteResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/WriteResource.java
@@ -10,6 +10,7 @@
PipedInputStream pin = new PipedInputStream();
final PipedOutputStream pout = new PipedOutputStream(pin);
Thread t = new Thread() {
+ @Override
public void run() {
try {
write(pout);
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/ZipResource.java b/bundleplugin/src/main/java/aQute/bnd/osgi/ZipResource.java
index edf6a68..1101945 100755
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/ZipResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/ZipResource.java
@@ -24,6 +24,7 @@
return zip.getInputStream(entry);
}
+ @Override
public String toString() {
return ":" + zip.getName() + "(" + entry.getName() + "):";
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/osgi/resource/Filters.java b/bundleplugin/src/main/java/aQute/bnd/osgi/resource/Filters.java
index b8c7836..f12e7c8 100644
--- a/bundleplugin/src/main/java/aQute/bnd/osgi/resource/Filters.java
+++ b/bundleplugin/src/main/java/aQute/bnd/osgi/resource/Filters.java
@@ -2,7 +2,6 @@
import org.osgi.framework.namespace.*;
-import aQute.bnd.osgi.*;
import aQute.bnd.version.*;
import aQute.libg.filters.*;
diff --git a/bundleplugin/src/main/java/aQute/bnd/repo/eclipse/EclipseRepo.java b/bundleplugin/src/main/java/aQute/bnd/repo/eclipse/EclipseRepo.java
index e40d179..d7817ad 100644
--- a/bundleplugin/src/main/java/aQute/bnd/repo/eclipse/EclipseRepo.java
+++ b/bundleplugin/src/main/java/aQute/bnd/repo/eclipse/EclipseRepo.java
@@ -85,7 +85,10 @@
private void write(File index, Map<String, ? extends Map<String,String>> map) throws Exception {
String s = Processor.printClauses(map);
- index.getParentFile().mkdirs();
+ File ip = index.getParentFile();
+ if (!ip.exists() && !ip.mkdirs()) {
+ throw new IOException("Could not create directory " + ip);
+ }
PrintWriter fw = IO.writer(index);
try {
fw.write(s);
@@ -166,7 +169,7 @@
return result;
}
- public File put(Jar jar) throws Exception {
+ public PutResult put(InputStream stream, PutOptions options) throws Exception {
return null;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/service/Deploy.java b/bundleplugin/src/main/java/aQute/bnd/service/Deploy.java
index a8fc577..fbdac78 100644
--- a/bundleplugin/src/main/java/aQute/bnd/service/Deploy.java
+++ b/bundleplugin/src/main/java/aQute/bnd/service/Deploy.java
@@ -1,11 +1,12 @@
package aQute.bnd.service;
+import java.io.InputStream;
+
import aQute.bnd.build.*;
-import aQute.bnd.osgi.*;
/**
* Deploy this artifact to maven.
*/
public interface Deploy {
- boolean deploy(Project project, Jar jar) throws Exception;
+ boolean deploy(Project project, String jarName, InputStream jarStream) throws Exception;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/service/RepositoryPlugin.java b/bundleplugin/src/main/java/aQute/bnd/service/RepositoryPlugin.java
index 772803d..73847f7 100644
--- a/bundleplugin/src/main/java/aQute/bnd/service/RepositoryPlugin.java
+++ b/bundleplugin/src/main/java/aQute/bnd/service/RepositoryPlugin.java
@@ -1,9 +1,9 @@
package aQute.bnd.service;
import java.io.*;
+import java.net.*;
import java.util.*;
-import aQute.bnd.osgi.*;
import aQute.bnd.version.*;
public interface RepositoryPlugin {
@@ -12,6 +12,83 @@
}
/**
+ * Options used to steer the put operation
+ */
+ public class PutOptions {
+ /**
+ * The <b>SHA1</b> digest of the artifact to put into the repository.<br/>
+ * <br/>
+ * When specified the digest of the <b>fetched</b> artifact will be
+ * calculated and verified against this digest, <b>before</b> putting
+ * the artifact into the repository.<br/>
+ * <br/>
+ * An exception is thrown if the specified digest and the calculated
+ * digest do not match.
+ */
+ public byte[] digest = null;
+
+ /**
+ * Allow the implementation to change the artifact.<br/>
+ * <br/>
+ * When set to true the implementation is allowed to change the artifact
+ * when putting it into the repository.<br/>
+ * <br/>
+ * An exception is thrown when set to false and the implementation can't
+ * put the artifact into the repository without changing it.
+ */
+ public boolean allowArtifactChange = false;
+
+ /**
+ * Generate a <b>SHA1</b> digest.<br/>
+ * <br/>
+ * When set to true the implementation generates a digest of the
+ * artifact as it is put into the repository and returns that digest in
+ * the result.
+ */
+ public boolean generateDigest = false;
+
+ /**
+ * Create a 'latest' artifact when it did not exist.<br/>
+ * <br/>
+ * When set to true the implementation is requested to create a 'latest'
+ * artifact.
+ */
+ public boolean createLatest = false;
+ }
+
+ /**
+ * Results returned by the put operation
+ */
+ public class PutResult {
+ /**
+ * The artifact as it was put in the repository.<br/>
+ * <br/>
+ * This can be a URI to the artifact (when it was put into the
+ * repository), or null when the artifact was not put into the
+ * repository (for example because it was already in the repository).
+ */
+ public URI artifact = null;
+
+ /**
+ * The 'latest' artifact as it was put in the repository.<br/>
+ * <br/>
+ * Only set when {@link PutOptions#createLatest} was set to true and the
+ * 'latest' artifact did not exist, or when the 'latest' artifact did
+ * exists and was older than the artifact being put in the repository.
+ */
+ public URI latest = null;
+
+ /**
+ * The <b>SHA1</b> digest of the artifact as it was put into the
+ * repository.<br/>
+ * <br/>
+ * This will be null when {@link PutOptions#generateDigest} was null, or
+ * when {@link #artifact} is null.
+ */
+ public byte[] digest = null;
+ }
+
+ /**
* Return a URL to a matching version of the given bundle.
*
* @param bsn
@@ -36,12 +113,29 @@
boolean canWrite();
/**
- * Put a JAR file in the repository.
+ * Put an artifact (from the InputStream) into the repository.<br/>
+ * <br/>
+ * There is NO guarantee that the artifact on the input stream has not been
+ * modified after it's been put in the repository since that is dependent on
+ * the implementation of the repository (see
+ * {@link RepositoryPlugin.PutOptions#allowArtifactChange}).
*
- * @param jar
+ * @param stream
+ * The input stream with the artifact
+ * @param options
+ * The put options. See {@link RepositoryPlugin.PutOptions}
+ * @return The result of the put, never null. See
+ * {@link RepositoryPlugin.PutResult}
* @throws Exception
+ * When the repository root directory doesn't exist, when the
+ * repository is read-only, when the specified checksum doesn't
+ * match the checksum of the fetched artifact (see
+ * {@link RepositoryPlugin.PutOptions#digest}), when the
+ * implementation wants to modify the artifact but isn't allowed
+ * (see {@link RepositoryPlugin.PutOptions#allowArtifactChange}
+ * ), or when another error has occurred.
*/
- File put(Jar jar) throws Exception;
+ PutResult put(InputStream stream, PutOptions options) throws Exception;
/**
* Return a list of bsns that are present in the repository.
diff --git a/bundleplugin/src/main/java/aQute/bnd/service/packageinfo b/bundleplugin/src/main/java/aQute/bnd/service/packageinfo
index 084a0d4..63eb236 100644
--- a/bundleplugin/src/main/java/aQute/bnd/service/packageinfo
+++ b/bundleplugin/src/main/java/aQute/bnd/service/packageinfo
@@ -1 +1 @@
-version 2.0.0
+version 3.0.0
diff --git a/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java b/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
index bbc0593..dab3b0c 100644
--- a/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
@@ -10,7 +10,7 @@
public interface MinimalRepository {
public enum Gestalt {
ADD, REMOTE
- };
+ }
Report add(File f) throws Exception;
diff --git a/bundleplugin/src/main/java/aQute/bnd/signing/JartoolSigner.java b/bundleplugin/src/main/java/aQute/bnd/signing/JartoolSigner.java
index fe317b8..f878450 100644
--- a/bundleplugin/src/main/java/aQute/bnd/signing/JartoolSigner.java
+++ b/bundleplugin/src/main/java/aQute/bnd/signing/JartoolSigner.java
@@ -119,6 +119,7 @@
final StringBuilder sb = new StringBuilder();
Thread tin = new Thread() {
+ @Override
public void run() {
try {
BufferedReader rdr = new BufferedReader(new InputStreamReader(in, Constants.DEFAULT_CHARSET));
diff --git a/bundleplugin/src/main/java/aQute/bnd/version/Version.java b/bundleplugin/src/main/java/aQute/bnd/version/Version.java
index 359a66d..7ec3ba1 100755
--- a/bundleplugin/src/main/java/aQute/bnd/version/Version.java
+++ b/bundleplugin/src/main/java/aQute/bnd/version/Version.java
@@ -106,6 +106,7 @@
return qualifier.compareTo(o.qualifier);
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(major);
@@ -120,6 +121,7 @@
return sb.toString();
}
+ @Override
public boolean equals(Object ot) {
if (!(ot instanceof Version))
return false;
@@ -127,6 +129,7 @@
return compareTo((Version) ot) == 0;
}
+ @Override
public int hashCode() {
return major * 97 ^ minor * 13 ^ micro + (qualifier == null ? 97 : qualifier.hashCode());
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/version/VersionRange.java b/bundleplugin/src/main/java/aQute/bnd/version/VersionRange.java
index 0761616..8c9a8dd 100755
--- a/bundleplugin/src/main/java/aQute/bnd/version/VersionRange.java
+++ b/bundleplugin/src/main/java/aQute/bnd/version/VersionRange.java
@@ -41,6 +41,7 @@
return end == ']';
}
+ @Override
public String toString() {
if (high == low)
return high.toString();