this.file = resource.getFile();
this.relPath = resource.getName();
// The version derived from the file name, to be checked against
// the version from the manifest.
Version nameVersion = null;
// Derive bundle name from the file name
final String fileName = file.getName();
String bn = null;
// The file name format is "<bundleName>-<version>.jar"
final int ix = fileName.lastIndexOf('-');
if (0 < ix) {
bn = fileName.substring(0, ix);
final String versionS = fileName.substring(ix + 1,
fileName.length() - 4);
try {
nameVersion = new Version(versionS);
} catch (NumberFormatException nfe) {
bn = null; // Not valid due to missing version.
task.log("Invalid version in bundle file name '" + versionS + "': "
+ nfe, Project.MSG_VERBOSE);
}
} else {
// No version in file name, just remove the ".jar"-suffix
bn = fileName.substring(0, fileName.length() - 4);
}
final JarFile bundle = new JarFile(file);
try {
final Manifest manifest = bundle.getManifest();
this.mainAttributes = manifest.getMainAttributes();
this.manifestVersion = deriveBundleManifestVersion();
this.bsn = deriveBundleSymbolicName();
this.version = deriveBundleVersion();
this.name = mainAttributes.getValue(Constants.BUNDLE_NAME);
int count = 0;
for (Enumeration e = bundle.entries(); e.hasMoreElements();) {
ZipEntry entry = (ZipEntry) e.nextElement();
if (entry.getName().startsWith(SRC_PREFIX)) {
count++;
}
}
srcCount = count;
} finally {
if (null != bundle) {
try {
bundle.close();
} catch (IOException _ioe) {
}
}
}
// Compare version from the file name with the one from the manifest
if (null != nameVersion && 0 != nameVersion.compareTo(version)) {
if (nameVersion.getMajor() == version.getMajor()
&& nameVersion.getMinor() == version.getMinor()
&& nameVersion.getMicro() == version.getMicro()
&& "".equals(nameVersion.getQualifier())) {
task.log("Found version '" + nameVersion + "' in the file name '"
+ fileName + "', but the version in the bundle's manifest "
+ "has qualifier '" + version + "'.", Project.MSG_DEBUG);
} else {
task.log("Found version '" + nameVersion + "' in the file name '"