Skip to content

Commit

Permalink
Issue #175, complaint that the range macro did not
Browse files Browse the repository at this point in the history
properly work since it was expanded too early, before
the implicit @ version was set. The range macro now
fails if there is no implicit version nor an explicit
this will make the macro return itself.
  • Loading branch information
pkriens committed May 24, 2012
1 parent 6530747 commit b048e1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
4 changes: 3 additions & 1 deletion biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java
Expand Up @@ -305,10 +305,12 @@ public void testVersionPolicy() throws Exception {
public void testImportMicroNotTruncated() throws Exception {
Builder b = new Builder();
b.addClasspath(new File("jar/osgi.jar"));
b.setProperty("Import-Package", "org.osgi.service.event;version=${@}");
b.setProperty("Import-Package", "org.osgi.service.event;version=${@}, org.osgi.service.log;version=\"${range;[==,=+)}\"");
b.build();
String s = b.getImports().getByFQN("org.osgi.service.event").get("version");
String l = b.getImports().getByFQN("org.osgi.service.log").get("version");
assertEquals("1.0.1", s);
assertEquals("[1.3,1.4)", l);
}

}
23 changes: 15 additions & 8 deletions biz.aQute.bndlib/src/aQute/lib/osgi/Macro.java
Expand Up @@ -316,10 +316,10 @@ public String _join(String args[]) {
public String _if(String args[]) {
verifyCommand(args, _ifHelp, null, 3, 4);
String condition = args[1].trim();
if ( !condition.equalsIgnoreCase("false"))
if (!condition.equalsIgnoreCase("false"))
if (condition.length() != 0)
return args[2];

if (args.length > 3)
return args[3];
else
Expand Down Expand Up @@ -739,7 +739,12 @@ public String _range(String args[]) {
Version version = null;
if (args.length >= 3)
version = new Version(args[2]);

else {
String v = domain.getProperty("@");
if (v == null)
return null;
version = new Version(v);
}
String spec = args[1];

Matcher m = RANGE_MASK.matcher(spec);
Expand All @@ -749,11 +754,13 @@ public String _range(String args[]) {
String ceilingMask = m.group(3);
String ceiling = m.group(4);

String left = version(version, floorMask);
String right = version(version, ceilingMask);
StringBuilder sb = new StringBuilder();
sb.append(floor);
sb.append(version(version, floorMask));
sb.append(left);
sb.append(",");
sb.append(version(version, ceilingMask));
sb.append(right);
sb.append(ceiling);

String s = sb.toString();
Expand Down Expand Up @@ -792,9 +799,9 @@ public String system_internal(boolean allowFail, String args[]) throws Exception

String s = IO.collect(process.getInputStream(), "UTF-8");
int exitValue = process.waitFor();
if ( exitValue != 0)
return exitValue+"";
if (exitValue != 0)
return exitValue + "";

if (!allowFail && (exitValue != 0)) {
domain.error("System command " + command + " failed with " + exitValue);
}
Expand Down
14 changes: 13 additions & 1 deletion biz.aQute.bndlib/src/aQute/lib/osgi/Processor.java
Expand Up @@ -769,7 +769,19 @@ public static boolean isTrue(String value) {
}

/**
* Get a property with a proper default
* Get a property without preprocessing it with a proper default
*
* @param headerName
* @param deflt
* @return
*/

public String getUnprocessedProperty(String key, String deflt) {
return getProperties().getProperty(key, deflt);
}

/**
* Get a property with preprocessing it with a proper default
*
* @param headerName
* @param deflt
Expand Down

0 comments on commit b048e1e

Please sign in to comment.