NameVersion nv = RepoUtils.readNameVersion(jis
.getManifest());
if (nv != null) {
+ if (nv.getName().endsWith(".source"))
+ continue entries;
CategorizedNameVersion cnv = new OsgiCategorizedNV(
groupId, nv.getName(), nv.getVersion(),
this);
if (log.isDebugEnabled())
log.debug("Wrapping " + uri);
+ boolean nothingWasDone = true;
Node distNode = osgiFactory.getDist(distSession, uri);
zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
wrapper.getName(), wrapper.getVersion());
byte[] pdeSource = RepoUtils.packageAsPdeSource(zin,
bundleNv);
+ Artifact sourcesArtifact = new DefaultArtifact(
+ wrapper.getCategory(), wrapper.getName()
+ + ".source", "jar",
+ wrapper.getVersion());
Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(
- javaSession.getRootNode(),
- new DefaultArtifact(wrapper.getCategory(),
- wrapper.getName() + ".source", "jar",
- wrapper.getVersion()), pdeSource);
+ javaSession.getRootNode(), sourcesArtifact,
+ pdeSource);
osgiFactory.indexNode(pdeSourceNode);
pdeSourceNode.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Added sources " + sourcesArtifact
+ + " for bundle " + wrapper.getArtifact()
+ + "from " + name + " in binary archive.");
}
- } else if (baseName.endsWith(".source")) {
- // TODO Eclipse source already available
+
}
+ // else if (baseName.endsWith(".source")) {
+ // }
// binaries
if (wrappers.containsKey(name)) {
BndWrapper wrapper = (BndWrapper) wrappers.get(name);
// we must copy since the stream is closed by BND
- byte[] sourceJarBytes = IOUtils.toByteArray(zin);
+ byte[] origJarBytes = IOUtils.toByteArray(zin);
Artifact artifact = wrapZipEntry(javaSession, zentry,
- sourceJarBytes, wrapper);
+ origJarBytes, wrapper);
+ nothingWasDone = false;
addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
} else {
for (String wrapperKey : wrappers.keySet())
BndWrapper wrapper = (BndWrapper) wrappers
.get(wrapperKey);
// we must copy since the stream is closed by BND
- byte[] sourceJarBytes = IOUtils.toByteArray(zin);
+ byte[] origJarBytes = IOUtils.toByteArray(zin);
Artifact artifact = wrapZipEntry(javaSession,
- zentry, sourceJarBytes, wrapper);
+ zentry, origJarBytes, wrapper);
+ nothingWasDone = false;
addArtifactToIndex(binaries, wrapper.getGroupId(),
artifact);
continue entries;
for (String include : includes.keySet()) {
if (pathMatcher.match(include, name)) {
String groupId = includes.get(include);
- byte[] sourceJarBytes = IOUtils.toByteArray(zin);
+ byte[] origJarBytes = IOUtils.toByteArray(zin);
Artifact artifact = importZipEntry(javaSession,
- zentry, sourceJarBytes, groupId);
+ zentry, origJarBytes, groupId);
if (artifact == null) {
log.warn("Skipped non identified " + zentry);
continue entries;
}
+ nothingWasDone = false;
if (artifact.getArtifactId().endsWith(".source"))
addArtifactToIndex(sources, groupId, artifact);
else
}
}
+ if (nothingWasDone)
+ throw new SlcException("Nothing was done");
+
// FIXME Fail if not all wrappers matched
} catch (Exception e) {
throw new SlcException("Cannot wrap distribution " + uri, e);
}
protected Artifact wrapZipEntry(Session javaSession, ZipEntry zentry,
- byte[] sourceJarBytes, BndWrapper wrapper)
- throws RepositoryException {
+ byte[] origJarBytes, BndWrapper wrapper) throws RepositoryException {
ByteArrayOutputStream out = null;
ByteArrayInputStream in = null;
Node newJarNode;
Jar jar = null;
try {
out = new ByteArrayOutputStream((int) zentry.getSize());
- in = new ByteArrayInputStream(sourceJarBytes);
+ in = new ByteArrayInputStream(origJarBytes);
wrapper.wrapJar(in, out);
Artifact artifact = wrapper.getArtifact();
}
protected void addSource(Session javaSession, Artifact artifact,
- byte[] jarBytes) {
+ byte[] binaryJarBytes) {
InputStream in = null;
ByteArrayOutputStream out = null;
Jar jar = null;
try {
- in = new ByteArrayInputStream(jarBytes);
+ in = new ByteArrayInputStream(binaryJarBytes);
jar = new Jar(null, in);
List<String> packages = jar.getPackages();
if (log.isDebugEnabled())
log.debug("Added sources " + sourcesArtifact + " for bundle "
- + artifact);
+ + artifact + "from source provider " + sourcesProvider);
} catch (Exception e) {
throw new SlcException("Cannot get sources for " + artifact, e);
} finally {
}
protected Artifact importZipEntry(Session javaSession, ZipEntry zentry,
- byte[] jarBytes, String groupId) throws RepositoryException {
+ byte[] binaryJarBytes, String groupId) throws RepositoryException {
ByteArrayInputStream in = null;
Node newJarNode;
try {
- in = new ByteArrayInputStream(jarBytes);
+ in = new ByteArrayInputStream(binaryJarBytes);
NameVersion nameVersion = RepoUtils.readNameVersion(in);
if (nameVersion == null) {
return null;
Artifact artifact = new DefaultArtifact(groupId,
nameVersion.getName(), "jar", nameVersion.getVersion());
newJarNode = RepoUtils.copyBytesAsArtifact(
- javaSession.getRootNode(), artifact, jarBytes);
+ javaSession.getRootNode(), artifact, binaryJarBytes);
osgiFactory.indexNode(newJarNode);
newJarNode.getSession().save();
if (log.isDebugEnabled())
+ newJarNode.getPath());
if (sourcesProvider != null)
- addSource(javaSession, artifact, jarBytes);
+ addSource(javaSession, artifact, binaryJarBytes);
return artifact;
} finally {