You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2012/06/15 15:28:02 UTC
svn commit: r1350613 [8/14] - in
/felix/trunk/bundleplugin/src/main/java/aQute: bnd/annotation/
bnd/annotation/component/ bnd/annotation/metatype/ bnd/build/
bnd/compatibility/ bnd/component/ bnd/differ/ bnd/help/ bnd/make/
bnd/make/calltree/ bnd/make/...
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java Fri Jun 15 13:27:53 2012
@@ -42,6 +42,7 @@ import aQute.lib.osgi.Descriptors.TypeRe
import aQute.libg.cryptography.*;
import aQute.libg.generics.*;
import aQute.libg.header.*;
+import aQute.libg.reporter.*;
import aQute.libg.version.Version;
public class Analyzer extends Processor {
@@ -57,30 +58,31 @@ public class Analyzer extends Processor
private TypeRef activator;
// Global parameters
- private final MultiMap<PackageRef, PackageRef> uses = new MultiMap<PackageRef, PackageRef>(
- PackageRef.class,
- PackageRef.class,
+ private final MultiMap<PackageRef,PackageRef> uses = new MultiMap<PackageRef,PackageRef>(
+ PackageRef.class, PackageRef.class,
true);
private final Packages classpathExports = new Packages();
private final Descriptors descriptors = new Descriptors();
private final List<Jar> classpath = list();
- private final Map<TypeRef, Clazz> classspace = map();
- private final Map<TypeRef, Clazz> importedClassesCache = map();
+ private final Map<TypeRef,Clazz> classspace = map();
+ private final Map<TypeRef,Clazz> importedClassesCache = map();
private boolean analyzed = false;
private boolean diagnostics = false;
private boolean inited = false;
+ final protected AnalyzerMessages msgs = ReporterMessages.base(this,
+ AnalyzerMessages.class);
public Analyzer(Processor parent) {
super(parent);
}
- public Analyzer() {
- }
+ public Analyzer() {}
/**
* Specifically for Maven
*
- * @param properties the properties
+ * @param properties
+ * the properties
*/
public static Properties getManifest(File dirOrJar) throws Exception {
@@ -280,7 +282,6 @@ public class Analyzer extends Processor
}
/**
- *
* @return
*/
boolean isResourceOnly() {
@@ -306,9 +307,8 @@ public class Analyzer extends Processor
boolean noExtraHeaders = "true".equalsIgnoreCase(getProperty(NOEXTRAHEADERS));
if (!noExtraHeaders) {
- main.putValue(CREATED_BY,
- System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
- + ")");
+ main.putValue(CREATED_BY, System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
+ + ")");
main.putValue(TOOL, "Bnd-" + getBndVersion());
main.putValue(BND_LASTMODIFIED, "" + System.currentTimeMillis());
}
@@ -323,8 +323,7 @@ public class Analyzer extends Processor
// Remove all the Java packages from the imports
if (!imports.isEmpty()) {
main.putValue(IMPORT_PACKAGE, printClauses(imports));
- }
- else {
+ } else {
main.remove(IMPORT_PACKAGE);
}
@@ -360,8 +359,7 @@ public class Analyzer extends Processor
continue;
}
- if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE)
- || header.equals(IMPORT_PACKAGE))
+ if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE) || header.equals(IMPORT_PACKAGE))
continue;
if (header.equalsIgnoreCase("Name")) {
@@ -374,14 +372,12 @@ public class Analyzer extends Processor
if (value != null && main.getValue(header) == null) {
if (value.trim().length() == 0)
main.remove(header);
+ else if (value.trim().equals(EMPTY_HEADER))
+ main.putValue(header, "");
else
- if (value.trim().equals(EMPTY_HEADER))
- main.putValue(header, "");
- else
- main.putValue(header, value);
+ main.putValue(header, value);
}
- }
- else {
+ } else {
// TODO should we report?
}
}
@@ -424,9 +420,7 @@ public class Analyzer extends Processor
/**
* Parse the namesection as instructions and then match them against the
- * current set of resources
- *
- * For example:
+ * current set of resources For example:
*
* <pre>
* -namesection: *;baz=true, abc/def/bar/X.class=3
@@ -435,7 +429,6 @@ public class Analyzer extends Processor
* The raw value of {@link Constants#NAMESECTION} is used but the values of
* the attributes are replaced where @ is set to the resource name. This
* allows macro to operate on the resource
- *
*/
private void doNamesection(Jar dot, Manifest manifest) {
@@ -451,7 +444,7 @@ public class Analyzer extends Processor
// to the manifest for the given resource name. Then add all
// attributes from the instruction to that name section.
//
- for (Map.Entry<Instruction, Attrs> instr : instructions.entrySet()) {
+ for (Map.Entry<Instruction,Attrs> instr : instructions.entrySet()) {
boolean matched = false;
// For each instruction
@@ -480,7 +473,7 @@ public class Analyzer extends Processor
// name section
//
- for (Map.Entry<String, String> property : instr.getValue().entrySet()) {
+ for (Map.Entry<String,String> property : instr.getValue().entrySet()) {
setProperty("@", path);
try {
String processed = getReplacer().process(property.getValue());
@@ -496,8 +489,7 @@ public class Analyzer extends Processor
}
if (!matched && resources.size() > 0)
- warning("The instruction %s in %s did not match any resources", instr.getKey(),
- NAMESECTION);
+ warning("The instruction %s in %s did not match any resources", instr.getKey(), NAMESECTION);
}
}
@@ -532,10 +524,8 @@ public class Analyzer extends Processor
manifest.getEntries().put(path, attrs);
}
attrs.putValue(name, getProperty(header));
- }
- else {
- warning("Invalid header (starts with @ but does not seem to be for the Name section): %s",
- header);
+ } else {
+ warning("Invalid header (starts with @ but does not seem to be for the Name section): %s", header);
}
}
@@ -554,13 +544,11 @@ public class Analyzer extends Processor
String projectName = getBase().getName();
if (value == null || value.equals("bnd.bnd")) {
value = projectName;
+ } else if (value.endsWith(".bnd")) {
+ value = value.substring(0, value.length() - 4);
+ if (!value.startsWith(getBase().getName()))
+ value = projectName + "." + value;
}
- else
- if (value.endsWith(".bnd")) {
- value = value.substring(0, value.length() - 4);
- if (!value.startsWith(getBase().getName()))
- value = projectName + "." + value;
- }
}
if (value == null)
@@ -579,13 +567,14 @@ public class Analyzer extends Processor
/**
* Calculate an export header solely based on the contents of a JAR file
*
- * @param bundle The jar file to analyze
+ * @param bundle
+ * The jar file to analyze
* @return
*/
public String calculateExportsFromContents(Jar bundle) {
String ddel = "";
StringBuilder sb = new StringBuilder();
- Map<String, Map<String, Resource>> map = bundle.getDirectories();
+ Map<String,Map<String,Resource>> map = bundle.getDirectories();
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String directory = i.next();
if (directory.equals("META-INF") || directory.startsWith("META-INF/"))
@@ -644,7 +633,7 @@ public class Analyzer extends Processor
return unreachable;
}
- public MultiMap<PackageRef, PackageRef> getUses() {
+ public MultiMap<PackageRef,PackageRef> getUses() {
return uses;
}
@@ -663,6 +652,7 @@ public class Analyzer extends Processor
return Long.parseLong(time);
}
catch (Exception e) {
+ // Ignore
}
return 0;
}
@@ -693,7 +683,8 @@ public class Analyzer extends Processor
* Merge the existing manifest with the instructions but do not override
* existing properties.
*
- * @param manifest The manifest to merge with
+ * @param manifest
+ * The manifest to merge with
* @throws IOException
*/
public void mergeManifest(Manifest manifest) throws IOException {
@@ -729,8 +720,7 @@ public class Analyzer extends Processor
if (classpath[i].exists()) {
Jar current = new Jar(classpath[i]);
list.add(current);
- }
- else {
+ } else {
error("Missing file on classpath: %s", classpath[i]);
}
}
@@ -799,8 +789,10 @@ public class Analyzer extends Processor
* Try to get a Jar from a file name/path or a url, or in last resort from
* the classpath name part of their files.
*
- * @param name URL or filename relative to the base
- * @param from Message identifying the caller for errors
+ * @param name
+ * URL or filename relative to the base
+ * @param from
+ * Message identifying the caller for errors
* @return null or a Jar with the contents for the name
*/
Jar getJarFromName(String name, String from) {
@@ -856,15 +848,13 @@ public class Analyzer extends Processor
}
/**
- *
* @param manifests
* @throws Exception
*/
- private void merge(Manifest result, Manifest old) throws IOException {
+ private void merge(Manifest result, Manifest old) {
if (old != null) {
- for (Iterator<Map.Entry<Object, Object>> e = old.getMainAttributes().entrySet()
- .iterator(); e.hasNext();) {
- Map.Entry<Object, Object> entry = e.next();
+ for (Iterator<Map.Entry<Object,Object>> e = old.getMainAttributes().entrySet().iterator(); e.hasNext();) {
+ Map.Entry<Object,Object> entry = e.next();
Attributes.Name name = (Attributes.Name) entry.getKey();
String value = (String) entry.getValue();
if (name.toString().equalsIgnoreCase("Created-By"))
@@ -874,11 +864,10 @@ public class Analyzer extends Processor
}
// do not overwrite existing entries
- Map<String, Attributes> oldEntries = old.getEntries();
- Map<String, Attributes> newEntries = result.getEntries();
- for (Iterator<Map.Entry<String, Attributes>> e = oldEntries.entrySet().iterator(); e
- .hasNext();) {
- Map.Entry<String, Attributes> entry = e.next();
+ Map<String,Attributes> oldEntries = old.getEntries();
+ Map<String,Attributes> newEntries = result.getEntries();
+ for (Iterator<Map.Entry<String,Attributes>> e = oldEntries.entrySet().iterator(); e.hasNext();) {
+ Map.Entry<String,Attributes> entry = e.next();
if (!newEntries.containsKey(entry.getKey())) {
newEntries.put(entry.getKey(), entry.getValue());
}
@@ -891,7 +880,8 @@ public class Analyzer extends Processor
* not using an invalid case. We do allow this to set headers that should
* not be processed by us but should be used by the framework.
*
- * @param properties Properties to verify.
+ * @param properties
+ * Properties to verify.
*/
void verifyManifestHeadersCase(Properties properties) {
@@ -910,26 +900,21 @@ public class Analyzer extends Processor
/**
* We will add all exports to the imports unless there is a -noimport
* directive specified on an export. This directive is skipped for the
- * manifest.
- *
- * We also remove any version parameter so that augmentImports can do the
- * version policy.
- *
- * The following method is really tricky and evolved over time. Coming from
- * the original background of OSGi, it was a weird idea for me to have a
- * public package that should not be substitutable. I was so much convinced
- * that this was the right rule that I rücksichtlos imported them all. Alas,
- * the real world was more subtle than that. It turns out that it is not a
- * good idea to always import. First, there must be a need to import, i.e.
- * there must be a contained package that refers to the exported package for
- * it to make use importing that package. Second, if an exported package
- * refers to an internal package than it should not be imported.
- *
- * Additionally, it is necessary to treat the exports in groups. If an
- * exported package refers to another exported packages than it must be in
- * the same group. A framework can only substitute exports for imports for
- * the whole of such a group. WHY????? Not clear anymore ...
- *
+ * manifest. We also remove any version parameter so that augmentImports can
+ * do the version policy. The following method is really tricky and evolved
+ * over time. Coming from the original background of OSGi, it was a weird
+ * idea for me to have a public package that should not be substitutable. I
+ * was so much convinced that this was the right rule that I rücksichtlos
+ * imported them all. Alas, the real world was more subtle than that. It
+ * turns out that it is not a good idea to always import. First, there must
+ * be a need to import, i.e. there must be a contained package that refers
+ * to the exported package for it to make use importing that package.
+ * Second, if an exported package refers to an internal package than it
+ * should not be imported. Additionally, it is necessary to treat the
+ * exports in groups. If an exported package refers to another exported
+ * packages than it must be in the same group. A framework can only
+ * substitute exports for imports for the whole of such a group. WHY?????
+ * Not clear anymore ...
*/
Packages doExportsToImports(Packages exports) {
@@ -1003,7 +988,7 @@ public class Analyzer extends Processor
public boolean referred(PackageRef packageName) {
// return true;
- for (Map.Entry<PackageRef, List<PackageRef>> contained : uses.entrySet()) {
+ for (Map.Entry<PackageRef,List<PackageRef>> contained : uses.entrySet()) {
if (!contained.getKey().equals(packageName)) {
if (contained.getValue().contains(packageName))
return true;
@@ -1013,7 +998,6 @@ public class Analyzer extends Processor
}
/**
- *
* @param jar
*/
private void getExternalExports(Jar jar, Packages classpathExports) {
@@ -1022,7 +1006,7 @@ public class Analyzer extends Processor
if (m != null) {
Domain domain = Domain.domain(m);
Parameters exported = domain.getExportPackage();
- for (Entry<String, Attrs> e : exported.entrySet()) {
+ for (Entry<String,Attrs> e : exported.entrySet()) {
PackageRef ref = getPackageRef(e.getKey());
if (!classpathExports.containsKey(ref)) {
// TODO e.getValue().put(SOURCE_DIRECTIVE,
@@ -1055,8 +1039,7 @@ public class Analyzer extends Processor
setProperty(CURRENT_PACKAGE, packageName);
try {
Attrs importAttributes = imports.get(packageRef);
- Attrs exportAttributes = exports.get(packageRef,
- classpathExports.get(packageRef, new Attrs()));
+ Attrs exportAttributes = exports.get(packageRef, classpathExports.get(packageRef, new Attrs()));
String exportVersion = exportAttributes.getVersion();
String importRange = importAttributes.getVersion();
@@ -1064,8 +1047,7 @@ public class Analyzer extends Processor
if (exportVersion == null) {
// TODO Should check if the source is from a bundle.
- }
- else {
+ } else {
//
// Version Policy - Import version substitution. We
@@ -1076,8 +1058,7 @@ public class Analyzer extends Processor
//
boolean provider = isTrue(importAttributes.get(PROVIDE_DIRECTIVE))
- || isTrue(exportAttributes.get(PROVIDE_DIRECTIVE))
- || provided.contains(packageRef);
+ || isTrue(exportAttributes.get(PROVIDE_DIRECTIVE)) || provided.contains(packageRef);
exportVersion = cleanupVersion(exportVersion);
@@ -1087,8 +1068,7 @@ public class Analyzer extends Processor
if (importRange != null) {
importRange = cleanupVersion(importRange);
importRange = getReplacer().process(importRange);
- }
- else
+ } else
importRange = getVersionPolicy(provider);
}
@@ -1180,7 +1160,7 @@ public class Analyzer extends Processor
if (exporterAttributes == null)
continue;
- for (Map.Entry<String, String> entry : exporterAttributes.entrySet()) {
+ for (Map.Entry<String,String> entry : exporterAttributes.entrySet()) {
String key = entry.getKey();
if (key.equalsIgnoreCase(SPECIFICATION_VERSION))
key = VERSION_ATTRIBUTE;
@@ -1202,9 +1182,7 @@ public class Analyzer extends Processor
}
/**
- * Fixup Attributes
- *
- * Execute any macros on an export and
+ * Fixup Attributes Execute any macros on an export and
*/
void fixupAttributes(Attrs attributes) {
@@ -1236,7 +1214,7 @@ public class Analyzer extends Processor
}
// Remove any ! valued attributes
- for (Iterator<Entry<String, String>> i = attributes.entrySet().iterator(); i.hasNext();) {
+ for (Iterator<Entry<String,String>> i = attributes.entrySet().iterator(); i.hasNext();) {
String v = i.next().getValue();
if (v.equals("!"))
i.remove();
@@ -1246,8 +1224,10 @@ public class Analyzer extends Processor
/**
* Calculate a version from a version policy.
*
- * @param version The actual exported version
- * @param impl true for implementations and false for clients
+ * @param version
+ * The actual exported version
+ * @param impl
+ * true for implementations and false for clients
*/
String calculateVersionRange(String version, boolean impl) {
@@ -1267,7 +1247,7 @@ public class Analyzer extends Processor
* @param uses
* @throws MojoExecutionException
*/
- void doUses(Packages exports, MultiMap<PackageRef, PackageRef> uses, Packages imports) {
+ void doUses(Packages exports, MultiMap<PackageRef,PackageRef> uses, Packages imports) {
if ("true".equalsIgnoreCase(getProperty(NOUSES)))
return;
@@ -1291,8 +1271,8 @@ public class Analyzer extends Processor
* @param uses
* @param imports
*/
- protected void doUses(PackageRef packageRef, Packages exports,
- MultiMap<PackageRef, PackageRef> uses, Packages imports) {
+ protected void doUses(PackageRef packageRef, Packages exports, MultiMap<PackageRef,PackageRef> uses,
+ Packages imports) {
Attrs clause = exports.get(packageRef);
// Check if someone already set the uses: directive
@@ -1328,12 +1308,10 @@ public class Analyzer extends Processor
setProperty(CURRENT_USES, sb.toString());
override = getReplacer().process(override);
unsetProperty(CURRENT_USES);
- }
- else
+ } else
// This is for backward compatibility 0.0.287
// can be deprecated over time
- override = override.replaceAll(USES_USES, Matcher.quoteReplacement(sb.toString()))
- .trim();
+ override = override.replaceAll(USES_USES, Matcher.quoteReplacement(sb.toString())).trim();
if (override.endsWith(","))
override = override.substring(0, override.length() - 1);
@@ -1374,8 +1352,7 @@ public class Analyzer extends Processor
* @param value
* @throws Exception
*/
- void setPackageInfo(PackageRef packageRef, Resource r, Packages classpathExports)
- throws Exception {
+ void setPackageInfo(PackageRef packageRef, Resource r, Packages classpathExports) throws Exception {
if (r == null)
return;
@@ -1418,18 +1395,15 @@ public class Analyzer extends Processor
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
- out.printf("File abs path : %s%n", jar.getSource()
- .getAbsolutePath());
+ out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
- Map<String, Map<String, Resource>> dirs = jar.getDirectories();
- for (Map.Entry<String, Map<String, Resource>> entry : dirs.entrySet()) {
- Map<String, Resource> dir = entry.getValue();
+ Map<String,Map<String,Resource>> dirs = jar.getDirectories();
+ for (Map.Entry<String,Map<String,Resource>> entry : dirs.entrySet()) {
+ Map<String,Resource> dir = entry.getValue();
String name = entry.getKey().replace('/', '.');
if (dir != null) {
- out.printf(" %-30s %d%n", name,
- dir.size());
- }
- else {
+ out.printf(" %-30s %d%n", name, dir.size());
+ } else {
out.printf(" %-30s <<empty>>%n", name);
}
}
@@ -1449,9 +1423,8 @@ public class Analyzer extends Processor
/**
* Findpath looks through the contents of the JAR and finds paths that end
- * with the given regular expression
- *
- * ${findpath (; reg-expr (; replacement)? )? }
+ * with the given regular expression ${findpath (; reg-expr (; replacement)?
+ * )? }
*
* @param args
* @return
@@ -1466,8 +1439,8 @@ public class Analyzer extends Processor
String findPath(String name, String[] args, boolean fullPathName) {
if (args.length > 3) {
- warning("Invalid nr of arguments to " + name + " " + Arrays.asList(args)
- + ", syntax: ${" + name + " (; reg-expr (; replacement)? )? }");
+ warning("Invalid nr of arguments to " + name + " " + Arrays.asList(args) + ", syntax: ${" + name
+ + " (; reg-expr (; replacement)? )? }");
return null;
}
@@ -1507,9 +1480,9 @@ public class Analyzer extends Processor
return sb.toString();
}
- public void putAll(Map<String, String> additional, boolean force) {
- for (Iterator<Map.Entry<String, String>> i = additional.entrySet().iterator(); i.hasNext();) {
- Map.Entry<String, String> entry = i.next();
+ public void putAll(Map<String,String> additional, boolean force) {
+ for (Iterator<Map.Entry<String,String>> i = additional.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String,String> entry = i.next();
if (force || getProperties().get(entry.getKey()) == null)
setProperty(entry.getKey(), entry.getValue());
}
@@ -1544,15 +1517,12 @@ public class Analyzer extends Processor
for (Object jar : jars) {
if (jar instanceof Jar)
addClasspath((Jar) jar);
+ else if (jar instanceof File)
+ addClasspath((File) jar);
+ else if (jar instanceof String)
+ addClasspath(getFile((String) jar));
else
- if (jar instanceof File)
- addClasspath((File) jar);
- else
- if (jar instanceof String)
- addClasspath(getFile((String) jar));
- else
- error("Cannot convert to JAR to add to classpath %s. Not a File, Jar, or String",
- jar);
+ error("Cannot convert to JAR to add to classpath %s. Not a File, Jar, or String", jar);
}
}
@@ -1577,8 +1547,7 @@ public class Analyzer extends Processor
if (bcp.isEmpty()) {
analyzeJar(dot, "", true);
- }
- else {
+ } else {
boolean okToIncludeDirs = true;
for (String path : bcp.keySet()) {
@@ -1613,8 +1582,7 @@ public class Analyzer extends Processor
catch (Exception e) {
warning("Invalid bundle classpath entry: " + path + " " + e);
}
- }
- else {
+ } else {
if (dot.getDirectories().containsKey(path)) {
// if directories are used, we should not have dot as we
// would have the classes in these directories on the
@@ -1623,8 +1591,7 @@ public class Analyzer extends Processor
warning("Bundle-ClassPath uses a directory '%s' as well as '.'. This means bnd does not know if a directory is a package.",
path, path);
analyzeJar(dot, Processor.appendPath(path) + "/", true);
- }
- else {
+ } else {
if (!"optional".equals(info.get(RESOLUTION_DIRECTIVE)))
warning("No sub JAR or directory " + path);
}
@@ -1646,7 +1613,7 @@ public class Analyzer extends Processor
* @throws IOException
*/
private boolean analyzeJar(Jar jar, String prefix, boolean okToIncludeDirs) throws Exception {
- Map<String, Clazz> mismatched = new HashMap<String, Clazz>();
+ Map<String,Clazz> mismatched = new HashMap<String,Clazz>();
next: for (String path : jar.getResources().keySet()) {
if (path.startsWith(prefix)) {
@@ -1668,8 +1635,7 @@ public class Analyzer extends Processor
// we found a class since the bcp has a tendency
// to overlap
if (!packageRef.isMetaData()) {
- Resource pinfo = jar.getResource(prefix + packageRef.getPath()
- + "/packageinfo");
+ Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
setPackageInfo(packageRef, pinfo, classpathExports);
}
}
@@ -1690,8 +1656,7 @@ public class Analyzer extends Processor
// package-info can contain an Export annotation
info = new Attrs();
parsePackageInfoClass(clazz, info);
- }
- else {
+ } else {
// Otherwise we just parse it simply
clazz.parseClassFile();
}
@@ -1712,16 +1677,14 @@ public class Analyzer extends Processor
// warning
if (okToIncludeDirs) // assume already reported
mismatched.put(clazz.getAbsolutePath(), clazz);
- }
- else {
+ } else {
classspace.put(clazz.getClassName(), clazz);
PackageRef packageRef = clazz.getClassName().getPackageRef();
if (!contained.containsKey(packageRef)) {
contained.put(packageRef);
if (!packageRef.isMetaData()) {
- Resource pinfo = jar.getResource(prefix + packageRef.getPath()
- + "/packageinfo");
+ Resource pinfo = jar.getResource(prefix + packageRef.getPath() + "/packageinfo");
setPackageInfo(packageRef, pinfo, classpathExports);
}
}
@@ -1767,92 +1730,87 @@ public class Analyzer extends Processor
if (Verifier.VERSION.matcher(version).matches())
info.put(VERSION_ATTRIBUTE, version);
else
- error("Export annotation in %s has invalid version info: %s",
- clazz, version);
+ error("Export annotation in %s has invalid version info: %s", clazz, version);
}
- }
- else {
+ } else {
// Verify this matches with packageinfo
String presentVersion = info.get(VERSION_ATTRIBUTE);
try {
Version av = new Version(presentVersion);
Version bv = new Version(version);
if (!av.equals(bv)) {
- error("Version from annotation for %s differs with packageinfo or Manifest",
- clazz.getClassName().getFQN());
+ error("Version from annotation for %s differs with packageinfo or Manifest", clazz
+ .getClassName().getFQN());
}
}
catch (Exception e) {
// Ignore
}
}
- }
- else
- if (name.equals(Export.class.getName())) {
-
- // Check mandatory attributes
- Attrs attrs = doAttrbutes((Object[]) a.get(Export.MANDATORY), clazz,
- getReplacer());
- if (!attrs.isEmpty()) {
- info.putAll(attrs);
- info.put(MANDATORY_DIRECTIVE, Processor.join(attrs.keySet()));
- }
-
- // Check optional attributes
- attrs = doAttrbutes((Object[]) a.get(Export.OPTIONAL), clazz, getReplacer());
- if (!attrs.isEmpty()) {
- info.putAll(attrs);
- }
+ } else if (name.equals(Export.class.getName())) {
- // Check Included classes
- Object[] included = a.get(Export.INCLUDE);
- if (included != null && included.length > 0) {
- StringBuilder sb = new StringBuilder();
- String del = "";
- for (Object i : included) {
- Matcher m = OBJECT_REFERENCE.matcher((String) i);
- if (m.matches()) {
- sb.append(del);
- sb.append(m.group(2));
- del = ",";
- }
- }
- info.put(INCLUDE_DIRECTIVE, sb.toString());
- }
-
- // Check Excluded classes
- Object[] excluded = a.get(Export.EXCLUDE);
- if (excluded != null && excluded.length > 0) {
- StringBuilder sb = new StringBuilder();
- String del = "";
- for (Object i : excluded) {
- Matcher m = OBJECT_REFERENCE.matcher((String) i);
- if (m.matches()) {
- sb.append(del);
- sb.append(m.group(2));
- del = ",";
- }
+ // Check mandatory attributes
+ Attrs attrs = doAttrbutes((Object[]) a.get(Export.MANDATORY), clazz, getReplacer());
+ if (!attrs.isEmpty()) {
+ info.putAll(attrs);
+ info.put(MANDATORY_DIRECTIVE, Processor.join(attrs.keySet()));
+ }
+
+ // Check optional attributes
+ attrs = doAttrbutes((Object[]) a.get(Export.OPTIONAL), clazz, getReplacer());
+ if (!attrs.isEmpty()) {
+ info.putAll(attrs);
+ }
+
+ // Check Included classes
+ Object[] included = a.get(Export.INCLUDE);
+ if (included != null && included.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ String del = "";
+ for (Object i : included) {
+ Matcher m = OBJECT_REFERENCE.matcher((String) i);
+ if (m.matches()) {
+ sb.append(del);
+ sb.append(m.group(2));
+ del = ",";
}
- info.put(EXCLUDE_DIRECTIVE, sb.toString());
}
+ info.put(INCLUDE_DIRECTIVE, sb.toString());
+ }
- // Check Uses
- Object[] uses = a.get(Export.USES);
- if (uses != null && uses.length > 0) {
- String old = info.get(USES_DIRECTIVE);
- if (old == null)
- old = "";
- StringBuilder sb = new StringBuilder(old);
- String del = sb.length() == 0 ? "" : ",";
-
- for (Object use : uses) {
+ // Check Excluded classes
+ Object[] excluded = a.get(Export.EXCLUDE);
+ if (excluded != null && excluded.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ String del = "";
+ for (Object i : excluded) {
+ Matcher m = OBJECT_REFERENCE.matcher((String) i);
+ if (m.matches()) {
sb.append(del);
- sb.append(use);
+ sb.append(m.group(2));
del = ",";
}
- info.put(USES_DIRECTIVE, sb.toString());
}
+ info.put(EXCLUDE_DIRECTIVE, sb.toString());
+ }
+
+ // Check Uses
+ Object[] uses = a.get(Export.USES);
+ if (uses != null && uses.length > 0) {
+ String old = info.get(USES_DIRECTIVE);
+ if (old == null)
+ old = "";
+ StringBuilder sb = new StringBuilder(old);
+ String del = sb.length() == 0 ? "" : ",";
+
+ for (Object use : uses) {
+ sb.append(del);
+ sb.append(use);
+ del = ",";
+ }
+ info.put(USES_DIRECTIVE, sb.toString());
}
+ }
}
});
@@ -1866,14 +1824,11 @@ public class Analyzer extends Processor
* @param VERSION_STRING
* @return
*/
- static Pattern fuzzyVersion = Pattern
- .compile(
- "(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
- Pattern.DOTALL);
- static Pattern fuzzyVersionRange = Pattern
- .compile(
- "(\\(|\\[)\\s*([-\\da-zA-Z.]+)\\s*,\\s*([-\\da-zA-Z.]+)\\s*(\\]|\\))",
- Pattern.DOTALL);
+ static Pattern fuzzyVersion = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
+ Pattern.DOTALL);
+ static Pattern fuzzyVersionRange = Pattern.compile(
+ "(\\(|\\[)\\s*([-\\da-zA-Z.]+)\\s*,\\s*([-\\da-zA-Z.]+)\\s*(\\]|\\))",
+ Pattern.DOTALL);
static Pattern fuzzyModifier = Pattern.compile("(\\d+[.-])*(.*)", Pattern.DOTALL);
static Pattern nummeric = Pattern.compile("\\d*");
@@ -1893,49 +1848,47 @@ public class Analyzer extends Processor
String suffix = m.group(4);
return prefix + cleanupVersion(first) + "," + cleanupVersion(last) + suffix;
}
- else {
- m = fuzzyVersion.matcher(version);
- if (m.matches()) {
- StringBuilder result = new StringBuilder();
- String major = removeLeadingZeroes(m.group(1));
- String minor = removeLeadingZeroes(m.group(3));
- String micro = removeLeadingZeroes(m.group(5));
- String qualifier = m.group(7);
-
- if (major != null) {
- result.append(major);
- if (minor != null) {
+
+ m = fuzzyVersion.matcher(version);
+ if (m.matches()) {
+ StringBuilder result = new StringBuilder();
+ String major = removeLeadingZeroes(m.group(1));
+ String minor = removeLeadingZeroes(m.group(3));
+ String micro = removeLeadingZeroes(m.group(5));
+ String qualifier = m.group(7);
+
+ if (major != null) {
+ result.append(major);
+ if (minor != null) {
+ result.append(".");
+ result.append(minor);
+ if (micro != null) {
result.append(".");
- result.append(minor);
- if (micro != null) {
- result.append(".");
- result.append(micro);
- if (qualifier != null) {
- result.append(".");
- cleanupModifier(result, qualifier);
- }
- }
- else
- if (qualifier != null) {
- result.append(".0.");
- cleanupModifier(result, qualifier);
- }
- }
- else
+ result.append(micro);
if (qualifier != null) {
- result.append(".0.0.");
+ result.append(".");
cleanupModifier(result, qualifier);
}
- return result.toString();
+ } else if (qualifier != null) {
+ result.append(".0.");
+ cleanupModifier(result, qualifier);
+ }
+ } else if (qualifier != null) {
+ result.append(".0.0.");
+ cleanupModifier(result, qualifier);
}
+ return result.toString();
}
}
return version;
}
private static String removeLeadingZeroes(String group) {
+ if (group == null)
+ return null;
+
int n = 0;
- while (group != null && n < group.length() - 1 && group.charAt(n) == '0')
+ while (n < group.length() - 1 && group.charAt(n) == '0')
n++;
if (n == 0)
return group;
@@ -1950,8 +1903,7 @@ public class Analyzer extends Processor
for (int i = 0; i < modifier.length(); i++) {
char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
- || c == '_' || c == '-')
+ if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
result.append(c);
}
}
@@ -1972,17 +1924,16 @@ public class Analyzer extends Processor
return getProperty(VERSIONPOLICY, DEFAULT_PROVIDER_POLICY);
}
- else {
- String s = getProperty(CONSUMER_POLICY);
- if (s != null)
- return s;
+ String s = getProperty(CONSUMER_POLICY);
+ if (s != null)
+ return s;
+
+ s = getProperty(VERSIONPOLICY_USES);
+ if (s != null)
+ return s;
- s = getProperty(VERSIONPOLICY_USES);
- if (s != null)
- return s;
+ return getProperty(VERSIONPOLICY, DEFAULT_CONSUMER_POLICY);
- return getProperty(VERSIONPOLICY, DEFAULT_CONSUMER_POLICY);
- }
// String vp = implemented ? getProperty(VERSIONPOLICY_IMPL) :
// getProperty(VERSIONPOLICY_USES);
//
@@ -2019,24 +1970,21 @@ public class Analyzer extends Processor
Set<Clazz> matched = new HashSet<Clazz>(classspace.values());
for (int i = 1; i < args.length; i++) {
if (args.length < i + 1)
- throw new IllegalArgumentException(
- "${classes} macro must have odd number of arguments. " + _classesHelp);
+ throw new IllegalArgumentException("${classes} macro must have odd number of arguments. "
+ + _classesHelp);
String typeName = args[i];
if (typeName.equalsIgnoreCase("extending"))
typeName = "extends";
- else
- if (typeName.equalsIgnoreCase("importing"))
- typeName = "imports";
- else
- if (typeName.equalsIgnoreCase("implementing"))
- typeName = "implements";
+ else if (typeName.equalsIgnoreCase("importing"))
+ typeName = "imports";
+ else if (typeName.equalsIgnoreCase("implementing"))
+ typeName = "implements";
Clazz.QUERY type = Clazz.QUERY.valueOf(typeName.toUpperCase());
if (type == null)
- throw new IllegalArgumentException("${classes} has invalid type: " + typeName
- + ". " + _classesHelp);
+ throw new IllegalArgumentException("${classes} has invalid type: " + typeName + ". " + _classesHelp);
Instruction instr = null;
if (Clazz.HAS_ARGUMENT.contains(type)) {
@@ -2058,9 +2006,7 @@ public class Analyzer extends Processor
*/
public String _exporters(String args[]) throws Exception {
- Macro.verifyCommand(
- args,
- "${exporters;<packagename>}, returns the list of jars that export the given package",
+ Macro.verifyCommand(args, "${exporters;<packagename>}, returns the list of jars that export the given package",
null, 2, 2);
StringBuilder sb = new StringBuilder();
String del = "";
@@ -2074,14 +2020,15 @@ public class Analyzer extends Processor
return sb.toString();
}
- public Map<TypeRef, Clazz> getClassspace() {
+ public Map<TypeRef,Clazz> getClassspace() {
return classspace;
}
/**
* Locate a resource on the class path.
*
- * @param path Path of the reosurce
+ * @param path
+ * Path of the reosurce
* @return A resource or <code>null</code>
*/
public Resource findResource(String path) {
@@ -2158,7 +2105,7 @@ public class Analyzer extends Processor
if (require == null || require.isEmpty())
return;
- Hashtable<String, String> map = new Hashtable<String, String>();
+ Hashtable<String,String> map = new Hashtable<String,String>();
map.put(Constants.VERSION_FILTER, getBndVersion());
for (String filter : require.keySet()) {
@@ -2181,8 +2128,9 @@ public class Analyzer extends Processor
static String _md5Help = "${md5;path}";
public String _md5(String args[]) throws Exception {
- Macro.verifyCommand(args, _md5Help,
- new Pattern[] {null, null, Pattern.compile("base64|hex")}, 2, 3);
+ Macro.verifyCommand(args, _md5Help, new Pattern[] {
+ null, null, Pattern.compile("base64|hex")
+ }, 2, 3);
Digester<MD5> digester = MD5.getDigester();
Resource r = dot.getResource(args[1]);
@@ -2193,8 +2141,8 @@ public class Analyzer extends Processor
boolean hex = args.length > 2 && args[2].equals("hex");
if (hex)
return Hex.toHexString(digester.digest().digest());
- else
- return Base64.encodeBase64(digester.digest().digest());
+
+ return Base64.encodeBase64(digester.digest().digest());
}
/**
@@ -2204,8 +2152,9 @@ public class Analyzer extends Processor
static String _sha1Help = "${sha1;path}";
public String _sha1(String args[]) throws Exception {
- Macro.verifyCommand(args, _sha1Help,
- new Pattern[] {null, null, Pattern.compile("base64|hex")}, 2, 3);
+ Macro.verifyCommand(args, _sha1Help, new Pattern[] {
+ null, null, Pattern.compile("base64|hex")
+ }, 2, 3);
Digester<SHA1> digester = SHA1.getDigester();
Resource r = dot.getResource(args[1]);
if (r == null)
@@ -2248,7 +2197,6 @@ public class Analyzer extends Processor
* are ordered so that the instructor can define which pattern matches
* first. Attributes in the instructions override any attributes from the
* actual.<br/>
- *
* A pattern is a modified regexp so it looks like globbing. The * becomes a
* .* just like the ? becomes a .?. '.' are replaced with \\. Additionally,
* if the pattern starts with an exclamation mark, it will remove that
@@ -2263,10 +2211,10 @@ public class Analyzer extends Processor
* </ul>
* Enough rope to hang the average developer I would say.
*
- *
- * @param instructions the instructions with patterns.
- * @param source the actual found packages, contains no duplicates
- *
+ * @param instructions
+ * the instructions with patterns.
+ * @param source
+ * the actual found packages, contains no duplicates
* @return Only the packages that were filtered by the given instructions
*/
@@ -2319,8 +2267,7 @@ public class Analyzer extends Processor
// doing and inserted a literal. So
// we ignore any not matched literals
if (instruction.isLiteral()) {
- result.merge(getPackageRef(instruction.getLiteral()), true,
- instructions.get(instruction));
+ result.merge(getPackageRef(instruction.getLiteral()), true, instructions.get(instruction));
i.remove();
continue;
}
@@ -2379,7 +2326,8 @@ public class Analyzer extends Processor
* Untitled-[n]
* </pre>
*
- * @param output may be null, otherwise a file path relative to base
+ * @param output
+ * may be null, otherwise a file path relative to base
*/
public File getOutputFile(String output) {
@@ -2394,16 +2342,14 @@ public class Analyzer extends Processor
outputDir = outputFile;
else
return outputFile;
- }
- else
+ } else
outputDir = getBase();
if (getBundleSymbolicName() != null) {
String bsn = getBundleSymbolicName();
String version = getBundleVersion();
Version v = Version.parseVersion(version);
- String outputName = bsn + "-" + v.getWithoutQualifier()
- + Constants.DEFAULT_JAR_EXTENSION;
+ String outputName = bsn + "-" + v.getWithoutQualifier() + Constants.DEFAULT_JAR_EXTENSION;
return new File(outputDir, outputName);
}
@@ -2413,8 +2359,7 @@ public class Analyzer extends Processor
return new File(outputDir, outputName);
}
- error("Cannot establish an output name from %s, nor bsn, nor source file name, using Untitled",
- output);
+ error("Cannot establish an output name from %s, nor bsn, nor source file name, using Untitled", output);
int n = 0;
File f = getFile(outputDir, "Untitled");
while (f.isFile()) {
@@ -2428,9 +2373,11 @@ public class Analyzer extends Processor
* source file has the same path as the output. It will also only save if
* the file was modified or the force flag is true
*
- * @param output the output file, if null {@link #getOutputFile(String)} is
- * used.
- * @param force if it needs to be overwritten
+ * @param output
+ * the output file, if null {@link #getOutputFile(String)} is
+ * used.
+ * @param force
+ * if it needs to be overwritten
* @throws Exception
*/
@@ -2441,8 +2388,8 @@ public class Analyzer extends Processor
Jar jar = getJar();
File source = jar.getSource();
- trace("check for modified build=%s file=%s, diff=%s", jar.lastModified(),
- output.lastModified(), jar.lastModified() - output.lastModified());
+ trace("check for modified build=%s file=%s, diff=%s", jar.lastModified(), output.lastModified(),
+ jar.lastModified() - output.lastModified());
if (!output.exists() || output.lastModified() <= jar.lastModified() || force) {
output.getParentFile().mkdirs();
@@ -2450,8 +2397,7 @@ public class Analyzer extends Processor
File bak = new File(source.getParentFile(), source.getName() + ".bak");
if (!source.renameTo(bak)) {
error("Could not create backup file %s", bak);
- }
- else
+ } else
source.delete();
}
try {
@@ -2464,10 +2410,9 @@ public class Analyzer extends Processor
}
return true;
}
- else {
- trace("Not modified %s", output);
- return false;
- }
+ trace("Not modified %s", output);
+ return false;
+
}
/**
Added: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java?rev=1350613&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java (added)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java Fri Jun 15 13:27:53 2012
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package aQute.lib.osgi;
+
+import aQute.libg.reporter.*;
+
+public interface AnalyzerMessages extends Messages {
+/**/
+}
Propchange: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/AnalyzerMessages.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Annotation.java Fri Jun 15 13:27:53 2012
@@ -6,16 +6,16 @@ import java.util.*;
import aQute.bnd.annotation.metatype.*;
import aQute.lib.osgi.Descriptors.TypeRef;
-@SuppressWarnings("unchecked") public class Annotation {
+@SuppressWarnings("unchecked")
+public class Annotation {
TypeRef name;
- Map<String, Object> elements;
+ Map<String,Object> elements;
ElementType member;
RetentionPolicy policy;
- public Annotation(TypeRef name, Map<String, Object> elements, ElementType member,
- RetentionPolicy policy) {
+ public Annotation(TypeRef name, Map<String,Object> elements, ElementType member, RetentionPolicy policy) {
this.name = name;
- if ( elements == null)
+ if (elements == null)
this.elements = Collections.emptyMap();
else
this.elements = elements;
@@ -30,11 +30,11 @@ import aQute.lib.osgi.Descriptors.TypeRe
public ElementType getElementType() {
return member;
}
-
+
public RetentionPolicy getRetentionPolicy() {
return policy;
}
-
+
public String toString() {
return name + ":" + member + ":" + policy + ":" + elements;
}
@@ -56,19 +56,20 @@ import aQute.lib.osgi.Descriptors.TypeRe
public Set<String> keySet() {
if (elements == null)
return Collections.emptySet();
-
+
return elements.keySet();
}
+
public <T extends java.lang.annotation.Annotation> T getAnnotation() throws Exception {
String cname = name.getFQN();
Class<T> c = (Class<T>) getClass().getClassLoader().loadClass(cname);
return getAnnotation(c);
}
- public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c)
- throws Exception {
+
+ public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c) throws Exception {
String cname = name.getFQN();
- if ( ! c.getName().equals(cname))
+ if (!c.getName().equals(cname))
return null;
- return Configurable.createConfigurable(c, elements );
+ return Configurable.createConfigurable(c, elements);
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java Fri Jun 15 13:27:53 2012
@@ -23,19 +23,14 @@ import aQute.libg.generics.*;
import aQute.libg.header.*;
/**
- * Include-Resource: ( [name '=' ] file )+
- *
- * Private-Package: package-decl ( ',' package-decl )*
- *
- * Export-Package: package-decl ( ',' package-decl )*
- *
+ * Include-Resource: ( [name '=' ] file )+ Private-Package: package-decl ( ','
+ * package-decl )* Export-Package: package-decl ( ',' package-decl )*
* Import-Package: package-decl ( ',' package-decl )*
*
* @version $Revision$
*/
public class Builder extends Analyzer {
- static Pattern IR_PATTERN = Pattern
- .compile("[{]?-?@?(?:[^=]+=)?\\s*([^}!]+).*");
+ static Pattern IR_PATTERN = Pattern.compile("[{]?-?@?(?:[^=]+=)?\\s*([^}!]+).*");
private final DiffPluginImpl differ = new DiffPluginImpl();
private Pattern xdoNotCopy = null;
private static final int SPLIT_MERGE_LAST = 1;
@@ -50,8 +45,7 @@ public class Builder extends Analyzer {
super(parent);
}
- public Builder() {
- }
+ public Builder() {}
public Jar build() throws Exception {
trace("build");
@@ -60,8 +54,7 @@ public class Builder extends Analyzer {
return null;
if (getProperty(CONDUIT) != null)
- error("Specified " + CONDUIT
- + " but calls build() instead of builds() (might be a programmer error");
+ error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error");
Jar dot = new Jar("dot");
try {
@@ -77,6 +70,8 @@ public class Builder extends Analyzer {
doIncludeResources(dot);
doWab(dot);
+ doBndInfo(dot);
+
// Check if we override the calculation of the
// manifest. We still need to calculated it because
// we need to have analyzed the classpath.
@@ -95,8 +90,7 @@ public class Builder extends Analyzer {
catch (Exception e) {
error(MANIFEST + " while reading manifest file", e);
}
- }
- else {
+ } else {
error(MANIFEST + ", no such file " + mf);
}
}
@@ -133,6 +127,21 @@ public class Builder extends Analyzer {
}
/**
+ * Make sure any bnd.info files are properly processed
+ *
+ * @param jar
+ */
+
+ private void doBndInfo(Jar jar) {
+ for (Entry<String,Resource> e : jar.getResources().entrySet()) {
+ if (e.getKey().endsWith("/bnd.info")) {
+ PreprocessResource pp = new PreprocessResource(this, e.getValue());
+ e.setValue(pp);
+ }
+ }
+ }
+
+ /**
* Check if we need to calculate any checksums.
*
* @param dot
@@ -215,16 +224,14 @@ public class Builder extends Analyzer {
for (String part : parts) {
File sub = getFile(f.getParentFile(), part);
if (!sub.exists() || !sub.getParentFile().equals(f.getParentFile())) {
- warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory",
- sub, f);
- }
- else {
+ warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory", sub,
+ f);
+ } else {
addWabLib(dot, sub);
}
}
}
- }
- else {
+ } else {
error("WAB lib does not exist %s", f);
}
}
@@ -255,14 +262,11 @@ public class Builder extends Analyzer {
changedFile(f);
}
- protected void changedFile(File f) {
- }
+ protected void changedFile(File f) {}
/**
- * Sign the jar file.
- *
- * -sign : <alias> [ ';' 'password:=' <password> ] [ ';' 'keystore:='
- * <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )*
+ * Sign the jar file. -sign : <alias> [ ';' 'password:=' <password> ] [ ';'
+ * 'keystore:=' <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )*
*
* @return
*/
@@ -276,7 +280,7 @@ public class Builder extends Analyzer {
List<SignerPlugin> signers = getPlugins(SignerPlugin.class);
Parameters infos = parseHeader(signing);
- for (Entry<String, Attrs> entry : infos.entrySet()) {
+ for (Entry<String,Attrs> entry : infos.entrySet()) {
for (SignerPlugin signer : signers) {
signer.sign(this, entry.getKey());
}
@@ -303,7 +307,7 @@ public class Builder extends Analyzer {
addClose(jar);
for (PackageRef pref : referred) {
for (Jar cpe : getClasspath()) {
- Map<String, Resource> map = cpe.getDirectories().get(pref.getPath());
+ Map<String,Resource> map = cpe.getDirectories().get(pref.getPath());
if (map != null) {
jar.addDirectory(map, false);
break;
@@ -335,7 +339,7 @@ public class Builder extends Analyzer {
}
public void cleanupVersion(Packages packages, String defaultVersion) {
- for (Map.Entry<PackageRef, Attrs> entry : packages.entrySet()) {
+ for (Map.Entry<PackageRef,Attrs> entry : packages.entrySet()) {
Attrs attributes = entry.getValue();
String v = attributes.get(Constants.VERSION_ATTRIBUTE);
if (v == null && defaultVersion != null) {
@@ -343,8 +347,7 @@ public class Builder extends Analyzer {
v = defaultVersion;
if (isPedantic())
warning("Used bundle version %s for exported package %s", v, entry.getKey());
- }
- else {
+ } else {
if (isPedantic())
warning("No export version for exported package %s", entry.getKey());
}
@@ -369,8 +372,9 @@ public class Builder extends Analyzer {
String packagePath = packageRef.getPath();
boolean found = false;
- String[] fixed = {"packageinfo", "package.html", "module-info.java",
- "package-info.java"};
+ String[] fixed = {
+ "packageinfo", "package.html", "module-info.java", "package-info.java"
+ };
for (Iterator<File> i = getSourcePath().iterator(); i.hasNext();) {
File root = i.next();
@@ -401,8 +405,7 @@ public class Builder extends Analyzer {
Resource resource = jar.getResource(sourcePath);
if (resource != null) {
dot.putResource("OSGI-OPT/src/" + sourcePath, resource);
- }
- else {
+ } else {
resource = jar.getResource("OSGI-OPT/src/" + sourcePath);
if (resource != null) {
dot.putResource("OSGI-OPT/src/" + sourcePath, resource);
@@ -411,8 +414,7 @@ public class Builder extends Analyzer {
}
}
if (getSourcePath().isEmpty())
- warning("Including sources but " + SOURCEPATH
- + " does not contain any source directories ");
+ warning("Including sources but " + SOURCEPATH + " does not contain any source directories ");
// TODO copy from the jars where they came from
}
}
@@ -432,8 +434,7 @@ public class Builder extends Analyzer {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: " + f);
- }
- else {
+ } else {
sourcePath.add(f);
}
}
@@ -451,13 +452,13 @@ public class Builder extends Analyzer {
getInfo(verifier);
}
- private void doExpand(Jar dot) throws IOException {
+ private void doExpand(Jar dot) {
// Build an index of the class path that we can then
// use destructively
- MultiMap<String, Jar> packages = new MultiMap<String, Jar>();
+ MultiMap<String,Jar> packages = new MultiMap<String,Jar>();
for (Jar srce : getClasspath()) {
- for (Entry<String, Map<String, Resource>> e : srce.getDirectories().entrySet()) {
+ for (Entry<String,Map<String,Resource>> e : srce.getDirectories().entrySet()) {
if (e.getValue() != null)
packages.add(e.getKey(), srce);
}
@@ -474,8 +475,7 @@ public class Builder extends Analyzer {
Set<Instruction> unused = doExpand(dot, packages, privateFilter);
if (!unused.isEmpty()) {
- warning("Unused Private-Package instructions, no such package(s) on the class path: %s",
- unused);
+ warning("Unused Private-Package instructions, no such package(s) on the class path: %s", unused);
}
}
@@ -500,10 +500,10 @@ public class Builder extends Analyzer {
* @param name
* @param instructions
*/
- private Set<Instruction> doExpand(Jar jar, MultiMap<String, Jar> index, Instructions filter) {
+ private Set<Instruction> doExpand(Jar jar, MultiMap<String,Jar> index, Instructions filter) {
Set<Instruction> unused = Create.set();
- for (Entry<Instruction, Attrs> e : filter.entrySet()) {
+ for (Entry<Instruction,Attrs> e : filter.entrySet()) {
Instruction instruction = e.getKey();
if (instruction.isDuplicate())
continue;
@@ -518,9 +518,8 @@ public class Builder extends Analyzer {
boolean used = false;
- for (Iterator<Entry<String, List<Jar>>> entry = index.entrySet().iterator(); entry
- .hasNext();) {
- Entry<String, List<Jar>> p = entry.next();
+ for (Iterator<Entry<String,List<Jar>>> entry = index.entrySet().iterator(); entry.hasNext();) {
+ Entry<String,List<Jar>> p = entry.next();
String directory = p.getKey();
PackageRef packageRef = getPackageRef(directory);
@@ -626,14 +625,9 @@ public class Builder extends Analyzer {
private void copy(Jar dest, Jar srce, String path, boolean overwrite) {
dest.copy(srce, path, overwrite);
- String key = path + "/bnd.info";
- Resource r = dest.getResource(key);
- if (r != null)
- dest.putResource(key, new PreprocessResource(this, r));
-
if (hasSources()) {
String srcPath = "OSGI-OPT/src/" + path;
- Map<String, Resource> srcContents = srce.getDirectories().get(srcPath);
+ Map<String,Resource> srcContents = srce.getDirectories().get(srcPath);
if (srcContents != null) {
dest.addDirectory(srcContents, overwrite);
}
@@ -680,16 +674,19 @@ public class Builder extends Analyzer {
/**
* Matches the instructions against a package.
*
- * @param instructions The list of instructions
- * @param pack The name of the package
- * @param unused The total list of patterns, matched patterns are removed
- * @param source The name of the source container, can be filtered upon with
- * the from: directive.
+ * @param instructions
+ * The list of instructions
+ * @param pack
+ * The name of the package
+ * @param unused
+ * The total list of patterns, matched patterns are removed
+ * @param source
+ * The name of the source container, can be filtered upon with
+ * the from: directive.
* @return
*/
- private Instruction matches(Instructions instructions, String pack, Set<Instruction> unused,
- String source) {
- for (Entry<Instruction, Attrs> entry : instructions.entrySet()) {
+ private Instruction matches(Instructions instructions, String pack, Set<Instruction> unused, String source) {
+ for (Entry<Instruction,Attrs> entry : instructions.entrySet()) {
Instruction pattern = entry.getKey();
// It is possible to filter on the source of the
@@ -728,8 +725,7 @@ public class Builder extends Analyzer {
includes = getProperty(INCLUDERESOURCE);
if (includes == null || includes.length() == 0)
includes = getProperty("Include-Resource");
- }
- else
+ } else
warning("Please use -includeresource instead of Bundle-Includes");
doIncludeResource(jar, includes);
@@ -741,15 +737,14 @@ public class Builder extends Analyzer {
doIncludeResource(jar, clauses);
}
- private void doIncludeResource(Jar jar, Parameters clauses) throws ZipException, IOException,
- Exception {
- for (Entry<String, Attrs> entry : clauses.entrySet()) {
+ private void doIncludeResource(Jar jar, Parameters clauses) throws ZipException, IOException, Exception {
+ for (Entry<String,Attrs> entry : clauses.entrySet()) {
doIncludeResource(jar, entry.getKey(), entry.getValue());
}
}
- private void doIncludeResource(Jar jar, String name, Map<String, String> extra)
- throws ZipException, IOException, Exception {
+ private void doIncludeResource(Jar jar, String name, Map<String,String> extra) throws ZipException, IOException,
+ Exception {
boolean preprocess = false;
boolean absentIsOk = false;
@@ -771,56 +766,47 @@ public class Builder extends Analyzer {
}
if (source.startsWith("@")) {
- extractFromJar(jar, source.substring(1), parts.length == 1 ? "" : destination,
- absentIsOk);
- }
- else
- if (extra.containsKey("cmd")) {
- doCommand(jar, source, destination, extra, preprocess, absentIsOk);
+ extractFromJar(jar, source.substring(1), parts.length == 1 ? "" : destination, absentIsOk);
+ } else if (extra.containsKey("cmd")) {
+ doCommand(jar, source, destination, extra, preprocess, absentIsOk);
+ } else if (extra.containsKey("literal")) {
+ String literal = extra.get("literal");
+ Resource r = new EmbeddedResource(literal.getBytes("UTF-8"), 0);
+ String x = extra.get("extra");
+ if (x != null)
+ r.setExtra(x);
+ jar.putResource(name, r);
+ } else {
+ File sourceFile;
+ String destinationPath;
+
+ sourceFile = getFile(source);
+ if (parts.length == 1) {
+ // Directories should be copied to the root
+ // but files to their file name ...
+ if (sourceFile.isDirectory())
+ destinationPath = "";
+ else
+ destinationPath = sourceFile.getName();
+ } else {
+ destinationPath = parts[0];
+ }
+ // Handle directories
+ if (sourceFile.isDirectory()) {
+ destinationPath = doResourceDirectory(jar, extra, preprocess, sourceFile, destinationPath);
+ return;
}
- else
- if (extra.containsKey("literal")) {
- String literal = extra.get("literal");
- Resource r = new EmbeddedResource(literal.getBytes("UTF-8"), 0);
- String x = extra.get("extra");
- if (x != null)
- r.setExtra(x);
- jar.putResource(name, r);
- }
- else {
- File sourceFile;
- String destinationPath;
-
- sourceFile = getFile(source);
- if (parts.length == 1) {
- // Directories should be copied to the root
- // but files to their file name ...
- if (sourceFile.isDirectory())
- destinationPath = "";
- else
- destinationPath = sourceFile.getName();
- }
- else {
- destinationPath = parts[0];
- }
- // Handle directories
- if (sourceFile.isDirectory()) {
- destinationPath = doResourceDirectory(jar, extra, preprocess, sourceFile,
- destinationPath);
- return;
- }
-
- // destinationPath = checkDestinationPath(destinationPath);
- if (!sourceFile.exists()) {
- if (absentIsOk)
- return;
+ // destinationPath = checkDestinationPath(destinationPath);
- noSuchFile(jar, name, extra, source, destinationPath);
- }
- else
- copy(jar, destinationPath, sourceFile, preprocess, extra);
- }
+ if (!sourceFile.exists()) {
+ if (absentIsOk)
+ return;
+
+ noSuchFile(jar, name, extra, source, destinationPath);
+ } else
+ copy(jar, destinationPath, sourceFile, preprocess, extra);
+ }
}
/**
@@ -831,13 +817,10 @@ public class Builder extends Analyzer {
* {@link Macro#_lsa(String[])} or {@link Macro#_lsb(String[])} macro. The
* repetition will repeat the given command for each item. The @} macro can
* be used to replace the current item. If no {@code for} is given, the
- * source is used as the only item.
- *
- * If the destination contains a macro, each iteration will create a new
- * file, otherwise the destination name is used.
- *
- * The execution of the command is delayed until the JAR is actually written
- * to the file system for performance reasons.
+ * source is used as the only item. If the destination contains a macro,
+ * each iteration will create a new file, otherwise the destination name is
+ * used. The execution of the command is delayed until the JAR is actually
+ * written to the file system for performance reasons.
*
* @param jar
* @param source
@@ -846,8 +829,8 @@ public class Builder extends Analyzer {
* @param preprocess
* @param absentIsOk
*/
- private void doCommand(Jar jar, String source, String destination, Map<String, String> extra,
- boolean preprocess, boolean absentIsOk) {
+ private void doCommand(Jar jar, String source, String destination, Map<String,String> extra, boolean preprocess,
+ boolean absentIsOk) {
String repeat = extra.get("for"); // TODO constant
if (repeat == null)
repeat = source;
@@ -857,10 +840,9 @@ public class Builder extends Analyzer {
for (String required : requires) {
File file = getFile(required);
if (!file.isFile()) {
- error("Include-Resource.cmd for %s, requires %s, but no such file %s", source,
- required, file.getAbsoluteFile());
- }
- else
+ error("Include-Resource.cmd for %s, requires %s, but no such file %s", source, required,
+ file.getAbsoluteFile());
+ } else
lastModified = Math.max(lastModified, file.lastModified());
}
@@ -874,7 +856,7 @@ public class Builder extends Analyzer {
cr = new CombinedResource();
}
trace("last modified requires %s", lastModified);
-
+
for (String item : items) {
setProperty("@", item);
try {
@@ -883,7 +865,7 @@ public class Builder extends Analyzer {
File file = getFile(item);
Resource r = new CommandResource(command, this, Math.max(lastModified,
- file.exists() ? file.lastModified():0L));
+ file.exists() ? file.lastModified() : 0L));
if (preprocess)
r = new PreprocessResource(this, r);
@@ -897,15 +879,15 @@ public class Builder extends Analyzer {
unsetProperty("@");
}
}
-
+
// Add last so the correct modification date is used
// to update the modified time.
- if ( cr != null)
+ if (cr != null)
jar.putResource(destination, cr);
}
- private String doResourceDirectory(Jar jar, Map<String, String> extra, boolean preprocess,
- File sourceFile, String destinationPath) throws Exception {
+ private String doResourceDirectory(Jar jar, Map<String,String> extra, boolean preprocess, File sourceFile,
+ String destinationPath) throws Exception {
String filter = extra.get("filter:");
boolean flatten = isTrue(extra.get("flatten:"));
boolean recursive = true;
@@ -917,22 +899,21 @@ public class Builder extends Analyzer {
Instruction.Filter iFilter = null;
if (filter != null) {
iFilter = new Instruction.Filter(new Instruction(filter), recursive, getDoNotCopy());
- }
- else {
+ } else {
iFilter = new Instruction.Filter(null, recursive, getDoNotCopy());
}
- Map<String, File> files = newMap();
+ Map<String,File> files = newMap();
resolveFiles(sourceFile, iFilter, recursive, destinationPath, files, flatten);
- for (Map.Entry<String, File> entry : files.entrySet()) {
+ for (Map.Entry<String,File> entry : files.entrySet()) {
copy(jar, entry.getKey(), entry.getValue(), preprocess, extra);
}
return destinationPath;
}
- private void resolveFiles(File dir, FileFilter filter, boolean recursive, String path,
- Map<String, File> files, boolean flatten) {
+ private void resolveFiles(File dir, FileFilter filter, boolean recursive, String path, Map<String,File> files,
+ boolean flatten) {
if (doNotCopy(dir.getName())) {
return;
@@ -951,8 +932,7 @@ public class Builder extends Analyzer {
resolveFiles(file, filter, recursive, nextPath, files, flatten);
}
// Directories are ignored otherwise
- }
- else {
+ } else {
String p = appendPath(path, file.getName());
if (files.containsKey(p))
warning("Include-Resource overwrites entry %s from file %s", p, file);
@@ -961,8 +941,8 @@ public class Builder extends Analyzer {
}
}
- private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source,
- String destinationPath) throws Exception {
+ private void noSuchFile(Jar jar, String clause, Map<String,String> extra, String source, String destinationPath)
+ throws Exception {
Jar src = getJarFromName(source, "Include-Resource " + source);
if (src != null) {
// Do not touch the manifest so this also
@@ -970,16 +950,14 @@ public class Builder extends Analyzer {
src.setDoNotTouchManifest();
JarResource jarResource = new JarResource(src);
jar.putResource(destinationPath, jarResource);
- }
- else {
+ } else {
Resource lastChance = make.process(source);
if (lastChance != null) {
String x = extra.get("extra");
if (x != null)
lastChance.setExtra(x);
jar.putResource(destinationPath, lastChance);
- }
- else
+ } else
error("Input file does not exist: " + source);
}
}
@@ -994,8 +972,8 @@ public class Builder extends Analyzer {
* @throws ZipException
* @throws IOException
*/
- private void extractFromJar(Jar jar, String source, String destination, boolean absentIsOk)
- throws ZipException, IOException {
+ private void extractFromJar(Jar jar, String source, String destination, boolean absentIsOk) throws ZipException,
+ IOException {
// Inline all resources and classes from another jar
// optionally appended with a modified regular expression
// like @zip.jar!/META-INF/MANIFEST.MF
@@ -1018,8 +996,7 @@ public class Builder extends Analyzer {
return;
error("Can not find JAR file " + source);
- }
- else {
+ } else {
addAll(jar, sub, instr, destination);
}
}
@@ -1027,8 +1004,10 @@ public class Builder extends Analyzer {
/**
* Add all the resources in the given jar that match the given filter.
*
- * @param sub the jar
- * @param filter a pattern that should match the resoures in sub to be added
+ * @param sub
+ * the jar
+ * @param filter
+ * a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar to, Jar sub, Instruction filter) {
return addAll(to, sub, filter, "");
@@ -1037,8 +1016,10 @@ public class Builder extends Analyzer {
/**
* Add all the resources in the given jar that match the given filter.
*
- * @param sub the jar
- * @param filter a pattern that should match the resoures in sub to be added
+ * @param sub
+ * the jar
+ * @param filter
+ * a pattern that should match the resoures in sub to be added
*/
public boolean addAll(Jar to, Jar sub, Instruction filter, String destination) {
boolean dupl = false;
@@ -1047,14 +1028,12 @@ public class Builder extends Analyzer {
continue;
if (filter == null || filter.matches(name) != filter.isNegated())
- dupl |= to.putResource(Processor.appendPath(destination, name),
- sub.getResource(name), true);
+ dupl |= to.putResource(Processor.appendPath(destination, name), sub.getResource(name), true);
}
return dupl;
}
- private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra)
- throws Exception {
+ private void copy(Jar jar, String path, File from, boolean preprocess, Map<String,String> extra) throws Exception {
if (doNotCopy(from.getName()))
return;
@@ -1064,8 +1043,7 @@ public class Builder extends Analyzer {
for (int i = 0; i < files.length; i++) {
copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra);
}
- }
- else {
+ } else {
if (from.exists()) {
Resource resource = new FileResource(from);
if (preprocess) {
@@ -1081,8 +1059,7 @@ public class Builder extends Analyzer {
if (isTrue(extra.get(LIB_DIRECTIVE))) {
setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
}
- }
- else {
+ } else {
error("Input file does not exist: " + from);
}
}
@@ -1242,16 +1219,15 @@ public class Builder extends Analyzer {
public String _maven_version(String args[]) {
if (args.length > 2)
error("${maven_version} macro receives too many arguments " + Arrays.toString(args));
- else
- if (args.length < 2)
- error("${maven_version} macro has no arguments, use ${maven_version;1.2.3-SNAPSHOT}");
- else {
- return cleanupVersion(args[1]);
- }
+ else if (args.length < 2)
+ error("${maven_version} macro has no arguments, use ${maven_version;1.2.3-SNAPSHOT}");
+ else {
+ return cleanupVersion(args[1]);
+ }
return null;
}
- public String _permissions(String args[]) throws IOException {
+ public String _permissions(String args[]) {
StringBuilder sb = new StringBuilder();
for (String arg : args) {
@@ -1268,16 +1244,12 @@ public class Builder extends Analyzer {
sb.append(exp);
sb.append("\" \"export\")\r\n");
}
- }
+ } else if ("admin".equals(arg) || "all".equals(arg)) {
+ sb.append("(org.osgi.framework.AdminPermission)");
+ } else if ("permissions".equals(arg))
+ ;
else
- if ("admin".equals(arg) || "all".equals(arg)) {
- sb.append("(org.osgi.framework.AdminPermission)");
- }
- else
- if ("permissions".equals(arg))
- ;
- else
- error("Invalid option in ${permissions}: %s", arg);
+ error("Invalid option in ${permissions}: %s", arg);
}
return sb.toString();
}
@@ -1293,7 +1265,7 @@ public class Builder extends Analyzer {
/**
* Check if the given resource is in scope of this bundle. That is, it
* checks if the Include-Resource includes this resource or if it is a class
- * file it is on the class path and the Export-Pacakge or Private-Package
+ * file it is on the class path and the Export-Package or Private-Package
* include this resource.
*
* @param f
@@ -1303,8 +1275,7 @@ public class Builder extends Analyzer {
Parameters clauses = parseHeader(getProperty(Constants.EXPORT_PACKAGE));
clauses.putAll(parseHeader(getProperty(Constants.PRIVATE_PACKAGE)));
if (isTrue(getProperty(Constants.UNDERTEST))) {
- clauses.putAll(parseHeader(getProperty(Constants.TESTPACKAGES,
- "test;presence:=optional")));
+ clauses.putAll(parseHeader(getProperty(Constants.TESTPACKAGES, "test;presence:=optional")));
}
Collection<String> ir = getIncludedResourcePrefixes();
@@ -1313,7 +1284,12 @@ public class Builder extends Analyzer {
for (File r : resources) {
String cpEntry = getClasspathEntrySuffix(r);
+
if (cpEntry != null) {
+
+ if (cpEntry.equals("")) // Meaning we actually have a CPE
+ return true;
+
String pack = Descriptors.getPackage(cpEntry);
Instruction i = matches(instructions, pack, null, r.getName());
if (i != null)
@@ -1340,7 +1316,7 @@ public class Builder extends Analyzer {
private Collection<String> getIncludedResourcePrefixes() {
List<String> prefixes = new ArrayList<String>();
Parameters includeResource = getIncludeResource();
- for (Entry<String, Attrs> p : includeResource.entrySet()) {
+ for (Entry<String,Attrs> p : includeResource.entrySet()) {
if (p.getValue().containsKey("literal"))
continue;
@@ -1354,19 +1330,26 @@ public class Builder extends Analyzer {
}
/**
- * Answer the string of the resource that it has in the container.
- *
- * @param resource The resource to look for
- * @return
+ * Answer the string of the resource that it has in the container. It is
+ * possible that the resource is a classpath entry. In that case an empty
+ * string is returned.
+ *
+ * @param resource
+ * The resource to look for
+ * @return A suffix on the classpath or "" if the resource is a class path
+ * entry
* @throws Exception
*/
public String getClasspathEntrySuffix(File resource) throws Exception {
for (Jar jar : getClasspath()) {
File source = jar.getSource();
if (source != null) {
+
source = source.getCanonicalFile();
String sourcePath = source.getAbsolutePath();
String resourcePath = resource.getAbsolutePath();
+ if (sourcePath.equals(resourcePath))
+ return ""; // Matches a classpath entry
if (resourcePath.startsWith(sourcePath)) {
// Make sure that the path name is translated correctly
@@ -1381,11 +1364,9 @@ public class Builder extends Analyzer {
}
/**
- * doNotCopy
- *
- * The doNotCopy variable maintains a patter for files that should not be
- * copied. There is a default {@link #DEFAULT_DO_NOT_COPY} but this ca be
- * overridden with the {@link Constants#DONOTCOPY} property.
+ * doNotCopy The doNotCopy variable maintains a patter for files that should
+ * not be copied. There is a default {@link #DEFAULT_DO_NOT_COPY} but this
+ * ca be overridden with the {@link Constants#DONOTCOPY} property.
*/
public boolean doNotCopy(String v) {
@@ -1442,7 +1423,7 @@ public class Builder extends Analyzer {
if (tree == null)
tree = differ.tree(this);
- for (Entry<String, Attrs> entry : diffs.entrySet()) {
+ for (Entry<String,Attrs> entry : diffs.entrySet()) {
String path = entry.getKey();
File file = getFile(path);
if (!file.isFile()) {
@@ -1470,11 +1451,9 @@ public class Builder extends Analyzer {
error("Differ %s", p);
else {
if (warning)
- warning("Diff found a difference in %s for packages %s", file,
- instructions);
+ warning("Diff found a difference in %s for packages %s", file, instructions);
else
- error("Diff found a difference in %s for packages %s", file,
- instructions);
+ error("Diff found a difference in %s for packages %s", file, instructions);
show(p, "", warning);
}
}
@@ -1529,7 +1508,7 @@ public class Builder extends Analyzer {
Baseline baseline = new Baseline(this, differ);
- for (Entry<String, Attrs> entry : diffs.entrySet()) {
+ for (Entry<String,Attrs> entry : diffs.entrySet()) {
String path = entry.getKey();
File file = getFile(path);
if (!file.isFile()) {
@@ -1540,9 +1519,8 @@ public class Builder extends Analyzer {
Set<Info> infos = baseline.baseline(dot, other, null);
for (Info info : infos) {
if (info.mismatch) {
- error("%s %-50s %-10s %-10s %-10s %-10s %-10s\n", info.mismatch ? '*' : ' ',
- info.packageName, info.packageDiff.getDelta(), info.newerVersion,
- info.olderVersion, info.suggestedVersion,
+ error("%s %-50s %-10s %-10s %-10s %-10s %-10s\n", info.mismatch ? '*' : ' ', info.packageName,
+ info.packageDiff.getDelta(), info.newerVersion, info.olderVersion, info.suggestedVersion,
info.suggestedIfProviders == null ? "-" : info.suggestedIfProviders);
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/BundleId.java Fri Jun 15 13:27:53 2012
@@ -1,9 +1,7 @@
package aQute.lib.osgi;
-
/**
* Holds the bundle bsn + version pair
- *
*/
public class BundleId implements Comparable<BundleId> {
final String bsn;
@@ -29,16 +27,16 @@ public class BundleId implements Compara
public boolean equals(Object o) {
return this == o || ((o instanceof BundleId) && compareTo((BundleId) o) == 0);
}
-
+
public int hashCode() {
return bsn.hashCode() ^ version.hashCode();
}
public int compareTo(BundleId other) {
int result = bsn.compareTo(other.bsn);
- if ( result != 0)
+ if (result != 0)
return result;
-
+
return version.compareTo(other.version);
}
}
Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/osgi/ClassDataCollector.java Fri Jun 15 13:27:53 2012
@@ -3,89 +3,81 @@ package aQute.lib.osgi;
import aQute.lib.osgi.Descriptors.TypeRef;
public class ClassDataCollector {
- public void classBegin(int access, TypeRef name) {
- }
+ public void classBegin(int access, TypeRef name) {}
- public boolean classStart(int access, TypeRef className) {
- classBegin(access,className);
- return true;
- }
-
- public void extendsClass(TypeRef zuper) throws Exception {
- }
+ public boolean classStart(int access, TypeRef className) {
+ classBegin(access, className);
+ return true;
+ }
- public void implementsInterfaces(TypeRef[] interfaces) throws Exception {
- }
+ public void extendsClass(TypeRef zuper) throws Exception {}
- public void addReference(TypeRef ref) {
- }
+ public void implementsInterfaces(TypeRef[] interfaces) throws Exception {}
- public void annotation(Annotation annotation) {
- }
+ public void addReference(TypeRef ref) {}
- public void parameter(int p) {
- }
+ public void annotation(Annotation annotation) {}
- public void method(Clazz.MethodDef defined) {
- }
+ public void parameter(int p) {}
- public void field(Clazz.FieldDef defined) {
- }
+ public void method(Clazz.MethodDef defined) {}
- public void reference(Clazz.MethodDef referenced) {
- }
+ public void field(Clazz.FieldDef defined) {}
- public void reference(Clazz.FieldDef referenced) {
- }
+ public void reference(Clazz.MethodDef referenced) {}
- public void classEnd() throws Exception {
- }
+ public void reference(Clazz.FieldDef referenced) {}
- public void deprecated() throws Exception {
- }
+ public void classEnd() throws Exception {}
+ public void deprecated() throws Exception {}
- /**
- * The EnclosingMethod attribute
- *
- * @param cName The name of the enclosing class, never null. Name is with slashes.
- * @param mName The name of the enclosing method in the class with cName or null
- * @param mDescriptor The descriptor of this type
- */
+ /**
+ * The EnclosingMethod attribute
+ *
+ * @param cName
+ * The name of the enclosing class, never null. Name is with
+ * slashes.
+ * @param mName
+ * The name of the enclosing method in the class with cName or
+ * null
+ * @param mDescriptor
+ * The descriptor of this type
+ */
public void enclosingMethod(TypeRef cName, String mName, String mDescriptor) {
-
+
}
/**
* The InnerClass attribute
*
- * @param innerClass The name of the inner class (with slashes). Can be null.
- * @param outerClass The name of the outer class (with slashes) Can be null.
- * @param innerName The name inside the outer class, can be null.
- * @param modifiers The access flags
- * @throws Exception
+ * @param innerClass
+ * The name of the inner class (with slashes). Can be null.
+ * @param outerClass
+ * The name of the outer class (with slashes) Can be null.
+ * @param innerName
+ * The name inside the outer class, can be null.
+ * @param modifiers
+ * The access flags
+ * @throws Exception
*/
- public void innerClass(TypeRef innerClass, TypeRef outerClass, String innerName,
- int innerClassAccessFlags) throws Exception {
- }
+ public void innerClass(TypeRef innerClass, TypeRef outerClass, String innerName, int innerClassAccessFlags)
+ throws Exception {}
- public void signature(String signature) {
- }
+ public void signature(String signature) {}
- public void constant(Object object) {
- }
+ public void constant(Object object) {}
- public void memberEnd() {
- }
+ public void memberEnd() {}
public void version(int minor, int major) {
// TODO Auto-generated method stub
-
+
}
public void referenceMethod(int access, TypeRef className, String method, String descriptor) {
// TODO Auto-generated method stub
-
+
}
}