use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class VerifierTest method testCapability.
public static void testCapability() throws Exception {
Parameters h = OSGiHeader.parseHeader("test; version.list:List < Version > = \"1.0, 1.1, 1.2\"; effective:=\"resolve\"; test =\"aName\";version : Version=\"1.0\"; long :Long=\"100\"; " + "double: Double=\"1.001\"; string:String =\"aString\"; " + "long.list : List <Long >=\"1, 2, 3, 4\";double.list: List< Double>= \"1.001, 1.002, 1.003\"; " + "string.list :List<String >= \"aString,bString,cString\"");
assertEquals(Attrs.Type.VERSION, h.get("test").getType("version"));
assertEquals(Attrs.Type.LONG, h.get("test").getType("long"));
assertEquals(Attrs.Type.DOUBLE, h.get("test").getType("double"));
assertEquals(Attrs.Type.STRING, h.get("test").getType("string"));
assertEquals(Attrs.Type.STRING, h.get("test").getType("test"));
assertEquals(Attrs.Type.LONGS, h.get("test").getType("long.list"));
assertEquals(Attrs.Type.DOUBLES, h.get("test").getType("double.list"));
assertEquals(Attrs.Type.STRINGS, h.get("test").getType("string.list"));
assertEquals(Attrs.Type.VERSIONS, h.get("test").getType("version.list"));
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class ConnectionSettings method readSettings.
public void readSettings() throws Exception {
File tmp = null;
try {
Parameters connectionSettings = new Parameters(mergeProperties(CONNECTION_SETTINGS), getParent());
if (connectionSettings.isEmpty()) {
File file = aQute.lib.io.IO.getFile(BND_CONNECTION_SETTINGS_XML);
if (!file.isFile()) {
file = aQute.lib.io.IO.getFile(M2_SETTINGS_XML);
if (!file.isFile()) {
return;
}
}
parse(file);
return;
}
for (Map.Entry<String, Attrs> entry : connectionSettings.entrySet()) {
String key = entry.getKey();
if ("false".equalsIgnoreCase(key))
continue;
switch(key) {
case "maven":
key = M2_SETTINGS_XML;
break;
case "bnd":
key = BND_CONNECTION_SETTINGS_XML;
break;
case "env":
Attrs attrs = entry.getValue();
String variable = attrs.get("var");
if (variable == null) {
getParent().error("Specified -connection-settings: %s, with 'env' but the 'var' parameter is no found", connectionSettings);
} else {
String value = System.getenv(key);
if (value != null) {
tmp = File.createTempFile("tmp", ".bnd");
IO.store(value, tmp);
key = tmp.getAbsolutePath();
} else
getParent().error("Specified -connection-settings: %s, but no such environment variable %s is found", connectionSettings, key);
}
break;
}
boolean ignoreError = false;
if (key.startsWith("-")) {
ignoreError = true;
key = key.substring(1);
}
key = Processor.removeDuplicateMarker(key);
if ("server".equals(key)) {
parseServer(entry.getValue());
} else {
File file = getParent() != null ? IO.getFile(key) : getParent().getFile(key);
if (!file.isFile()) {
if (!ignoreError) {
SetLocation error = getParent().error("Specified -connection-settings: %s, but no such file or is directory", file);
FileLine header = getParent().getHeader(CONNECTION_SETTINGS, key);
if (header != null)
header.set(error);
}
} else
parse(file);
}
}
} finally {
if (tmp != null)
IO.delete(tmp);
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class DiffPluginImpl method setIgnore.
public void setIgnore(String diffignore) {
if (diffignore == null) {
localIgnore = null;
return;
}
Parameters p = new Parameters(diffignore);
localIgnore = new Instructions(p);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class DiffPluginImpl method manifestElement.
/**
* Create an element for each manifest header. There are
* {@link #IGNORE_HEADERS} and {@link #MAJOR_HEADERS} that will be treated
* differently.
*
* @param manifest
* @return the created {@code Element}
*/
private Element manifestElement(Manifest manifest) {
List<Element> result = new ArrayList<Element>();
for (Object key : manifest.getMainAttributes().keySet()) {
String header = key.toString();
String value = manifest.getMainAttributes().getValue(header);
if (IGNORE_HEADERS.contains(header))
continue;
if (localIgnore != null && localIgnore.matches(header)) {
continue;
}
if (MAJOR_HEADERS.contains(header)) {
if (header.equalsIgnoreCase(Constants.BUNDLE_VERSION)) {
Version v = new Version(value).getWithoutQualifier();
result.add(new Element(Type.HEADER, header + ":" + v.toString(), null, CHANGED, CHANGED, null));
} else {
Parameters clauses = OSGiHeader.parseHeader(value);
Collection<Element> clausesDef = new ArrayList<Element>();
for (Map.Entry<String, Attrs> clause : clauses.entrySet()) {
Collection<Element> parameterDef = new ArrayList<Element>();
for (Map.Entry<String, String> parameter : clause.getValue().entrySet()) {
String paramValue = parameter.getValue();
if (Constants.EXPORT_PACKAGE.equals(header) && Constants.USES_DIRECTIVE.equals(parameter.getKey())) {
ExtList<String> uses = ExtList.from(parameter.getValue());
Collections.sort(uses);
paramValue = uses.join();
}
parameterDef.add(new Element(Type.PARAMETER, parameter.getKey() + ":" + paramValue, null, CHANGED, CHANGED, null));
}
clausesDef.add(new Element(Type.CLAUSE, clause.getKey(), parameterDef, CHANGED, CHANGED, null));
}
result.add(new Element(Type.HEADER, header, clausesDef, CHANGED, CHANGED, null));
}
} else if (ORDERED_HEADERS.contains(header)) {
ExtList<String> values = ExtList.from(value);
Collections.sort(values);
result.add(new Element(Type.HEADER, header + ":" + values.join(), null, CHANGED, CHANGED, null));
} else {
result.add(new Element(Type.HEADER, header + ":" + value, null, CHANGED, CHANGED, null));
}
}
return new Element(Type.MANIFEST, "<manifest>", result, CHANGED, CHANGED, null);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Make method getMakeHeader.
Map<Instruction, Map<String, String>> getMakeHeader() {
if (make != null)
return make;
make = Processor.newMap();
Parameters make = builder.getMergedParameters(Builder.MAKE);
for (Entry<String, Attrs> entry : make.entrySet()) {
String pattern = Processor.removeDuplicateMarker(entry.getKey());
Instruction instr = new Instruction(pattern);
this.make.put(instr, entry.getValue());
}
return this.make;
}
Aggregations