visitedSCMs = new HashSet<>();
-
- private String extractScmUrl() {
- String connection = extractScmConnection();
- String scmURL = connection.replaceFirst("^scm:git:", "").replaceFirst("^scm:githttps:", "https:")
- .replaceFirst("\\.git$", "");
- if (EnrichPoms.test && visitedSCMs.add(scmURL)) {
- try (InputStream in = new URI(scmURL).toURL().openStream()) {
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return scmURL;
- }
-
- private static String substringTo(String string, int beginIndex, char endChar) {
- int endIndex = string.indexOf(endChar, beginIndex);
- return endIndex == -1 ? string.substring(beginIndex) : string.substring(beginIndex, endIndex);
- }
-
- private static void element(String tag, String indent, StringBuilder buf, String... contents) {
- buf.append(indent).append('<').append(tag).append('>');
- if (contents.length == 1 && !contents[0].contains("\n")) {
- buf.append(contents[0]);
- } else {
- buf.append("\n");
- for (String content : contents) {
- content.lines().forEach(line -> buf.append(indent).append(INDENT).append(line).append('\n'));
- }
- buf.append(indent);
- }
- buf.append("").append(tag).append(">\n");
- }
-
- private static String subElement(String tag, String content) {
- Objects.requireNonNull(content);
- StringBuilder buf = new StringBuilder();
- element(tag, "", buf, content);
- return buf.toString();
- }
-}
diff --git a/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/EnrichPoms.java b/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/EnrichPoms.java
deleted file mode 100644
index 550783585e1..00000000000
--- a/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/EnrichPoms.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2016, 2025 GK Software SE and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Stephan Herrmann - initial implementation
- ********************************************************************************/
-package org.eclipse.platform.releng.maven.pom;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.stream.Stream;
-
-/**
- * To test locally, the /publish-to-maven-central/SDK4Mvn.aggr must be used to
- * produce the Mavenized p2 repository. To do that, you need to install the "CBI
- * Aggregator Editor" from https://download.eclipse.org/cbi/updates/p2-aggregator/tools/nightly/latest.
- * Then you can open the SDK4Mvn.aggr in the Aggregator Editor and invoke
- * Build Aggregation from the context menu. That generates results in
- * ${user.home}/build. Only the contents of following three folders are
- * actually published to Maven (perhaps equinox in the future), so you can run
- * main for just those folders:
- *
- *
- * ~/build/final/org/eclipse/pde
- * ~/build/final/org/eclipse/jdt
- * ~/build/final/org/eclipse/platform
- * -test
- * -verbose
- *
- *
- * The -test will test that the SCM URL actually exists. The
- * -verbose will print the contents to each enriched pom to
- * System.out.
- */
-public class EnrichPoms {
-
- private static final String DOT_POM = ".pom";
- private static final String DOT_JAR = ".jar";
- private static final String BAK_SUFFIX = "-bak";
-
- static boolean test;
-
- static boolean verbose;
-
- public static void main(String[] args) throws IOException {
- Set paths = new LinkedHashSet<>();
- for (String arg : args) {
- if ("-test".equals(arg)) {
- test = true;
- } else if ("-verbose".equals(arg)) {
- verbose = true;
- } else {
- Path path = FileSystems.getDefault().getPath(arg);
- if (!Files.exists(path) || !Files.isDirectory(path)) {
- throw new IllegalArgumentException(path.toString() + " is not a directory");
- }
- paths.add(path);
- }
- }
-
- if (paths.isEmpty()) {
- throw new IllegalArgumentException("No directories specified");
- }
-
- for (Path path : paths) {
- try (Stream files = Files.walk(path)) {
- int enrichedCount = files.filter(EnrichPoms::isArtifact).mapToInt(EnrichPoms::enrich).sum();
- System.out.println("Enriched " + enrichedCount + " POM files under " + path);
- }
- }
- }
-
- private static boolean isArtifact(Path path) {
- if (!path.getFileName().toString().endsWith(DOT_POM) || Files.isDirectory(path)) {
- return false;
- }
- Path jarPath = getCorrespondingJarPath(path);
- return Files.exists(jarPath);
- }
-
- private static Path getCorrespondingJarPath(Path pomPath) {
- String fileName = pomPath.getFileName().toString();
- String jarName = fileName.substring(0, fileName.length() - DOT_POM.length()) + DOT_JAR;
- return pomPath.resolveSibling(jarName);
- }
-
- public static int enrich(Path pomPath) {
- try {
- Path jarPath = getCorrespondingJarPath(pomPath);
- ArtifactInfo info = ManifestReader.read(jarPath);
- if (info == null) {
- // Don't process features because they aren't published.
- return 0;
- }
-
- Path backPath = pomPath.resolveSibling(pomPath.getFileName().toString() + BAK_SUFFIX);
- Path newPom = Files.createTempFile(pomPath.getParent(), "", DOT_POM);
- try (Stream lines = Files.lines(Files.exists(backPath) ? backPath : pomPath);
- Writer out = Files.newBufferedWriter(newPom);) {
- boolean detailsInserted = false;
- for (String line : (Iterable) lines::iterator) {
- out.append(line).append('\n');
- if (!detailsInserted && line.contains("")) {
- out.append(info.toPomFragment());
- detailsInserted = true;
- }
- }
- }
- if (verbose) {
- String pomText = Files.readString(newPom);
- System.out.println(pomText);
- }
- if (!Files.exists(backPath)) {
- Files.move(pomPath, backPath);
- }
- Files.move(newPom, pomPath, StandardCopyOption.REPLACE_EXISTING);
- return 1;
- } catch (IOException e) {
- throw new IllegalStateException("Failed to rewrite pom " + pomPath, e);
- }
- }
-}
diff --git a/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/ManifestReader.java b/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/ManifestReader.java
deleted file mode 100644
index 7a6b89b57ee..00000000000
--- a/eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/ManifestReader.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2016, 2025 GK Software SE and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Stephan Herrmann - initial implementation
- ********************************************************************************/
-package org.eclipse.platform.releng.maven.pom;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Map.Entry;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-public class ManifestReader {
-
- private static final String FEATURE_XML = "feature.xml";
- private static final String MANIFEST_MF = "META-INF/MANIFEST.MF";
- // Eclipse headers in MANIFEST.MF:
- private static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName";
- private static final String ECLIPSE_SOURCE_REFERENCES = "Eclipse-SourceReferences";
-
- public static ArtifactInfo read(Path path) throws FileNotFoundException, IOException {
- try (ZipFile zip = new ZipFile(path.toFile())) {
- ZipEntry featureEntry = zip.getEntry(FEATURE_XML);
- if (featureEntry != null) {
- return null;
- }
-
- ZipEntry entry = zip.getEntry(MANIFEST_MF);
- Manifest mf = new Manifest(zip.getInputStream(entry));
- Attributes mainAttributes = mf.getMainAttributes();
- // printAllMainAttributes(mainAttributes);
-
- String bsn = getSymbolicName(mainAttributes);
- String scmConnection = mainAttributes.getValue(ECLIPSE_SOURCE_REFERENCES);
- return new ArtifactInfo(bsn, scmConnection);
- }
- }
-
- private static String getSymbolicName(Attributes mainAttributes) {
- String bsn = mainAttributes.getValue(BUNDLE_SYMBOLIC_NAME);
- int semi = bsn.indexOf(';');
- if (semi != -1) {
- return bsn.substring(0, semi); // cut off ;singleton etc...
- }
- return bsn;
- }
-
- // debugging
- static void printAllMainAttributes(Attributes mainAttributes) {
- for (Entry