- // if (sourcesProvider != null) {
- // IOUtils.closeQuietly(in);
- // in = new ByteArrayInputStream(out.toByteArray());
- // jar = new Jar(null, in);
- // List<String> packages = jar.getPackages();
- //
- // IOUtils.closeQuietly(out);
- // out = new ByteArrayOutputStream();
- // sourcesProvider
- // .writeSources(packages, new ZipOutputStream(out));
- //
- // IOUtils.closeQuietly(in);
- // in = new ByteArrayInputStream(out.toByteArray());
- // byte[] sourcesJar = RepoUtils.packageAsPdeSource(in,
- // new DefaultNameVersion(this));
- // Artifact sourcesArtifact = new DefaultArtifact(getArtifact()
- // .getGroupId(), getArtifact().getArtifactId()
- // + ".source", "jar", getArtifact().getVersion());
- // Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(
- // javaSession.getRootNode(), sourcesArtifact, sourcesJar);
- // sourcesJarNode.getSession().save();
- //
- // if (log.isDebugEnabled())
- // log.debug("Added sources " + sourcesArtifact
- // + " for bundle " + getArtifact());
- // }
+ if (sourcesProvider != null) {
+ IOUtils.closeQuietly(in);
+ in = new ByteArrayInputStream(out.toByteArray());
+ jar = new Jar(null, in);
+ List<String> packages = jar.getPackages();
+
+ IOUtils.closeQuietly(out);
+ out = new ByteArrayOutputStream();
+ sourcesProvider
+ .writeSources(packages, new ZipOutputStream(out));
+
+ IOUtils.closeQuietly(in);
+ in = new ByteArrayInputStream(out.toByteArray());
+ byte[] sourcesJar = RepoUtils.packageAsPdeSource(in,
+ new DefaultNameVersion(this));
+ Artifact sourcesArtifact = new DefaultArtifact(getArtifact()
+ .getGroupId(), getArtifact().getArtifactId()
+ + ".source", "jar", getArtifact().getVersion());
+ Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(
+ javaSession.getRootNode(), sourcesArtifact, sourcesJar);
+ sourcesJarNode.getSession().save();
+
+ if (log.isDebugEnabled())
+ log.debug("Added sources " + sourcesArtifact
+ + " for bundle " + getArtifact());
+ }