private final static String COMMON_BND = "common.bnd";
private Path originBase;
- private Path factoryBase;
+ private Path a2Base;
/** key is URI prefix, value list of base URLs */
private Map<String, List<String>> mirrors = new HashMap<String, List<String>>();
- public A2Factory(Path originBase, Path factoryBase) {
- super();
- this.originBase = originBase;
- this.factoryBase = factoryBase;
+ public A2Factory(Path a2Base) {
+ this.originBase = Paths.get(System.getProperty("user.home"), ".cache", "argeo/slc/origin");
+ this.a2Base = a2Base;
// TODO make it configurable
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/");
mirrors.put("http://www.eclipse.org/downloads", eclipseMirrors);
}
public void processSingleM2ArtifactDistributionUnit(Path bndFile) {
try {
String category = bndFile.getParent().getFileName().toString();
- Path targetCategoryBase = factoryBase.resolve(category);
+ Path targetCategoryBase = a2Base.resolve(category);
Properties fileProps = new Properties();
try (InputStream in = Files.newInputStream(bndFile)) {
fileProps.load(in);
public void processM2BasedDistributionUnit(Path duDir) {
try {
String category = duDir.getParent().getFileName().toString();
- Path targetCategoryBase = factoryBase.resolve(category);
+ Path targetCategoryBase = a2Base.resolve(category);
Path commonBnd = duDir.resolve(COMMON_BND);
Properties commonProps = new Properties();
try (InputStream in = Files.newInputStream(commonBnd)) {
}
String m2Version = commonProps.getProperty(SLC_ORIGIN_M2.toString());
+ if (m2Version == null) {
+ logger.log(Level.WARNING, "Ignoring " + duDir + " as it is not an M2-based distribution unit");
+ return;// ignore, this is probably an Eclipse archive
+ }
if (!m2Version.startsWith(":")) {
throw new IllegalStateException("Only the M2 version can be specified: " + m2Version);
}
boolean doNotModify = Boolean.parseBoolean(fileProps
.getOrDefault(ManifestConstants.SLC_ORIGIN_MANIFEST_NOT_MODIFIED.toString(), "false").toString());
+ // we always force the symbolic name
+
if (doNotModify) {
fileEntries: for (Object key : fileProps.keySet()) {
if (ManifestConstants.SLC_ORIGIN_M2.toString().equals(key))
public void processEclipseArchive(Path duDir) {
try {
String category = duDir.getParent().getFileName().toString();
- Path targetCategoryBase = factoryBase.resolve(category);
+ Path targetCategoryBase = a2Base.resolve(category);
Files.createDirectories(targetCategoryBase);
Files.createDirectories(originBase);
}
protected Path processBundleJar(Path file, Path targetBase, Map<String, String> entries) throws IOException {
- NameVersion nameVersion;
+ DefaultNameVersion nameVersion;
Path targetBundleDir;
try (JarInputStream jarIn = new JarInputStream(Files.newInputStream(file), false)) {
Manifest manifest = new Manifest(jarIn.getManifest());
logger.log(Level.WARNING, "Original version is " + nameVersion.getVersion()
+ " while new version is " + versionFromEntries);
}
+ if (symbolicNameFromEntries != null) {
+ // we always force our symbolic name
+ nameVersion.setName(symbolicNameFromEntries);
+ }
}
targetBundleDir = targetBase.resolve(nameVersion.getName() + "." + nameVersion.getBranch());
String value = entries.get(key);
Object previousValue = manifest.getMainAttributes().putValue(key, value);
if (previousValue != null && !previousValue.equals(value)) {
- logger.log(Level.WARNING,
- file.getFileName() + ": " + key + " was " + previousValue + ", overridden with " + value);
+ if (ManifestConstants.IMPORT_PACKAGE.toString().equals(key)
+ || ManifestConstants.EXPORT_PACKAGE.toString().equals(key))
+ logger.log(Level.WARNING, file.getFileName() + ": " + key + " was modified");
+
+ else
+ logger.log(Level.WARNING, file.getFileName() + ": " + key + " was " + previousValue
+ + ", overridden with " + value);
}
}
try (OutputStream out = Files.newOutputStream(manifestPath)) {
});
}
- protected NameVersion nameVersionFromManifest(Manifest manifest) {
+ protected DefaultNameVersion nameVersionFromManifest(Manifest manifest) {
Attributes attrs = manifest.getMainAttributes();
// symbolic name
String symbolicName = attrs.getValue(ManifestConstants.BUNDLE_SYMBOLICNAME.toString());
}
public static void main(String[] args) {
- Path originBase = Paths.get("../output/origin").toAbsolutePath().normalize();
- Path factoryBase = Paths.get("../output/a2").toAbsolutePath().normalize();
- A2Factory factory = new A2Factory(originBase, factoryBase);
+ Path factoryBase = Paths.get("../../output/a2").toAbsolutePath().normalize();
+ A2Factory factory = new A2Factory(factoryBase);
Path descriptorsBase = Paths.get("../tp").toAbsolutePath().normalize();
// factory.processSingleM2ArtifactDistributionUnit(descriptorsBase.resolve("org.argeo.tp.apache").resolve("org.apache.xml.resolver.bnd"));
-// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp/slf4j"));
-// System.exit(0);
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.apache/apache-sshd"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.jetty/jetty"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.jetty/jetty-websocket"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp"));
+ System.exit(0);
// Eclipse
factory.processEclipseArchive(
factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rap").resolve("eclipse-rap"));
factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp").resolve("eclipse-rcp"));
+ System.exit(0);
+
// Maven
factory.processCategory(descriptorsBase.resolve("org.argeo.tp.sdk"));
factory.processCategory(descriptorsBase.resolve("org.argeo.tp"));