Skip to content

Commit 293dc41

Browse files
committed
[Build|RelEng] Clean-up and fix EnrichPom java code and fix warning
- Move publish-to-maven project from Java-11 to 21 as the Maven-publication process already requires Java-21 - Remove fix of scmConnection value as it's not necessary anymore (ECJ metadata are fine out of the box) and it removes (accidentally) the scm-tag information - Remove now obsolete SCM-mapping - Throw exceptions on missing information instead of using default and be strict - Add print-out about basic statics, i.e. the number of enhanced POM files - Remove unused enrichPoms.jardesc
1 parent 88d9506 commit 293dc41

File tree

8 files changed

+117
-253
lines changed

8 files changed

+117
-253
lines changed

JenkinsJobs/Releng/publishToMaven.jenkinsfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pipeline {
7474
ENRICH_POMS_JAR=${WORKSPACE}/work/EnrichPoms.jar
7575
ENRICH_POMS_PACKAGE=org.eclipse.platform.releng.maven.pom
7676

77+
#TODO: Just launch as multi-file source-code program as soon as Java-22 or later is used: https://openjdk.org/jeps/458
7778
# build the jar:
7879
mkdir -p ${WORKSPACE}/work/bin
7980
javac -d "${WORKSPACE}/work/bin" $(find "${MAVEN_PUBLISH_BASE}/src" -name \\*.java)
@@ -82,10 +83,9 @@ pipeline {
8283
popd
8384
ls -l ${ENRICH_POMS_JAR}
8485

85-
for project in {platform,jdt,pde}; do
86-
echo "${project}"
87-
java -jar ${ENRICH_POMS_JAR} "${REPO}/org/eclipse/${project}"
88-
done
86+
set -x
87+
java -jar ${ENRICH_POMS_JAR} ${REPO}/org/eclipse/{platform,jdt,pde}
88+
set +x
8989

9090
echo "==== Add Javadoc stubs ===="
9191

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
34
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
55
<classpathentry kind="output" path="bin"/>
66
</classpath>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
44
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5-
org.eclipse.jdt.core.compiler.compliance=11
5+
org.eclipse.jdt.core.compiler.compliance=21
66
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
77
org.eclipse.jdt.core.compiler.debug.localVariable=generate
88
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -11,4 +11,4 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
1111
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
1212
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
1313
org.eclipse.jdt.core.compiler.release=enabled
14-
org.eclipse.jdt.core.compiler.source=11
14+
org.eclipse.jdt.core.compiler.source=21

eclipse.platform.releng/publish-to-maven-central/enrichPoms.jardesc

Lines changed: 0 additions & 16 deletions
This file was deleted.

eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/ArtifactInfo.java

Lines changed: 67 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/********************************************************************************
2-
* Copyright (c) 2016, 2018 GK Software SE and others.
3-
*
2+
* Copyright (c) 2016, 2025 GK Software SE and others.
3+
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
@@ -10,204 +10,129 @@
1010
*
1111
* Contributors:
1212
* Stephan Herrmann - initial implementation
13+
* Hannes Wellmann - Simplify and remove now unncessary elements
1314
********************************************************************************/
1415
package org.eclipse.platform.releng.maven.pom;
1516

1617
import java.io.InputStream;
17-
import java.net.URL;
18-
import java.util.HashMap;
18+
import java.net.URI;
1919
import java.util.HashSet;
20-
import java.util.Map;
20+
import java.util.Objects;
2121
import java.util.Set;
2222
import java.util.regex.Matcher;
2323
import java.util.regex.Pattern;
2424

25-
public class ArtifactInfo {
25+
public record ArtifactInfo(String bsn, String scmConnection) {
2626

2727
private static final String SCM_TAG_START = ";tag=\""; // git tag inside Eclipse-SourceReference
28-
2928
private static final String INDENT = " ";
30-
31-
private static final Map<String, String> MOVED_SCMS = new HashMap<>();
32-
3329
private static final Pattern GITHUB_PATTERN = Pattern.compile("https://github.com/([^/]+)/.*");
3430

35-
static {
36-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.releng",
37-
"https://github.com/eclipse-platform/eclipse.platform.releng");
38-
MOVED_SCMS.put("https://git.eclipse.org/r/platform/eclipse.platform.releng",
39-
"https://github.com/eclipse-platform/eclipse.platform.releng");
40-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.ui",
41-
"https://github.com/eclipse-platform/eclipse.platform.ui");
42-
MOVED_SCMS.put("https://git.eclipse.org/r/platform/eclipse.platform.ui",
43-
"https://github.com/eclipse-platform/eclipse.platform.ui");
44-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.text",
45-
"https://github.com/eclipse-platform/eclipse.platform.text");
46-
MOVED_SCMS.put("https://git.eclipse.org/r/platform/eclipse.platform.text",
47-
"https://github.com/eclipse-platform/eclipse.platform.text");
48-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.debug",
49-
"https://github.com/eclipse-platform/eclipse.platform.debug");
50-
MOVED_SCMS.put("http://git.eclipse.org/gitroot/e4/org.eclipse.e4.tools",
51-
"https://github.com/eclipse-platform/eclipse.platform.ui.tools");
52-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.ua",
53-
"https://github.com/eclipse-platform/eclipse.platform.ua");
54-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/platform/eclipse.platform.swt",
55-
"https://github.com/eclipse-platform/eclipse.platform.swt");
56-
57-
MOVED_SCMS.put("https://gihub.com/eclipse-platform/eclipse.platform.ua",
58-
"https://github.com/eclipse-platform/eclipse.platform.ua");
59-
MOVED_SCMS.put("https://github.com/eclipse-platform/org.eclipse.ui.tools",
60-
"https://github.com/eclipse-platform/eclipse.platform.ui.tools");
61-
62-
MOVED_SCMS.put("https://git.eclipse.org/r/equinox/rt.equinox.bundles", "https://github.com/eclipse-equinox/p2");
63-
MOVED_SCMS.put("https://git.eclipse.org/r/equinox/rt.equinox.p2", "https://github.com/eclipse-equinox/p2");
64-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/equinox/rt.equinox.p2", "https://github.com/eclipse-equinox/p2");
65-
MOVED_SCMS.put("https://git.eclipse.org/r/equinox/rt.equinox.framework",
66-
"https://github.com/eclipse-equinox/equinox");
67-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/equinox/rt.equinox.bundles",
68-
"https://github.com/eclipse-equinox/equinox");
69-
70-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.binaries",
71-
"https://github.com/eclipse-jdt/eclipse.jdt.core.binaries");
72-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui",
73-
"https://github.com/eclipse-jdt/eclipse.jdt.ui");
74-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core",
75-
"https://github.com/eclipse-jdt/eclipse.jdt.core");
76-
MOVED_SCMS.put("https://git.eclipse.org/r/jdt/eclipse.jdt.core",
77-
"https://github.com/eclipse-jdt/eclipse.jdt.core");
78-
79-
MOVED_SCMS.put("git://git.eclipse.org/gitroot/pde/eclipse.pde.ui",
80-
"https://github.com/eclipse-pde/eclipse.pde");
81-
MOVED_SCMS.put("https://git.eclipse.org/r/pde/eclipse.pde.ui", "https://github.com/eclipse-pde/eclipse.pde");
82-
}
83-
84-
public String bsn;
85-
public String scmConnection;
86-
87-
@Override
88-
public String toString() {
89-
return "ArtifactInfo [bsn=" + bsn + ", scmConnection=" + scmConnection + "]";
31+
public ArtifactInfo {
32+
Objects.requireNonNull(bsn);
33+
Objects.requireNonNull(scmConnection);
9034
}
9135

92-
public String toPomFragment() {
36+
String toPomFragment() {
9337
try {
94-
fixData();
9538
StringBuilder buf = new StringBuilder();
96-
String indent = INDENT;
97-
element("url", indent, buf, getProjectURL());
98-
if (this.scmConnection == null) {
99-
System.err.println("No scm info for " + this.bsn);
100-
} else {
101-
String connectionUrl = extractScmConnection();
102-
String url = extractScmUrl(connectionUrl);
103-
buf.append(getFrontMatter(url));
104-
element("scm", indent, buf, subElement("connection", connectionUrl), subElement("tag", extractScmTag()),
105-
subElement("url", url));
106-
Developer.addUrlDevelopers(getProjectURL(), indent, buf);
107-
}
39+
String projectURL = getProjectURL();
40+
element("url", INDENT, buf, projectURL);
41+
String url = extractScmUrl();
42+
buf.append(getFrontMatter(url));
43+
element("scm", INDENT, buf, subElement("connection", extractScmConnection()),
44+
subElement("tag", extractScmTag()), subElement("url", url));
45+
addUrlDevelopers(projectURL, INDENT, buf);
10846
return buf.toString();
10947
} catch (RuntimeException e) {
110-
System.err.println("Failed for " + this);
111-
throw e;
48+
throw new IllegalStateException("Failed for " + this, e);
11249
}
11350
}
11451

11552
private static String getFrontMatter(String scmURL) {
116-
String FRONT_MATTER = "" + //
117-
" <licenses>\n" + //
118-
" <license>\n" + //
119-
" <name>Eclipse Public License - v 2.0</name>\n" + //
120-
" <url>https://www.eclipse.org/legal/epl-2.0/</url>\n" + //
121-
" <distribution>repo</distribution>\n" + //
122-
" </license>\n" + //
123-
" </licenses>\n" + //
124-
" <organization>\n" + //
125-
" <name>Eclipse Foundation</name>\n" + //
126-
" <url>https://www.eclipse.org/</url>\n" + //
127-
" </organization>\n" + //
128-
" <issueManagement>\n" + //
129-
" <system>Github</system>\n" + //
130-
" <url>" + scmURL + "/issues</url>\n" + //
131-
" </issueManagement>\n"; //
132-
return FRONT_MATTER;
53+
return String.format("""
54+
<licenses>
55+
<license>
56+
<name>Eclipse Public License - v 2.0</name>
57+
<url>https://www.eclipse.org/legal/epl-2.0/</url>
58+
<distribution>repo</distribution>
59+
</license>
60+
</licenses>
61+
<organization>
62+
<name>Eclipse Foundation</name>
63+
<url>https://www.eclipse.org/</url>
64+
</organization>
65+
<issueManagement>
66+
<system>Github</system>
67+
<url>%s/issues</url>
68+
</issueManagement>
69+
""", scmURL);
13370
}
13471

135-
private void fixData() {
136-
if (this.scmConnection == null) {
137-
if (this.bsn.equals("org.eclipse.jdt.core.compiler.batch")) {
138-
// not a regular OSGi bundle, scm info missing:
139-
this.scmConnection = "scm:git:https://github.com/eclipse-jdt/eclipse.jdt.core.git;path=\"org.eclipse.jdt.core\"";
140-
System.out.println("Fixed scmUrl for " + this.bsn);
141-
}
142-
} else {
143-
this.scmConnection = "scm:git:" + extractScmUrl(extractScmConnection()) + ".git";
144-
}
145-
}
146-
147-
String getProjectURL() {
148-
String scmURL = extractScmUrl(extractScmConnection());
72+
private String getProjectURL() {
73+
String scmURL = extractScmUrl();
14974
Matcher matcher = GITHUB_PATTERN.matcher(scmURL);
15075
if (matcher.matches()) {
15176
String organization = matcher.group(1);
15277
return "https://projects.eclipse.org/projects/" + organization.replace('-', '.');
15378
}
154-
155-
return "https://projects.eclipse.org/projects/";
79+
throw new IllegalArgumentException("Unexpected scm-URL: " + scmURL);
15680
}
15781

158-
String extractScmConnection() {
159-
int semi = this.scmConnection.indexOf(';');
160-
if (semi == -1)
161-
return this.scmConnection;
162-
return this.scmConnection.substring(0, semi);
82+
private String extractScmConnection() {
83+
return substringTo(this.scmConnection, 0, ';');
16384
}
16485

165-
String extractScmTag() {
86+
private String extractScmTag() {
16687
int tagStart = this.scmConnection.indexOf(SCM_TAG_START);
167-
if (tagStart == -1)
168-
return null;
169-
int next = this.scmConnection.indexOf("\"", tagStart + SCM_TAG_START.length());
170-
if (next == -1)
171-
next = this.scmConnection.length();
172-
return this.scmConnection.substring(tagStart + SCM_TAG_START.length(), next);
88+
if (tagStart == -1) {
89+
throw new IllegalArgumentException("scm-tag not found in " + this.scmConnection);
90+
}
91+
return substringTo(this.scmConnection, tagStart + SCM_TAG_START.length(), '"');
92+
}
93+
94+
private static void addUrlDevelopers(String projectURL, String indent, StringBuilder buf) {
95+
StringBuilder subElements = new StringBuilder();
96+
element("developer", "", subElements, subElement("url", projectURL + "/who"));
97+
element("developers", indent, buf, subElements.toString());
17398
}
17499

175100
private static final Set<String> visitedSCMs = new HashSet<>();
176101

177-
String extractScmUrl(String connection) {
178-
String scmURL = connection.replaceAll("^scm:git:", "").replaceAll("^scm:githttps:", "https:")
179-
.replaceAll("\\.git$", "");
180-
String movedSCMURL = MOVED_SCMS.get(scmURL);
181-
if (movedSCMURL != null) {
182-
scmURL = movedSCMURL;
183-
}
102+
private String extractScmUrl() {
103+
String connection = extractScmConnection();
104+
String scmURL = connection.replaceFirst("^scm:git:", "").replaceFirst("^scm:githttps:", "https:")
105+
.replaceFirst("\\.git$", "");
184106
if (EnrichPoms.test && visitedSCMs.add(scmURL)) {
185-
try (InputStream in = new URL(scmURL).openStream()) {
107+
try (InputStream in = new URI(scmURL).toURL().openStream()) {
186108
} catch (Exception ex) {
187109
ex.printStackTrace();
188110
}
189111
}
190112
return scmURL;
191113
}
192114

193-
public static void element(String tag, String indent, StringBuilder buf, String... contents) {
115+
private static String substringTo(String string, int beginIndex, char endChar) {
116+
int endIndex = string.indexOf(endChar, beginIndex);
117+
return endIndex == -1 ? string.substring(beginIndex) : string.substring(beginIndex, endIndex);
118+
}
119+
120+
private static void element(String tag, String indent, StringBuilder buf, String... contents) {
194121
buf.append(indent).append('<').append(tag).append('>');
195122
if (contents.length == 1 && !contents[0].contains("\n")) {
196123
buf.append(contents[0]);
197124
} else {
198125
buf.append("\n");
199-
for (String content : contents)
200-
if (content != null)
201-
for (String line : content.split("\\n"))
202-
buf.append(indent).append(INDENT).append(line).append('\n');
126+
for (String content : contents) {
127+
content.lines().forEach(line -> buf.append(indent).append(INDENT).append(line).append('\n'));
128+
}
203129
buf.append(indent);
204130
}
205131
buf.append("</").append(tag).append(">\n");
206132
}
207133

208-
public static String subElement(String tag, String content) {
209-
if (content == null)
210-
return null;
134+
private static String subElement(String tag, String content) {
135+
Objects.requireNonNull(content);
211136
StringBuilder buf = new StringBuilder();
212137
element(tag, "", buf, content);
213138
return buf.toString();

eclipse.platform.releng/publish-to-maven-central/src/org/eclipse/platform/releng/maven/pom/Developer.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)