if (!FileUtil.createParentDirs(outputJar)) {
throw new OsgiBuildException("Can't create output directory for '" + outputJar + "'");
}
try {
Analyzer analyzer = new ReportingAnalyzer(myReporter);
analyzer.setPedantic(false);
analyzer.setJar(inputJar);
analyzer.putAll(properties, false);
if (analyzer.getProperty(Constants.IMPORT_PACKAGE) == null) {
analyzer.setProperty(Constants.IMPORT_PACKAGE, "*;resolution:=optional");
}
if (analyzer.getProperty(Constants.BUNDLE_SYMBOLICNAME) == null) {
Pattern p = Pattern.compile("(" + Verifier.SYMBOLICNAME.pattern() + ")(-[0-9])?.*\\.jar");
Matcher m = p.matcher(inputJar.getName());
if (!m.matches()) {
throw new OsgiBuildException("Can't calculate output bundle name for '" + inputJar + "' - rename file or use -properties");
}
analyzer.setProperty(Constants.BUNDLE_SYMBOLICNAME, m.group(1));
}
if (analyzer.getProperty(Constants.EXPORT_PACKAGE) == null) {
analyzer.setProperty(Constants.EXPORT_PACKAGE, "*");
}
JarFile jarFile = new JarFile(inputJar);
try {
analyzer.mergeManifest(jarFile.getManifest());
}
finally {
jarFile.close();
}
String version = analyzer.getProperty(Constants.BUNDLE_VERSION);
if (version != null) {
version = Analyzer.cleanupVersion(version);
analyzer.setProperty(Constants.BUNDLE_VERSION, version);
}
analyzer.calcManifest();
Jar jar = analyzer.getJar();
jar.write(outputJar);
jar.close();
analyzer.close();
}
catch (OsgiBuildException e) {
throw e;
}
catch (Exception e) {