+ }
+
+ // add legal notices and licenses
+ for (Path p : listLegalFilesToInclude(source).values()) {
+ jarOut.putNextEntry(new JarEntry(p.getFileName().toString()));
+ Files.copy(p, jarOut);
+ }
+ }
+
+ if (sourceBundles) {// create separate sources jar
+ Path a2srcJarDirectory = bundleParent != null ? a2srcOutput.resolve(bundleParent).resolve(category)
+ : a2srcOutput.resolve(category);
+ Files.createDirectories(a2srcJarDirectory);
+ Path srcJarP = a2srcJarDirectory.resolve(compiled.getFileName() + "." + major + "." + minor + ".src.jar");
+ Manifest srcManifest = new Manifest();
+ srcManifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ srcManifest.getMainAttributes().putValue("Bundle-SymbolicName", bundleSymbolicName + ".src");
+ srcManifest.getMainAttributes().putValue("Bundle-Version",
+ manifest.getMainAttributes().getValue("Bundle-Version").toString());
+
+ boolean isJsBundle = bundleSymbolicName.endsWith(".js");
+ if (!isJsBundle) {
+ srcManifest.getMainAttributes().putValue("Eclipse-SourceBundle",
+ bundleSymbolicName + ";version=\"" + manifest.getMainAttributes().getValue("Bundle-Version"));
+
+ try (JarOutputStream srcJarOut = new JarOutputStream(Files.newOutputStream(srcJarP), srcManifest)) {
+ copySourcesToJar(srcP, srcJarOut, "");
+ // add legal notices and licenses
+ for (Path p : listLegalFilesToInclude(source).values()) {
+ srcJarOut.putNextEntry(new JarEntry(p.getFileName().toString()));
+ Files.copy(p, srcJarOut);
+ }
+ }
+ } else {// JavaScript source maps
+ srcManifest.getMainAttributes().putValue("Fragment-Host",
+ bundleSymbolicName + ";version=\"" + manifest.getMainAttributes().getValue("Bundle-Version"));
+ try (JarOutputStream srcJarOut = new JarOutputStream(Files.newOutputStream(srcJarP), srcManifest)) {
+ Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Path relativeP = source.relativize(file);
+ if (!file.getFileName().toString().endsWith(".map"))
+ return FileVisitResult.CONTINUE;
+ JarEntry entry = new JarEntry(relativeP.toString());
+ srcJarOut.putNextEntry(entry);
+ Files.copy(file, srcJarOut);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+ }
+ }
+ }