import java.lang.System.Logger.Level;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
throw new IllegalArgumentException(this.descriptorsBase + " does not exist");
this.includeSources = includeSources;
+ // URIs mapping
Path urisPath = this.descriptorsBase.resolve("uris.properties");
if (Files.exists(urisPath)) {
try (InputStream in = Files.newInputStream(urisPath)) {
}
}
- // TODO make it configurable
+ // Eclipse mirrors
+ Path eclipseMirrorsPath = this.descriptorsBase.resolve("eclipse.mirrors.txt");
List<String> eclipseMirrors = new ArrayList<>();
- eclipseMirrors.add("https://archive.eclipse.org/");
- eclipseMirrors.add("http://ftp-stud.hs-esslingen.de/Mirrors/eclipse/");
- eclipseMirrors.add("http://ftp.fau.de/eclipse/");
+ if (Files.exists(eclipseMirrorsPath)) {
+ try {
+ eclipseMirrors = Files.readAllLines(eclipseMirrorsPath, StandardCharsets.UTF_8);
+ } catch (IOException e) {
+ throw new IllegalStateException("Cannot load " + eclipseMirrorsPath, e);
+ }
+ for (Iterator<String> it = eclipseMirrors.iterator(); it.hasNext();) {
+ String value = it.next();
+ if (value.strip().equals(""))
+ it.remove();
+ }
+ }
mirrors.put("http://www.eclipse.org/downloads", eclipseMirrors);
}
if (includeMatcher.matches(file)) {
for (PathMatcher excludeMatcher : excludeMatchers) {
if (excludeMatcher.matches(file)) {
- logger.log(Level.WARNING, "Skipping excluded " + file);
+ logger.log(Level.TRACE, "Skipping excluded " + file);
return FileVisitResult.CONTINUE;
}
}
Manifest sourceManifest = jarIn.getManifest();
Manifest manifest = sourceManifest != null ? new Manifest(sourceManifest) : new Manifest();
+ // singleton
+ boolean isSingleton = false;
+ String rawSourceSymbolicName = manifest.getMainAttributes()
+ .getValue(ManifestConstants.BUNDLE_SYMBOLICNAME.toString());
+ if (rawSourceSymbolicName != null) {
+
+ // make sure there is no directive
+ String[] arr = rawSourceSymbolicName.split(";");
+ for (int i = 1; i < arr.length; i++) {
+ if (arr[i].trim().equals("singleton:=true"))
+ isSingleton = true;
+ logger.log(DEBUG, file.getFileName() + " is a singleton");
+ }
+ }
+
// remove problematic entries in MANIFEST
manifest.getEntries().clear();
// copy MANIFEST
Path manifestPath = targetBundleDir.resolve("META-INF/MANIFEST.MF");
Files.createDirectories(manifestPath.getParent());
+
+ if (isSingleton && entries.containsKey(BUNDLE_SYMBOLICNAME.toString())) {
+ entries.put(BUNDLE_SYMBOLICNAME.toString(),
+ entries.get(BUNDLE_SYMBOLICNAME.toString()) + ";singleton:=true");
+ }
+
for (String key : entries.keySet()) {
String value = entries.get(key);
Object previousValue = manifest.getMainAttributes().putValue(key, value);
manifest = new Manifest(in);
}
try (JarOutputStream jarOut = new JarOutputStream(Files.newOutputStream(jarPath), manifest)) {
- jarOut.setLevel(Deflater.NO_COMPRESSION);
+ jarOut.setLevel(Deflater.DEFAULT_COMPRESSION);
Files.walkFileTree(bundleDir, new SimpleFileVisitor<Path>() {
@Override