Hack to work around Bug 510996: Bogus dependency on aarch64 and arm
fragments
diff --git a/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/EnrichPoms.java b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/EnrichPoms.java
index fe83293..3667667 100644
--- a/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/EnrichPoms.java
+++ b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/EnrichPoms.java
@@ -15,12 +15,27 @@
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.List;
public class EnrichPoms {
private static final String DOT_POM = ".pom";
private static final String DOT_JAR = ".jar";
private static final String BAK_SUFFIX = "-bak";
+
+ private static final String SWT_ID = "org.eclipse.swt";
+ private static final String[] LINES_SWT_TO_SKIP = {
+ "<dependency>",
+ "<groupId>org.eclipse.platform</groupId>",
+ "<artifactId>org.eclipse.swt.gtk.linux.aarch64</artifactId>",
+ "<version>[3.105.3,3.105.3]</version>",
+ "</dependency>",
+ "<dependency>",
+ "<groupId>org.eclipse.platform</groupId>",
+ "<artifactId>org.eclipse.swt.gtk.linux.arm</artifactId>",
+ "<version>[3.105.3,3.105.3]</version>",
+ "</dependency>"
+ };
public static void main(String[] args) throws IOException {
@@ -57,11 +72,17 @@
}
Path jarPath = getCorrespondingJarPath(pomPath);
ArtifactInfo info = ManifestReader.read(jarPath);
+ boolean isSWT = SWT_ID.equals(info.bsn);
Path newPom = Files.createTempFile(pomPath.getParent(), "", DOT_POM);
try (OutputStreamWriter out = new OutputStreamWriter(Files.newOutputStream(newPom))) {
boolean copyrightInserted = false;
boolean detailsInserted = false;
- for (String line : Files.readAllLines(pomPath)) {
+ List<String> allLines = Files.readAllLines(pomPath);
+ for (int i = 0; i < allLines.size(); i++) {
+ if (isSWT && matches(LINES_SWT_TO_SKIP, allLines, i)) {
+ i += LINES_SWT_TO_SKIP.length;
+ }
+ String line = allLines.get(i);
out.write(line);
out.append('\n');
if (!copyrightInserted) {
@@ -85,4 +106,15 @@
System.err.println("Failed to rewrite pom "+pomPath+": "+e.getClass()+": "+e.getMessage());
}
}
+
+ /** Hack to work around https://bugs.eclipse.org/510996 */
+ private static boolean matches(String[] linesToSkip, List<String> allLines, int idx) {
+ if (idx+linesToSkip.length >= allLines.size())
+ return false;
+ for (int i = 0; i < linesToSkip.length; i++) {
+ if (!allLines.get(idx+i).trim().equals(linesToSkip[i]))
+ return false;
+ }
+ return true;
+ }
}