Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Cannot Reproduce
-
maven-scr-plugin-1.2.0
-
None
Description
When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
protected Manifest getManifest(Artifact artifact) throws IOException {
if (!this.isJavaArtifact(artifact))
if ("bundle".equals(artifact.getType()))
{ return getManifestFromBundle(artifact); }return getManifestFromJarFile(artifact);
}
private Manifest getManifestFromBundle(Artifact artifact)
throws FileNotFoundException, IOException {
//artifact.getFile() returns
/META-INF/MANIFEST.MF
File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
FileInputStream manifestInputStream = null;
try
finally {
if (manifestInputStream != null) {
try
catch (IOException ignore) {
}
}
}
}
private Manifest getManifestFromJarFile(Artifact artifact)
throws IOException {
JarFile file = null;
try
finally {
if (file != null) {
try
catch (IOException ignore) {
}
}
}
}
protected File getFile(Artifact artifact, String path) throws IOException {
if ("bundle".equals(artifact.getType()))
return getFileFromJar(artifact, path);
}
private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
//artifact.getFile() returns
/path
File file = artifact.getFile();
File targetFile = new File(file.getParentFile().getParentFile(),path);
if (targetFile.canRead())
log.warn("Won't be able to read: " + targetFile);
return null;
}
private File getFileFromJar(Artifact artifact, String path)
throws IOException, FileNotFoundException {
final int pos = path.lastIndexOf('.');
final String suffix = path.substring(pos + 1);
JarFile file = null;
File tmpFile = null;
try {
file = new JarFile(artifact.getFile());
final JarEntry entry = file.getJarEntry(path);
if ( entry != null )
return null;
} finally {
if (file != null) {
try
catch (IOException ignore) {
}
}
}
}