Latest bnd code
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350613 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/BsnToMavenPath.java b/bundleplugin/src/main/java/aQute/bnd/maven/BsnToMavenPath.java
index 6dc716c..85125ce 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/BsnToMavenPath.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/BsnToMavenPath.java
@@ -1,5 +1,5 @@
package aQute.bnd.maven;
public interface BsnToMavenPath {
- String[] getGroupAndArtifact(String bsn);
+ String[] getGroupAndArtifact(String bsn);
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
index e9cbfc3..edd212b 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenCommand.java
@@ -22,8 +22,7 @@
final Settings settings = new Settings();
File temp;
- public MavenCommand() {
- }
+ public MavenCommand() {}
public MavenCommand(Processor p) {
super(p);
@@ -167,14 +166,15 @@
else if (option.equals("-output"))
output = args[i++];
else if (option.equals("-nodelete"))
- nodelete=true;
+ nodelete = true;
else if (option.startsWith("-properties")) {
InputStream in = null;
try {
in = new FileInputStream(args[i++]);
properties.load(in);
- } catch (Exception e) {
- } finally {
+ }
+ catch (Exception e) {}
+ finally {
if (in != null) {
in.close();
}
@@ -233,17 +233,16 @@
for (String d : developers)
pom.addDeveloper(d);
- Set<String> exports = OSGiHeader.parseHeader(
- manifest.getMainAttributes().getValue(Constants.EXPORT_PACKAGE)).keySet();
+ Set<String> exports = OSGiHeader.parseHeader(manifest.getMainAttributes().getValue(Constants.EXPORT_PACKAGE))
+ .keySet();
Jar sourceJar;
if (source == null) {
trace("Splitting source code");
sourceJar = new Jar("source");
- for (Map.Entry<String, Resource> entry : binaryJar.getResources().entrySet()) {
+ for (Map.Entry<String,Resource> entry : binaryJar.getResources().entrySet()) {
if (entry.getKey().startsWith("OSGI-OPT/src")) {
- sourceJar.putResource(entry.getKey().substring("OSGI-OPT/src/".length()),
- entry.getValue());
+ sourceJar.putResource(entry.getKey().substring("OSGI-OPT/src/".length()), entry.getValue());
}
}
copyInfo(binaryJar, sourceJar, "source");
@@ -251,7 +250,7 @@
sourceJar = getJarFromFileOrURL(source);
}
sourceJar.calcChecksums(null);
-
+
Jar javadocJar;
if (javadoc == null) {
trace("creating javadoc because -javadoc not used");
@@ -266,7 +265,7 @@
javadocJar = getJarFromFileOrURL(javadoc);
}
javadocJar.calcChecksums(null);
-
+
addClose(binaryJar);
addClose(sourceJar);
addClose(javadocJar);
@@ -280,8 +279,7 @@
File sourceFile = new File(bundle, prefix + "-sources.jar");
File javadocFile = new File(bundle, prefix + "-javadoc.jar");
File pomFile = new File(bundle, "pom.xml").getAbsoluteFile();
- trace("creating output files %s, %s,%s, and %s", binaryFile, sourceFile, javadocFile,
- pomFile);
+ trace("creating output files %s, %s,%s, and %s", binaryFile, sourceFile, javadocFile, pomFile);
IO.copy(pom.openInputStream(), pomFile);
trace("copied pom");
@@ -318,39 +316,39 @@
private void copyInfo(Jar source, Jar dest, String type) throws Exception {
source.ensureManifest();
dest.ensureManifest();
- copyInfoResource( source, dest, "LICENSE");
- copyInfoResource( source, dest, "LICENSE.html");
- copyInfoResource( source, dest, "about.html");
-
+ copyInfoResource(source, dest, "LICENSE");
+ copyInfoResource(source, dest, "LICENSE.html");
+ copyInfoResource(source, dest, "about.html");
+
Manifest sm = source.getManifest();
Manifest dm = dest.getManifest();
- copyInfoHeader( sm, dm, "Bundle-Description","");
- copyInfoHeader( sm, dm, "Bundle-Vendor","");
- copyInfoHeader( sm, dm, "Bundle-Copyright","");
- copyInfoHeader( sm, dm, "Bundle-DocURL","");
- copyInfoHeader( sm, dm, "Bundle-License","");
- copyInfoHeader( sm, dm, "Bundle-Name", " " + type);
- copyInfoHeader( sm, dm, "Bundle-SymbolicName", "." + type);
- copyInfoHeader( sm, dm, "Bundle-Version", "");
+ copyInfoHeader(sm, dm, "Bundle-Description", "");
+ copyInfoHeader(sm, dm, "Bundle-Vendor", "");
+ copyInfoHeader(sm, dm, "Bundle-Copyright", "");
+ copyInfoHeader(sm, dm, "Bundle-DocURL", "");
+ copyInfoHeader(sm, dm, "Bundle-License", "");
+ copyInfoHeader(sm, dm, "Bundle-Name", " " + type);
+ copyInfoHeader(sm, dm, "Bundle-SymbolicName", "." + type);
+ copyInfoHeader(sm, dm, "Bundle-Version", "");
}
private void copyInfoHeader(Manifest sm, Manifest dm, String key, String value) {
String v = sm.getMainAttributes().getValue(key);
- if ( v == null) {
+ if (v == null) {
trace("no source for " + key);
return;
}
-
- if ( dm.getMainAttributes().getValue(key) != null) {
- trace("already have " + key );
+
+ if (dm.getMainAttributes().getValue(key) != null) {
+ trace("already have " + key);
return;
}
-
+
dm.getMainAttributes().putValue(key, v + value);
}
private void copyInfoResource(Jar source, Jar dest, String type) {
- if ( source.getResources().containsKey(type) && !dest.getResources().containsKey(type))
+ if (source.getResources().containsKey(type) && !dest.getResources().containsKey(type))
dest.putResource(type, source.getResource(type));
}
@@ -369,7 +367,8 @@
InputStream in = url.openStream();
try {
jar = new Jar(url.getFile(), in);
- } finally {
+ }
+ finally {
in.close();
}
}
@@ -399,8 +398,7 @@
}
}
- private Jar javadoc(File source, Set<String> exports, Manifest m, Properties p)
- throws Exception {
+ private Jar javadoc(File source, Set<String> exports, Manifest m, Properties p) throws Exception {
File tmp = new File(temp, "javadoc");
tmp.mkdirs();
@@ -438,7 +436,7 @@
command.add("-tag");
command.add("noimplement:t:Consumers of this API must not implement this interface");
- for (Enumeration<?> e = pp.propertyNames(); e.hasMoreElements();) {
+ for (Enumeration< ? > e = pp.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
String value = pp.getProperty(key);
@@ -460,8 +458,7 @@
int result = command.execute(out, err);
if (result != 0) {
- warning("Error during execution of javadoc command: %s\n******************\n%s", out,
- err);
+ warning("Error during execution of javadoc command: %s\n******************\n%s", out, err);
}
Jar jar = new Jar(tmp);
addClose(jar);
@@ -475,14 +472,13 @@
* @return
*/
private String license(Attributes attr) {
- Parameters map = Processor.parseHeader(
- attr.getValue(Constants.BUNDLE_LICENSE), null);
+ Parameters map = Processor.parseHeader(attr.getValue(Constants.BUNDLE_LICENSE), null);
if (map.isEmpty())
return null;
StringBuilder sb = new StringBuilder();
String sep = "Licensed under ";
- for (Entry<String, Attrs> entry : map.entrySet()) {
+ for (Entry<String,Attrs> entry : map.entrySet()) {
sb.append(sep);
String key = entry.getKey();
String link = entry.getValue().get("link");
@@ -541,78 +537,74 @@
pp.setProperty(key, defaultValue);
}
-
/**
* View - Show the dependency details of an artifact
*/
-
- static Executor executor = Executors.newCachedThreadPool();
- static Pattern GROUP_ARTIFACT_VERSION = Pattern.compile("([^+]+)\\+([^+]+)\\+([^+]+)");
- void view( String args[], int i) throws Exception {
+ static Executor executor = Executors.newCachedThreadPool();
+ static Pattern GROUP_ARTIFACT_VERSION = Pattern.compile("([^+]+)\\+([^+]+)\\+([^+]+)");
+
+ void view(String args[], int i) throws Exception {
Maven maven = new Maven(executor);
OutputStream out = System.err;
-
- List<URI> urls = new ArrayList<URI>();
-
- while ( i < args.length && args[i].startsWith("-")) {
- if( "-r".equals(args[i])) {
+
+ List<URI> urls = new ArrayList<URI>();
+
+ while (i < args.length && args[i].startsWith("-")) {
+ if ("-r".equals(args[i])) {
URI uri = new URI(args[++i]);
- urls.add( uri );
+ urls.add(uri);
System.err.println("URI for repo " + uri);
- }
- else
- if ( "-o".equals(args[i])) {
- out = new FileOutputStream(args[++i]);
- }
- else
- throw new IllegalArgumentException("Unknown option: " + args[i]);
-
+ } else if ("-o".equals(args[i])) {
+ out = new FileOutputStream(args[++i]);
+ } else
+ throw new IllegalArgumentException("Unknown option: " + args[i]);
+
i++;
}
-
+
URI[] urls2 = urls.toArray(new URI[urls.size()]);
PrintWriter pw = IO.writer(out);
-
- while ( i < args.length) {
+
+ while (i < args.length) {
String ref = args[i++];
pw.println("Ref " + ref);
-
+
Matcher matcher = GROUP_ARTIFACT_VERSION.matcher(ref);
if (matcher.matches()) {
-
+
String group = matcher.group(1);
String artifact = matcher.group(2);
String version = matcher.group(3);
CachedPom pom = maven.getPom(group, artifact, version, urls2);
-
+
Builder a = new Builder();
a.setProperty("Private-Package", "*");
Set<Pom> dependencies = pom.getDependencies(Scope.compile, urls2);
- for ( Pom dep : dependencies ) {
- System.err.printf( "%20s %-20s %10s%n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
+ for (Pom dep : dependencies) {
+ System.err.printf("%20s %-20s %10s%n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
a.addClasspath(dep.getArtifact());
}
pw.println(a.getClasspath());
a.build();
- TreeSet<PackageRef> sorted = new TreeSet<PackageRef>( a.getImports().keySet());
- for ( PackageRef p :sorted) {
- pw.printf("%-40s\n",p);
+ TreeSet<PackageRef> sorted = new TreeSet<PackageRef>(a.getImports().keySet());
+ for (PackageRef p : sorted) {
+ pw.printf("%-40s\n", p);
}
-// for ( Map.Entry<String, Set<String>> entry : a.getUses().entrySet()) {
-// String from = entry.getKey();
-// for ( String uses : entry.getValue()) {
-// System.err.printf("%40s %s\n", from, uses);
-// from = "";
-// }
-// }
+ // for ( Map.Entry<String, Set<String>> entry :
+ // a.getUses().entrySet()) {
+ // String from = entry.getKey();
+ // for ( String uses : entry.getValue()) {
+ // System.err.printf("%40s %s\n", from, uses);
+ // from = "";
+ // }
+ // }
a.close();
} else
System.err.println("Wrong, must look like group+artifact+version, is " + ref);
-
+
}
}
-
-
+
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
index 52d2708..d34f2b2 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDependencyGraph.java
@@ -14,14 +14,13 @@
final List<Artifact> dependencies = new ArrayList<Artifact>();
final List<URL> repositories = new ArrayList<URL>();
final XPath xpath = xpathFactory.newXPath();
- final Map<URL, Artifact> cache = new HashMap<URL, Artifact>();
- Artifact root;
+ final Map<URL,Artifact> cache = new HashMap<URL,Artifact>();
+ Artifact root;
enum Scope {
COMPILE, RUNTIME, TEST, PROVIDED, SYSTEM, IMPORT,
}
-
public class Artifact {
String groupId;
@@ -49,33 +48,27 @@
if (scope != null && scope.length() > 0) {
this.scope = Scope.valueOf(scope.toUpperCase());
}
- NodeList evaluate = (NodeList) xpath.evaluate("//dependencies/dependency", doc,
- XPathConstants.NODESET);
+ NodeList evaluate = (NodeList) xpath.evaluate("//dependencies/dependency", doc, XPathConstants.NODESET);
for (int i = 0; i < evaluate.getLength(); i++) {
Node childNode = evaluate.item(i);
- Artifact artifact = getArtifact(xpath.evaluate("groupId", childNode), xpath
- .evaluate("artifactId", childNode), xpath.evaluate("version", childNode));
+ Artifact artifact = getArtifact(xpath.evaluate("groupId", childNode),
+ xpath.evaluate("artifactId", childNode), xpath.evaluate("version", childNode));
add(artifact);
}
}
}
-
-
public void add(Artifact artifact) {
dependencies.add(artifact);
}
-
-
public String toString() {
return groupId + "." + artifactId + "-" + version + "[" + scope + "," + optional + "]";
}
public String getPath() throws URISyntaxException {
- return groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId
- + "-" + version;
+ return groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version;
}
}
@@ -102,7 +95,8 @@
} else {
return new Artifact(url);
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
System.err.println("Failed to get " + artifactId + " from " + repository);
}
}
@@ -127,13 +121,10 @@
return null;
}
-
-
- public void addArtifact( Artifact artifact ) throws Exception {
- if ( root == null)
+ public void addArtifact(Artifact artifact) throws Exception {
+ if (root == null)
root = new Artifact(null);
root.add(artifact);
}
-
-
+
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
index ce936e7..ec5e2b7 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeploy.java
@@ -21,7 +21,7 @@
String passphrase;
Reporter reporter;
- public void setProperties(Map<String, String> map) {
+ public void setProperties(Map<String,String> map) {
repository = map.get("repository");
url = map.get("url");
passphrase = map.get("passphrase");
@@ -41,10 +41,9 @@
/**
*/
public boolean deploy(Project project, Jar original) throws Exception {
- Parameters deploy = project.parseHeader(project
- .getProperty(Constants.DEPLOY));
+ Parameters deploy = project.parseHeader(project.getProperty(Constants.DEPLOY));
- Map<String, String> maven = deploy.get(repository);
+ Map<String,String> maven = deploy.get(repository);
if (maven == null)
return false; // we're not playing for this bundle
@@ -66,8 +65,8 @@
Jar src = new Jar("src");
try {
split(original, main, src);
- Parameters exports = project.parseHeader(manifest
- .getMainAttributes().getValue(Constants.EXPORT_PACKAGE));
+ 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());
@@ -86,7 +85,8 @@
project.progress("Deploying main javadoc file");
maven_gpg_sign_and_deploy(project, javadocFile, "javadoc", null);
- } finally {
+ }
+ finally {
main.close();
src.close();
}
@@ -95,7 +95,7 @@
}
private void split(Jar original, Jar main, Jar src) {
- for (Map.Entry<String, Resource> e : original.getResources().entrySet()) {
+ for (Map.Entry<String,Resource> e : original.getResources().entrySet()) {
String path = e.getKey();
if (path.startsWith("OSGI-OPT/src/")) {
src.putResource(path.substring("OSGI-OPT/src/".length()), e.getValue());
@@ -114,8 +114,7 @@
// -Dfile=/Ws/bnd/biz.aQute.bndlib/tmp/biz.aQute.bndlib.jar \
// -Dpassphrase=a1k3v3t5x3
- private void maven_gpg_sign_and_deploy(Project b, File file, String classifier, File pomFile)
- throws Exception {
+ private void maven_gpg_sign_and_deploy(Project b, File file, String classifier, File pomFile) throws Exception {
Command command = new Command();
command.setTrace();
command.add(b.getProperty("mvn", "mvn"));
@@ -134,8 +133,8 @@
int result = command.execute(stdout, stderr);
if (result != 0) {
- b.error("Maven deploy to %s failed to sign and transfer %s because %s", repository,
- file, "" + stdout + stderr);
+ b.error("Maven deploy to %s failed to sign and transfer %s because %s", repository, file, "" + stdout
+ + stderr);
}
}
@@ -148,12 +147,12 @@
private Jar javadoc(File tmp, Project b, Set<String> exports) throws Exception {
Command command = new Command();
-
+
command.add(b.getProperty("javadoc", "javadoc"));
command.add("-d");
command.add(tmp.getAbsolutePath());
command.add("-sourcepath");
- command.add( Processor.join(b.getSourcePath(),File.pathSeparator));
+ command.add(Processor.join(b.getSourcePath(), File.pathSeparator));
for (String packageName : exports) {
command.add(packageName);
@@ -178,7 +177,8 @@
OutputStream out = new FileOutputStream(f);
try {
r.write(out);
- } finally {
+ }
+ finally {
out.close();
}
return f;
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
index bbd233f..0209f5c 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenDeployCmd.java
@@ -30,16 +30,16 @@
*/
void run(String args[], int i) throws Exception {
if (i >= args.length) {
+ System.err.println("Usage:%n");
System.err
- .println("Usage:%n");
- System.err.println(" deploy [-url repo] [-passphrase passphrase] [-homedir homedir] [-keyname keyname] bundle ...");
+ .println(" deploy [-url repo] [-passphrase passphrase] [-homedir homedir] [-keyname keyname] bundle ...");
System.err.println(" settings");
return;
}
/* skip first argument */
i++;
-
+
while (i < args.length && args[i].startsWith("-")) {
String option = args[i];
if (option.equals("-url"))
@@ -54,10 +54,9 @@
error("Invalid command ");
}
-
}
- public void setProperties(Map<String, String> map) {
+ public void setProperties(Map<String,String> map) {
repository = map.get("repository");
url = map.get("url");
passphrase = map.get("passphrase");
@@ -77,10 +76,9 @@
/**
*/
public boolean deploy(Project project, Jar original) throws Exception {
- Parameters deploy = project.parseHeader(project
- .getProperty(Constants.DEPLOY));
+ Parameters deploy = project.parseHeader(project.getProperty(Constants.DEPLOY));
- Map<String, String> maven = deploy.get(repository);
+ Map<String,String> maven = deploy.get(repository);
if (maven == null)
return false; // we're not playing for this bundle
@@ -102,8 +100,8 @@
Jar src = new Jar("src");
try {
split(original, main, src);
- Parameters exports = project.parseHeader(manifest
- .getMainAttributes().getValue(Constants.EXPORT_PACKAGE));
+ 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());
@@ -122,7 +120,8 @@
project.progress("Deploying main javadoc file");
maven_gpg_sign_and_deploy(project, javadocFile, "javadoc", null);
- } finally {
+ }
+ finally {
main.close();
src.close();
}
@@ -131,7 +130,7 @@
}
private void split(Jar original, Jar main, Jar src) {
- for (Map.Entry<String, Resource> e : original.getResources().entrySet()) {
+ for (Map.Entry<String,Resource> e : original.getResources().entrySet()) {
String path = e.getKey();
if (path.startsWith("OSGI-OPT/src/")) {
src.putResource(path.substring("OSGI-OPT/src/".length()), e.getValue());
@@ -150,8 +149,7 @@
// -Dfile=/Ws/bnd/biz.aQute.bndlib/tmp/biz.aQute.bndlib.jar \
// -Dpassphrase=a1k3v3t5x3
- private void maven_gpg_sign_and_deploy(Project b, File file, String classifier, File pomFile)
- throws Exception {
+ private void maven_gpg_sign_and_deploy(Project b, File file, String classifier, File pomFile) throws Exception {
Command command = new Command();
command.setTrace();
command.add(b.getProperty("mvn", "mvn"));
@@ -170,8 +168,8 @@
int result = command.execute(stdout, stderr);
if (result != 0) {
- b.error("Maven deploy to %s failed to sign and transfer %s because %s", repository,
- file, "" + stdout + stderr);
+ b.error("Maven deploy to %s failed to sign and transfer %s because %s", repository, file, "" + stdout
+ + stderr);
}
}
@@ -214,7 +212,8 @@
OutputStream out = new FileOutputStream(f);
try {
r.write(out);
- } finally {
+ }
+ finally {
out.close();
}
return f;
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenGroup.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenGroup.java
index 2d49be6..d74b6d6 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenGroup.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenGroup.java
@@ -6,22 +6,21 @@
import aQute.libg.reporter.*;
public class MavenGroup implements BsnToMavenPath, Plugin {
- String groupId = "";
+ String groupId = "";
- public String[] getGroupAndArtifact(String bsn) {
- String[] result = new String[2];
- result[0] = groupId;
- result[1] = bsn;
- return result;
- }
+ public String[] getGroupAndArtifact(String bsn) {
+ String[] result = new String[2];
+ result[0] = groupId;
+ result[1] = bsn;
+ return result;
+ }
- public void setProperties(Map<String, String> map) {
- if (map.containsKey("groupId")) {
- groupId = map.get("groupId");
- }
- }
+ public void setProperties(Map<String,String> map) {
+ if (map.containsKey("groupId")) {
+ groupId = map.get("groupId");
+ }
+ }
- public void setReporter(Reporter processor) {
- }
+ public void setReporter(Reporter processor) {}
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java b/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
index a5ad200..80a0a4e 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/MavenRepository.java
@@ -13,9 +13,9 @@
public final static String NAME = "name";
- File root;
- Reporter reporter;
- String name;
+ File root;
+ Reporter reporter;
+ String name;
public String toString() {
return "maven:" + root;
@@ -31,9 +31,9 @@
range = new VersionRange(version);
List<BsnToMavenPath> plugins = ((Processor) reporter).getPlugins(BsnToMavenPath.class);
- if ( plugins.isEmpty())
+ if (plugins.isEmpty())
plugins.add(this);
-
+
for (BsnToMavenPath cvr : plugins) {
String[] paths = cvr.getGroupAndArtifact(bsn);
if (paths != null) {
@@ -62,18 +62,16 @@
if (Verifier.isVersion(vv)) {
Version vvv = new Version(vv);
if (range.includes(vvv)) {
- File file = Processor.getFile(vsdir, v + "/" + artifactId + "-" + v
- + ".jar");
+ File file = Processor.getFile(vsdir, v + "/" + artifactId + "-" + v + ".jar");
if (file.isFile())
result.add(file);
else
reporter.warning("Expected maven entry was not a valid file %s ", file);
}
} else {
- reporter
- .warning(
- "Expected a version directory in maven: dir=%s raw-version=%s cleaned-up-version=%s",
- vsdir, vv, v);
+ reporter.warning(
+ "Expected a version directory in maven: dir=%s raw-version=%s cleaned-up-version=%s",
+ vsdir, vv, v);
}
}
} else
@@ -119,27 +117,27 @@
}
public List<Version> versions(String bsn) throws Exception {
-
- File files[] = get( bsn, null);
+
+ File files[] = get(bsn, null);
List<Version> versions = new ArrayList<Version>();
- for ( File f : files ) {
+ for (File f : files) {
String version = f.getParentFile().getName();
version = Builder.cleanupVersion(version);
- Version v = new Version( version );
+ Version v = new Version(version);
versions.add(v);
}
return versions;
}
- public void setProperties(Map<String, String> map) {
+ public void setProperties(Map<String,String> map) {
File home = new File("");
String root = map.get("root");
if (root == null) {
- home = new File( System.getProperty("user.home") );
- this.root = Processor.getFile(home , ".m2/repository").getAbsoluteFile();
+ home = new File(System.getProperty("user.home"));
+ this.root = Processor.getFile(home, ".m2/repository").getAbsoluteFile();
} else
this.root = Processor.getFile(home, root).getAbsoluteFile();
-
+
if (!this.root.isDirectory()) {
reporter.error("Maven repository did not get a proper URL to the repository %s", root);
}
@@ -155,21 +153,23 @@
String groupId;
String artifactId;
int n = bsn.indexOf('.');
-
- while ( n > 0 ) {
- artifactId = bsn.substring(n+1);
- groupId = bsn.substring(0,n);
-
- File gdir = new File(root, groupId.replace('.',File.separatorChar)).getAbsoluteFile();
- File adir = new File( gdir, artifactId).getAbsoluteFile();
- if ( adir.isDirectory() )
- return new String[] {groupId, artifactId};
-
- n = bsn.indexOf('.',n+1);
+
+ while (n > 0) {
+ artifactId = bsn.substring(n + 1);
+ groupId = bsn.substring(0, n);
+
+ File gdir = new File(root, groupId.replace('.', File.separatorChar)).getAbsoluteFile();
+ File adir = new File(gdir, artifactId).getAbsoluteFile();
+ if (adir.isDirectory())
+ return new String[] {
+ groupId, artifactId
+ };
+
+ n = bsn.indexOf('.', n + 1);
}
return null;
}
-
+
public String getName() {
if (name == null) {
return toString();
@@ -181,16 +181,16 @@
File[] files = get(bsn, range);
if (files.length >= 0) {
switch (strategy) {
- case LOWEST:
- return files[0];
- case HIGHEST:
- return files[files.length - 1];
+ case LOWEST :
+ return files[0];
+ case HIGHEST :
+ return files[files.length - 1];
}
}
return null;
}
- public void setRoot( File f ) {
+ public void setRoot(File f) {
root = f;
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/PomFromManifest.java b/bundleplugin/src/main/java/aQute/bnd/maven/PomFromManifest.java
index 5b8c149..782c282 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/PomFromManifest.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/PomFromManifest.java
@@ -70,11 +70,13 @@
this.manifest = manifest;
}
- @Override public long lastModified() {
+ @Override
+ public long lastModified() {
return 0;
}
- @Override public void write(OutputStream out) throws IOException {
+ @Override
+ public void write(OutputStream out) throws IOException {
PrintWriter ps = IO.writer(out);
String name = manifest.getMainAttributes().getValue(Analyzer.BUNDLE_NAME);
@@ -148,8 +150,7 @@
String xname = email;
String organization = null;
- Matcher m = Pattern.compile("([^@]+)@([\\d\\w\\-_\\.]+)\\.([\\d\\w\\-_\\.]+)")
- .matcher(email);
+ Matcher m = Pattern.compile("([^@]+)@([\\d\\w\\-_\\.]+)\\.([\\d\\w\\-_\\.]+)").matcher(email);
if (m.matches()) {
xname = m.group(1);
organization = m.group(2);
@@ -167,8 +168,7 @@
Tag ls = new Tag(project, "licenses");
Parameters map = Processor.parseHeader(licenses, null);
- for (Iterator<Entry<String, Attrs>> e = map.entrySet().iterator(); e
- .hasNext();) {
+ for (Iterator<Entry<String,Attrs>> e = map.entrySet().iterator(); e.hasNext();) {
// Bundle-License:
// http://www.opensource.org/licenses/apache2.0.php; \
@@ -182,9 +182,9 @@
// <distribution>repo</distribution>
// </license>
- Entry<String, Attrs> entry = e.next();
+ Entry<String,Attrs> entry = e.next();
Tag l = new Tag(ls, "license");
- Map<String, String> values = entry.getValue();
+ Map<String,String> values = entry.getValue();
String url = entry.getKey();
if (values.containsKey("description"))
@@ -209,8 +209,7 @@
* @param tag
* @param object
*/
- private Tag tagFromMap(Tag parent, Map<String, String> values, String string, String tag,
- String object) {
+ private Tag tagFromMap(Tag parent, Map<String,String> values, String string, String tag, String object) {
String value = values.get(string);
if (value == null)
value = object;
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/PomParser.java b/bundleplugin/src/main/java/aQute/bnd/maven/PomParser.java
index e529141..12c2edc 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/PomParser.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/PomParser.java
@@ -12,22 +12,21 @@
import aQute.lib.osgi.*;
/**
- * Provides a way to parse a maven pom as properties.
- *
- * This provides most of the maven elements as properties. It also
- * provides pom.scope.[compile|test|runtime|provided|system] properties
- * that can be appended to the build and run path. That is, they are
- * in the correct format for this.
+ * Provides a way to parse a maven pom as properties. This provides most of the
+ * maven elements as properties. It also provides
+ * pom.scope.[compile|test|runtime|provided|system] properties that can be
+ * appended to the build and run path. That is, they are in the correct format
+ * for this.
*/
public class PomParser extends Processor {
static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
static XPathFactory xpathf = XPathFactory.newInstance();
static Set<String> multiple = new HashSet<String>();
- static Set<String> skip = new HashSet<String>();
+ static Set<String> skip = new HashSet<String>();
static {
dbf.setNamespaceAware(false);
-
+
// Set all elements that need enumeration of their elements
// these will not use the name of the subelement but instead
// they use an index from 0..n
@@ -46,7 +45,7 @@
skip.add("dependencies");
skip.add("reporting");
skip.add("extensions");
-
+
}
public Properties getProperties(File pom) throws Exception {
@@ -58,7 +57,7 @@
// Check if there is a parent pom
String relativePath = xpath.evaluate("project/parent/relativePath", doc);
- if (relativePath != null && relativePath.length()!=0) {
+ if (relativePath != null && relativePath.length() != 0) {
File parentPom = IO.getFile(pom.getParentFile(), relativePath);
if (parentPom.isFile()) {
Properties parentProps = getProperties(parentPom);
@@ -71,15 +70,16 @@
Element e = doc.getDocumentElement();
traverse("pom", e, p);
- String scopes[] = { "provided", "runtime", "test", "system" };
+ String scopes[] = {
+ "provided", "runtime", "test", "system"
+ };
NodeList set = (NodeList) xpath.evaluate("//dependency[not(scope) or scope='compile']", doc,
XPathConstants.NODESET);
if (set.getLength() != 0)
p.put("pom.scope.compile", toBsn(set));
for (String scope : scopes) {
- set = (NodeList) xpath.evaluate("//dependency[scope='" + scope + "']", doc,
- XPathConstants.NODESET);
+ set = (NodeList) xpath.evaluate("//dependency[scope='" + scope + "']", doc, XPathConstants.NODESET);
if (set.getLength() != 0)
p.put("pom.scope." + scope, toBsn(set));
}
@@ -98,9 +98,9 @@
sb.append(xpath.evaluate("groupId", child));
sb.append(".");
sb.append(xpath.evaluate("artifactId", child));
- if (version != null && version.trim().length()!=0) {
+ if (version != null && version.trim().length() != 0) {
sb.append(";version=");
- sb.append( Analyzer.cleanupVersion(version));
+ sb.append(Analyzer.cleanupVersion(version));
}
del = ", ";
}
@@ -108,15 +108,17 @@
}
/**
- * The maven POM is quite straightforward, it is basically a structured property file.
+ * The maven POM is quite straightforward, it is basically a structured
+ * property file.
+ *
* @param name
* @param parent
* @param p
*/
static void traverse(String name, Node parent, Properties p) {
- if ( skip.contains(parent.getNodeName()))
+ if (skip.contains(parent.getNodeName()))
return;
-
+
NodeList children = parent.getChildNodes();
if (multiple.contains(parent.getNodeName())) {
int n = 0;
@@ -132,7 +134,7 @@
Node child = children.item(i);
if (child instanceof Text) {
String value = child.getNodeValue().trim();
- if (value.length()!=0) {
+ if (value.length() != 0) {
p.put(name, value);
}
} else {
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/PomResource.java b/bundleplugin/src/main/java/aQute/bnd/maven/PomResource.java
index 416062d..b722d0f 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/PomResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/PomResource.java
@@ -13,18 +13,20 @@
public class PomResource extends WriteResource {
final Manifest manifest;
- private Map<String, String> scm;
+ private Map<String,String> scm;
final static Pattern NAME_URL = Pattern.compile("(.*)(http://.*)");
public PomResource(Manifest manifest) {
this.manifest = manifest;
}
- @Override public long lastModified() {
+ @Override
+ public long lastModified() {
return 0;
}
- @Override public void write(OutputStream out) throws IOException {
+ @Override
+ public void write(OutputStream out) throws IOException {
PrintWriter ps = IO.writer(out);
String name = manifest.getMainAttributes().getValue(Analyzer.BUNDLE_NAME);
@@ -80,7 +82,7 @@
if (scm != null) {
Tag scm = new Tag(project, "scm");
- for (Map.Entry<String, String> e : this.scm.entrySet()) {
+ for (Map.Entry<String,String> e : this.scm.entrySet()) {
new Tag(scm, e.getKey()).addContent(e.getValue());
}
}
@@ -103,8 +105,7 @@
Tag ls = new Tag(project, "licenses");
Parameters map = Processor.parseHeader(licenses, null);
- for (Iterator<Entry<String, Attrs>> e = map.entrySet().iterator(); e
- .hasNext();) {
+ for (Iterator<Entry<String,Attrs>> e = map.entrySet().iterator(); e.hasNext();) {
// Bundle-License:
// http://www.opensource.org/licenses/apache2.0.php; \
@@ -118,9 +119,9 @@
// <distribution>repo</distribution>
// </license>
- Entry<String, Attrs> entry = e.next();
+ Entry<String,Attrs> entry = e.next();
Tag l = new Tag(ls, "license");
- Map<String, String> values = entry.getValue();
+ Map<String,String> values = entry.getValue();
String url = entry.getKey();
if (values.containsKey("description"))
@@ -145,8 +146,7 @@
* @param tag
* @param object
*/
- private Tag tagFromMap(Tag parent, Map<String, String> values, String string, String tag,
- String object) {
+ private Tag tagFromMap(Tag parent, Map<String,String> values, String string, String tag, String object) {
String value = values.get(string);
if (value == null)
value = object;
@@ -156,7 +156,7 @@
return parent;
}
- public void setProperties(Map<String, String> scm) {
+ public void setProperties(Map<String,String> scm) {
this.scm = scm;
}
}
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 02449fa..5787e29 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/CachedPom.java
@@ -4,7 +4,7 @@
import java.net.*;
public class CachedPom extends Pom {
- final MavenEntry maven;
+ final MavenEntry maven;
CachedPom(MavenEntry mavenEntry, URI repo) throws Exception {
super(mavenEntry.maven, mavenEntry.getPomFile(), repo);
diff --git a/bundleplugin/src/main/java/aQute/bnd/maven/support/Maven.java b/bundleplugin/src/main/java/aQute/bnd/maven/support/Maven.java
index 2124a05..416f255 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/Maven.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/Maven.java
@@ -12,25 +12,27 @@
*/
public class Maven {
final File userHome = new File(System.getProperty("user.home"));
- final Map<String, MavenEntry> entries = new ConcurrentHashMap<String, MavenEntry>();
- final static String[] ALGORITHMS = { "md5", "sha1" };
+ final Map<String,MavenEntry> entries = new ConcurrentHashMap<String,MavenEntry>();
+ final static String[] ALGORITHMS = {
+ "md5", "sha1"
+ };
boolean usecache = false;
final Executor executor;
File m2 = new File(userHome, ".m2");
File repository = new File(m2, "repository");
public Maven(Executor executor) {
- if ( executor == null)
+ if (executor == null)
this.executor = Executors.newCachedThreadPool();
else
this.executor = executor;
}
-
- //http://repo1.maven.org/maven2/junit/junit/maven-metadata.xml
-
- static Pattern MAVEN_RANGE = Pattern.compile("(\\[|\\()(.+)(,(.+))(\\]|\\))");
- public CachedPom getPom(String groupId, String artifactId, String version, URI... extra)
- throws Exception {
+
+ // http://repo1.maven.org/maven2/junit/junit/maven-metadata.xml
+
+ static Pattern MAVEN_RANGE = Pattern.compile("(\\[|\\()(.+)(,(.+))(\\]|\\))");
+
+ public CachedPom getPom(String groupId, String artifactId, String version, URI... extra) throws Exception {
MavenEntry entry = getEntry(groupId, artifactId, version);
return entry.getPom(extra);
}
@@ -59,8 +61,7 @@
}
private String path(String groupId, String artifactId, String version) {
- return groupId.replace('.', '/') + '/' + artifactId + '/' + version + "/" + artifactId
- + "-" + version;
+ return groupId.replace('.', '/') + '/' + artifactId + '/' + version + "/" + artifactId + "-" + version;
}
public void schedule(Runnable runnable) {
@@ -82,7 +83,7 @@
public void setM2(File dir) {
this.m2 = dir;
- this.repository = new File(dir,"repository");
+ this.repository = new File(dir, "repository");
}
}
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 60ebb63..fd4459a 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenEntry.java
@@ -13,7 +13,6 @@
/**
* An entry (a group/artifact) in the maven cache in the .m2/repository
* directory. It provides methods to get the pom and the artifact.
- *
*/
public class MavenEntry implements Closeable {
final Maven maven;
@@ -21,7 +20,7 @@
final File dir;
final String path;
final DirectoryLock lock;
- final Map<URI, CachedPom> poms = new HashMap<URI, CachedPom>();
+ final Map<URI,CachedPom> poms = new HashMap<URI,CachedPom>();
final File pomFile;
final File artifactFile;
final String pomPath;
@@ -57,7 +56,6 @@
* @param urls
* The allowed URLs
* @return a CachedPom for this maven entry
- *
* @throws Exception
* If something goes haywire
*/
@@ -124,7 +122,8 @@
}
}
return null;
- } finally {
+ }
+ finally {
saveProperties();
// lock.release();
}
@@ -143,12 +142,13 @@
private boolean download(URI repo, String path) throws MalformedURLException {
try {
URL url = toURL(repo, path);
- System.err.println("Downloading " + repo + " path " + path + " url " + url);
+ System.err.println("Downloading " + repo + " path " + path + " url " + url);
File file = new File(root, path);
IO.copy(url.openStream(), file);
- System.err.println("Downloaded " + url);
+ System.err.println("Downloaded " + url);
return true;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
System.err.println("debug: " + e);
return false;
}
@@ -162,7 +162,6 @@
* @param path
* The path in the directory + url
* @return a URL that points to the file in the repo
- *
* @throws MalformedURLException
*/
URL toURL(URI base, String path) throws MalformedURLException {
@@ -181,8 +180,7 @@
* @return true if valid
*/
private boolean isValid() {
- return pomFile.isFile() && pomFile.length() > 100 && artifactFile.isFile()
- && artifactFile.length() > 100;
+ return pomFile.isFile() && pomFile.length() > 100 && artifactFile.isFile() && artifactFile.length() > 100;
}
/**
@@ -211,9 +209,11 @@
try {
in = new FileInputStream(props);
properties.load(in);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
// we ignore for now, will handle it on safe
- } finally {
+ }
+ finally {
IO.close(in);
}
}
@@ -238,7 +238,8 @@
FileOutputStream fout = new FileOutputStream(propertiesFile);
try {
properties.store(fout, "");
- } finally {
+ }
+ finally {
properties = null;
propertiesChanged = false;
fout.close();
@@ -298,11 +299,13 @@
File digestFile = new File(root, digestPath);
final MessageDigest md = MessageDigest.getInstance(algorithm);
IO.copy(actualFile, new OutputStream() {
- @Override public void write(int c) throws IOException {
+ @Override
+ public void write(int c) throws IOException {
md.update((byte) c);
}
- @Override public void write(byte[] buffer, int offset, int length) {
+ @Override
+ public void write(byte[] buffer, int offset, int length) {
md.update(buffer, offset, length);
}
});
@@ -319,7 +322,7 @@
}
public File getArtifact() throws Exception {
- if (artifact == null )
+ if (artifact == null)
return artifactFile;
return artifact.get();
}
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 a9f0ba2..d1c0472 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/MavenRemoteRepository.java
@@ -21,23 +21,24 @@
if (f == null)
return null;
- return new File[] { f };
+ return new File[] {
+ f
+ };
}
- public File get(String bsn, String version, Strategy strategy, Map<String, String> properties)
- throws Exception {
+ public File get(String bsn, String version, Strategy strategy, Map<String,String> properties) throws Exception {
String groupId = null;
-
+
if (properties != null)
groupId = properties.get("groupId");
-
+
if (groupId == null) {
int n = bsn.indexOf('+');
- if ( n < 0)
+ if (n < 0)
return null;
-
- groupId = bsn.substring(0,n);
- bsn = bsn.substring(n+1);
+
+ groupId = bsn.substring(0, n);
+ bsn = bsn.substring(n + 1);
}
String artifactId = bsn;
@@ -59,15 +60,16 @@
try {
action = Pom.Scope.valueOf(value);
return pom.getLibrary(action, repositories);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
return pom.getArtifact();
}
}
public Maven getMaven() {
- if ( maven != null)
+ if (maven != null)
return maven;
-
+
maven = registry.getPlugin(Maven.class);
return maven;
}
@@ -96,7 +98,7 @@
repositories = urls;
}
- public void setProperties(Map<String, String> map) {
+ public void setProperties(Map<String,String> map) {
String repoString = map.get("repositories");
if (repoString != null) {
String[] repos = repoString.split("\\s*,\\s*");
@@ -105,10 +107,11 @@
for (String repo : repos) {
try {
URI uri = new URI(repo);
- if ( !uri.isAbsolute())
- uri = IO.getFile( new File(""),repo).toURI();
+ if (!uri.isAbsolute())
+ uri = IO.getFile(new File(""), repo).toURI();
repositories[n++] = uri;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
if (reporter != null)
reporter.error("Invalid repository %s for maven plugin, %s", repo, e);
}
@@ -129,9 +132,9 @@
}
public String getLocation() {
- if ( repositories == null || repositories.length==0)
+ if (repositories == null || repositories.length == 0)
return "maven central";
-
- return Arrays.toString(repositories);
+
+ return Arrays.toString(repositories);
}
}
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 30a3378..0055d19 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/Pom.java
@@ -18,19 +18,19 @@
static {
dbf.setNamespaceAware(false);
}
-
+
public enum Scope {
compile, runtime, system, import_, provided, test, ;
-
-// private boolean includes(Scope other) {
-// if (other == this) return true;
-// switch (this) {
-// case compile:
-// return other == provided || other == test;
-// default:
-// return false;
-// }
-// }
+
+ // private boolean includes(Scope other) {
+ // if (other == this) return true;
+ // switch (this) {
+ // case compile:
+ // return other == provided || other == test;
+ // default:
+ // return false;
+ // }
+ // }
}
final Maven maven;
@@ -41,7 +41,7 @@
String version;
List<Dependency> dependencies = new ArrayList<Dependency>();
File pomFile;
- String description="";
+ String description = "";
String name;
public String getDescription() {
@@ -88,6 +88,7 @@
public Pom getPom() throws Exception {
return maven.getPom(groupId, artifactId, version);
}
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -129,16 +130,15 @@
this.artifactId = replace(xp.evaluate("project/artifactId", doc).trim(), this.artifactId);
this.groupId = replace(xp.evaluate("project/groupId", doc).trim(), this.groupId);
this.version = replace(xp.evaluate("project/version", doc).trim(), this.version);
-
+
String nextDescription = xp.evaluate("project/description", doc).trim();
- if ( this.description.length() != 0 && nextDescription.length() != 0)
+ if (this.description.length() != 0 && nextDescription.length() != 0)
this.description += "\n";
this.description += replace(nextDescription);
-
+
this.name = replace(xp.evaluate("project/name", doc).trim(), this.name);
- NodeList list = (NodeList) xp.evaluate("project/dependencies/dependency", doc,
- XPathConstants.NODESET);
+ NodeList list = (NodeList) xp.evaluate("project/dependencies/dependency", doc, XPathConstants.NODESET);
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
Dependency dep = new Dependency();
@@ -157,8 +157,7 @@
dep.version = replace(xp.evaluate("version", node).trim());
dependencies.add(dep);
- NodeList exclusions = (NodeList) xp
- .evaluate("exclusions", node, XPathConstants.NODESET);
+ NodeList exclusions = (NodeList) xp.evaluate("exclusions", node, XPathConstants.NODESET);
for (int e = 0; e < exclusions.getLength(); e++) {
Node exc = exclusions.item(e);
String exclGroupId = xp.evaluate("groupId", exc).trim();
@@ -170,9 +169,9 @@
}
private String replace(String key, String dflt) {
- if ( key == null || key.length() == 0)
+ if (key == null || key.length() == 0)
return dflt;
-
+
return replace(key);
}
@@ -185,7 +184,7 @@
}
public String getVersion() throws Exception {
- if ( version == null)
+ if (version == null)
return "<not set>";
return replace(version);
}
@@ -205,8 +204,7 @@
final Dependency dependency;
public boolean excludes(String name) {
- return dependency.exclusions.contains(name) && previous != null
- && previous.excludes(name);
+ return dependency.exclusions.contains(name) && previous != null && previous.excludes(name);
}
}
@@ -229,7 +227,7 @@
if (rover.excludes(name) || dep.optional)
continue;
-
+
if (dep.scope == scope && !dep.optional) {
try {
Pom sub = maven.getPom(groupId, artifactId, version, urls);
@@ -240,35 +238,35 @@
queue.add(new Rover(rover, subd));
}
}
- } else
- if (rover.previous != null)
- System.err.println("Cannot find " + dep + " from "
- + rover.previous.dependency);
- else
- System.err.println("Cannot find " + dep + " from top");
- } catch (Exception e) {
+ } else if (rover.previous != null)
+ System.err.println("Cannot find " + dep + " from " + rover.previous.dependency);
+ else
+ System.err.println("Cannot find " + dep + " from top");
+ }
+ catch (Exception e) {
if (rover.previous != null)
- System.err.println("Cannot find " + dep + " from "
- + rover.previous.dependency);
+ System.err.println("Cannot find " + dep + " from " + rover.previous.dependency);
else
System.err.println("Cannot find " + dep + " from top");
-// boolean include = false;
-// if (dep.scope == Scope.compile) {
-// include = true;
-// } else if (dep.scope == Scope.test) {
-// include = rover.previous == null && (action == Action.compile || action == Action.test);
-// } else if (dep.scope == Scope.runtime) {
-// include = action == Action.run;
-// }
-// if (include) {
-// Pom sub = maven.getPom(groupId, artifactId, version, urls);
-// if (!result.contains(sub)) {
-// result.add(sub);
-// for (Dependency subd : sub.dependencies) {
-// queue.add(new Rover(rover, subd));
-// }
-
+ // boolean include = false;
+ // if (dep.scope == Scope.compile) {
+ // include = true;
+ // } else if (dep.scope == Scope.test) {
+ // include = rover.previous == null && (action ==
+ // Action.compile || action == Action.test);
+ // } else if (dep.scope == Scope.runtime) {
+ // include = action == Action.run;
+ // }
+ // if (include) {
+ // Pom sub = maven.getPom(groupId, artifactId, version,
+ // urls);
+ // if (!result.contains(sub)) {
+ // result.add(sub);
+ // for (Dependency subd : sub.dependencies) {
+ // queue.add(new Rover(rover, subd));
+ // }
+
}
}
}
@@ -281,8 +279,7 @@
return "null";
in = in.trim();
- if ("${pom.version}".equals(in) || "${version}".equals(in)
- || "${project.version}".equals(in))
+ if ("${pom.version}".equals(in) || "${version}".equals(in) || "${project.version}".equals(in))
return version;
if ("${basedir}".equals(in))
@@ -318,7 +315,8 @@
for (Pom dep : getDependencies(action, repositories)) {
doEntry(writer, dep);
}
- } finally {
+ }
+ finally {
writer.close();
}
return file;
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 069acb9..6a8130c 100644
--- a/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java
+++ b/bundleplugin/src/main/java/aQute/bnd/maven/support/ProjectPom.java
@@ -13,20 +13,21 @@
public class ProjectPom extends Pom {
- final List<URI> repositories = new ArrayList<URI>();
+ final List<URI> repositories = new ArrayList<URI>();
final Properties properties = new Properties();
- String packaging;
- String url;
-
+ String packaging;
+ String url;
+
ProjectPom(Maven maven, File pomFile) throws Exception {
super(maven, pomFile, pomFile.toURI());
}
- @Override protected void parse(Document doc, XPath xp) throws Exception {
+ @Override
+ protected void parse(Document doc, XPath xp) throws Exception {
packaging = xp.evaluate("project/packaging", doc);
url = xp.evaluate("project/url", doc);
-
+
Node parent = (Node) xp.evaluate("project/parent", doc, XPathConstants.NODE);
if (parent != null && parent.hasChildNodes()) {
File parentFile = IO.getFile(getPomFile().getParentFile(), "../pom.xml");
@@ -35,20 +36,20 @@
String parentArtifactId = xp.evaluate("artifactId", parent).trim();
String parentVersion = xp.evaluate("version", parent).trim();
String parentPath = xp.evaluate("relativePath", parent).trim();
- if (parentPath != null && parentPath.length()!=0) {
+ if (parentPath != null && parentPath.length() != 0) {
parentFile = IO.getFile(getPomFile().getParentFile(), parentPath);
}
if (parentFile.isFile()) {
ProjectPom parentPom = new ProjectPom(maven, parentFile);
parentPom.parse();
dependencies.addAll(parentPom.dependencies);
- for ( Enumeration<?> e = parentPom.properties.propertyNames(); e.hasMoreElements(); ) {
+ for (Enumeration< ? > e = parentPom.properties.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
- if ( ! properties.contains(key))
+ if (!properties.contains(key))
properties.put(key, parentPom.properties.get(key));
}
repositories.addAll(parentPom.repositories);
-
+
setNames(parentPom);
} else {
// This seems to be a bit bizarre, extending an external pom?
@@ -58,42 +59,40 @@
}
}
- NodeList propNodes = (NodeList) xp.evaluate("project/properties/*", doc,
- XPathConstants.NODESET);
+ NodeList propNodes = (NodeList) xp.evaluate("project/properties/*", doc, XPathConstants.NODESET);
for (int i = 0; i < propNodes.getLength(); i++) {
Node node = propNodes.item(i);
String key = node.getNodeName();
String value = node.getTextContent();
- if ( key == null || key.length()==0)
+ if (key == null || key.length() == 0)
throw new IllegalArgumentException("Pom has an empty or null key");
- if ( value == null || value.length()==0)
+ if (value == null || value.length() == 0)
throw new IllegalArgumentException("Pom has an empty or null value for property " + key);
properties.setProperty(key, value.trim());
}
- NodeList repos = (NodeList) xp.evaluate("project/repositories/repository/url", doc,
- XPathConstants.NODESET);
+ NodeList repos = (NodeList) xp.evaluate("project/repositories/repository/url", doc, XPathConstants.NODESET);
for (int i = 0; i < repos.getLength(); i++) {
Node node = repos.item(i);
String URIString = node.getTextContent().trim();
URI uri = new URI(URIString);
- if ( uri.getScheme() ==null )
- uri = IO.getFile(pomFile.getParentFile(),URIString).toURI();
+ if (uri.getScheme() == null)
+ uri = IO.getFile(pomFile.getParentFile(), URIString).toURI();
repositories.add(uri);
}
super.parse(doc, xp);
}
-// private void print(Node node, String indent) {
-// System.err.print(indent);
-// System.err.println(node.getNodeName());
-// Node rover = node.getFirstChild();
-// while ( rover != null) {
-// print( rover, indent+" ");
-// rover = rover.getNextSibling();
-// }
-// }
+ // private void print(Node node, String indent) {
+ // System.err.print(indent);
+ // System.err.println(node.getNodeName());
+ // Node rover = node.getFirstChild();
+ // while ( rover != null) {
+ // print( rover, indent+" ");
+ // rover = rover.getNextSibling();
+ // }
+ // }
/**
* @param parentArtifactId
@@ -102,17 +101,17 @@
* @throws Exception
*/
private void setNames(Pom pom) throws Exception {
- if (artifactId == null || artifactId.length()==0)
+ if (artifactId == null || artifactId.length() == 0)
artifactId = pom.getArtifactId();
- if (groupId == null || groupId.length()==0)
+ if (groupId == null || groupId.length() == 0)
groupId = pom.getGroupId();
- if (version == null || version.length()==0)
+ if (version == null || version.length() == 0)
version = pom.getVersion();
- if ( description == null )
+ if (description == null)
description = pom.getDescription();
else
description = pom.getDescription() + "\n" + description;
-
+
}
static class Rover {
@@ -126,8 +125,7 @@
final Dependency dependency;
public boolean excludes(String name) {
- return dependency.exclusions.contains(name) && previous != null
- && previous.excludes(name);
+ return dependency.exclusions.contains(name) && previous != null && previous.excludes(name);
}
}
@@ -140,7 +138,7 @@
protected String replace(String in) {
System.err.println("Replce: " + in);
- if ( in == null) {
+ if (in == null) {
System.err.println("null??");
}
Matcher matcher = MACRO.matcher(in);
@@ -148,18 +146,18 @@
StringBuilder sb = new StringBuilder();
while (matcher.find()) {
int n = matcher.start();
- sb.append( in, last, n);
+ sb.append(in, last, n);
String replacement = get(matcher.group(2));
- if ( replacement == null )
- sb.append( matcher.group(1));
+ if (replacement == null)
+ sb.append(matcher.group(1));
else
- sb.append( replacement );
+ sb.append(replacement);
last = matcher.end();
}
- if ( last == 0)
+ if (last == 0)
return in;
-
- sb.append( in, last, in.length());
+
+ sb.append(in, last, in.length());
return sb.toString();
}
@@ -170,14 +168,14 @@
return groupId;
if (key.equals("pom.version"))
return version;
-
+
if (key.equals("pom.name"))
return name;
-
+
String prop = properties.getProperty(key);
- if ( prop != null )
+ if (prop != null)
return prop;
-
+
return System.getProperty(key);
}
@@ -198,7 +196,8 @@
return replace(s);
}
- @Override public File getArtifact() throws Exception {
+ @Override
+ public File getArtifact() throws Exception {
return null;
}
}