Skip to content

Commit dc8d4aa

Browse files
New major version to remove legacy features (#304)
* New major version * remove deprecations introduced in 2.0 * Update Jenkins baseline and BOM version in pom.xml
1 parent 779b62a commit dc8d4aa

34 files changed

Lines changed: 15 additions & 1966 deletions

README.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Since version 1.10 release notes are recorded in https://github.com/jenkinsci/ba
2424

2525
Changelogs for older releases can be found in the link:https://github.com/jenkinsci/badge-plugin/blob/fa18486e5f1f21f8f3eb7fe3a8e6088647e84ab3/CHANGELOG.adoc[archive].
2626

27+
=== Version 3.x
28+
29+
Version 3.0 removes legacy features introduced in <<Version 2.x>> and therefore breaks compatibility in case the legacy features where not migrated before upgrading the plugin. More details on this can be found in the https://github.com/jenkinsci/badge-plugin/releases/tag/badge-3.0[Release Notes for 3.0].
30+
2731
=== Version 2.x
2832

2933
Version 2.0 is a major rework of the original plugin and introduces lots of new features.

pom.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
<properties>
3535
<changelist>-SNAPSHOT</changelist>
3636
<gitHubRepo>jenkinsci/badge-plugin</gitHubRepo>
37-
<hpi.compatibleSinceVersion>2.0</hpi.compatibleSinceVersion>
37+
<hpi.compatibleSinceVersion>3.0</hpi.compatibleSinceVersion>
3838
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
39-
<jenkins.baseline>2.516</jenkins.baseline>
39+
<jenkins.baseline>2.541</jenkins.baseline>
4040
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
41-
<revision>2</revision>
41+
<revision>3</revision>
4242
<changelist>999999-SNAPSHOT</changelist>
4343
<spotless.check.skip>false</spotless.check.skip>
4444
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
@@ -50,18 +50,14 @@
5050
<dependency>
5151
<groupId>io.jenkins.tools.bom</groupId>
5252
<artifactId>bom-${jenkins.baseline}.x</artifactId>
53-
<version>6098.v29a_dff8a_0c19</version>
53+
<version>6146.vc53a_0edb_e986</version>
5454
<type>pom</type>
5555
<scope>import</scope>
5656
</dependency>
5757
</dependencies>
5858
</dependencyManagement>
5959

6060
<dependencies>
61-
<dependency>
62-
<groupId>io.jenkins.plugins</groupId>
63-
<artifactId>commons-text-api</artifactId>
64-
</dependency>
6561
<dependency>
6662
<groupId>io.jenkins.plugins</groupId>
6763
<artifactId>emoji-symbols-api</artifactId>

src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import java.util.logging.Logger;
3939
import jenkins.model.Jenkins;
4040
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
41-
import org.kohsuke.accmod.Restricted;
42-
import org.kohsuke.accmod.restrictions.NoExternalUse;
4341
import org.kohsuke.stapler.export.Exported;
4442
import org.kohsuke.stapler.export.ExportedBean;
4543

@@ -74,7 +72,7 @@ public abstract class AbstractBadgeAction implements Action, Serializable {
7472
*
7573
* @deprecated Use {@link AbstractBadgeAction#AbstractBadgeAction(String, String, String, String, String, String, String)} instead.
7674
*/
77-
@Deprecated(since = "2.8")
75+
@Deprecated(since = "2.8", forRemoval = true)
7876
protected AbstractBadgeAction(String id, String icon, String text, String cssClass, String style, String link) {
7977
this(id, icon, text, cssClass, style, link, null);
8078
}
@@ -123,7 +121,7 @@ public String getIcon() {
123121
return icon;
124122
}
125123

126-
// backwards compatible replacement for old GIFs
124+
// backwards compatible replacement for old GIFs - since 2.8
127125
return switch (icon) {
128126
case "completed.gif" -> "symbol-status-blue";
129127
case "db_in.gif" -> Ionicons.getIconClassName("cloud-upload-outline");
@@ -248,101 +246,4 @@ public String getIconFileName() {
248246
public String getUrlName() {
249247
return "";
250248
}
251-
252-
// LEGACY CODE
253-
@Deprecated(since = "2.0", forRemoval = true)
254-
private transient String iconPath;
255-
256-
@Deprecated(since = "2.0", forRemoval = true)
257-
private transient String color;
258-
259-
@Deprecated(since = "2.0", forRemoval = true)
260-
private transient String background;
261-
262-
@Deprecated(since = "2.0", forRemoval = true)
263-
private transient String border;
264-
265-
@Deprecated(since = "2.0", forRemoval = true)
266-
private transient String borderColor;
267-
268-
/**
269-
* @deprecated kept for backwards compatibility.
270-
* Translates pre 2.0 build.xml to latest format for backwards compatibility.
271-
* @return this instance
272-
*/
273-
@Serial
274-
@Deprecated(since = "2.0", forRemoval = true)
275-
protected Object readResolve() {
276-
// field renamed - see AbstractBadgeAction
277-
if (iconPath != null) {
278-
setIcon(iconPath);
279-
}
280-
281-
// field reworked - see AddShortTextStep
282-
String style = "";
283-
if (border != null) {
284-
style += "border: " + border + " solid " + (borderColor != null ? borderColor : "") + ";";
285-
}
286-
if (background != null) {
287-
style += "background: " + background + ";";
288-
}
289-
if (color != null) {
290-
if (color.startsWith("jenkins-!-color")) {
291-
style += "color: var(--" + color.replaceFirst("jenkins-!-color-", "") + ");";
292-
} else if (color.startsWith("jenkins-!-")) {
293-
style += "color: var(--" + color.replaceFirst("jenkins-!-", "") + ");";
294-
} else {
295-
style += "color: " + getJenkinsColorStyle(color) + ";";
296-
}
297-
}
298-
if (!style.isEmpty()) {
299-
setStyle(style);
300-
}
301-
302-
return this;
303-
}
304-
305-
/**
306-
* Get the Jenkins color style for the given color reference. Returns {@code color} if the color is not a
307-
* known Jenkins palette color or semantic color.
308-
* @param color color reference
309-
* @return jenkins color style variable
310-
*/
311-
@NonNull
312-
@Restricted(NoExternalUse.class)
313-
public static String getJenkinsColorStyle(@NonNull String color) {
314-
String primary = color;
315-
if (color.startsWith("light-") && color.length() > 6) {
316-
primary = color.substring(6);
317-
} else if (color.startsWith("dark-") && color.length() > 5) {
318-
primary = color.substring(5);
319-
}
320-
// spotless:off
321-
// https://github.com/jenkinsci/jenkins/blob/master/src/main/scss/abstracts/_theme.scss
322-
return switch (primary) {
323-
case "blue",
324-
"brown",
325-
"cyan",
326-
"green",
327-
"indigo",
328-
"orange",
329-
"pink",
330-
"purple",
331-
"red",
332-
"yellow",
333-
"white",
334-
"black" -> "var(--" + color + ")"; // palette
335-
case "accent",
336-
"text",
337-
"error",
338-
"warning",
339-
"success",
340-
"destructive",
341-
"build",
342-
"danger",
343-
"info" -> "var(--" + color + "-color)"; // semantics
344-
default -> color;
345-
};
346-
// spotless:on
347-
}
348249
}

src/main/java/com/jenkinsci/plugins/badge/action/BadgeAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BadgeAction extends AbstractBadgeAction implements BuildBadgeAction
3737
/**
3838
* @deprecated Use {@link BadgeAction#BadgeAction(String, String, String, String, String, String, String)} instead.
3939
*/
40-
@Deprecated(since = "2.8")
40+
@Deprecated(since = "2.8", forRemoval = true)
4141
public BadgeAction(String id, String icon, String text, String cssClass, String style, String link) {
4242
super(id, icon, text, cssClass, style, link);
4343
}

src/main/java/com/jenkinsci/plugins/badge/action/BadgeSummaryAction.java

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
package com.jenkinsci.plugins.badge.action;
2525

2626
import java.io.Serial;
27-
import java.util.Objects;
28-
import org.apache.commons.text.StringEscapeUtils;
29-
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
3027

3128
/**
3229
* Common action for build summaries.
@@ -39,7 +36,7 @@ public class BadgeSummaryAction extends AbstractBadgeAction {
3936
/**
4037
* @deprecated Use {@link BadgeSummaryAction#BadgeSummaryAction(String, String, String, String, String, String, String)} instead.
4138
*/
42-
@Deprecated(since = "2.8")
39+
@Deprecated(since = "2.8", forRemoval = true)
4340
public BadgeSummaryAction(String id, String icon, String text, String cssClass, String style, String link) {
4441
super(id, icon, text, cssClass, style, link);
4542
}
@@ -53,65 +50,4 @@ public BadgeSummaryAction(
5350
public String getDisplayName() {
5451
return "Badge Summary Action";
5552
}
56-
57-
@Whitelisted
58-
@Deprecated(since = "2.0", forRemoval = true)
59-
public void appendText(String text) {
60-
appendText(text, false);
61-
}
62-
63-
@Whitelisted
64-
@Deprecated(since = "2.0", forRemoval = true)
65-
public void appendText(String text, boolean escapeHtml) {
66-
if (escapeHtml) {
67-
text = StringEscapeUtils.escapeHtml4(text);
68-
}
69-
setText(Objects.requireNonNullElse(getText(), "") + text);
70-
}
71-
72-
@Whitelisted
73-
@Deprecated(since = "2.0", forRemoval = true)
74-
public void appendText(String text, boolean escapeHtml, boolean bold, boolean italic, String color) {
75-
String startTags = "";
76-
String closeTags = "";
77-
if (bold) {
78-
startTags += "<b>";
79-
closeTags += "</b>";
80-
}
81-
if (italic) {
82-
startTags += "<i>";
83-
closeTags += "</i>";
84-
}
85-
if (color != null) {
86-
startTags += "<font color=\"" + StringEscapeUtils.escapeHtml4(color) + "\">";
87-
closeTags += "</font>";
88-
}
89-
if (escapeHtml) {
90-
text = StringEscapeUtils.escapeHtml4(text);
91-
}
92-
setText(Objects.requireNonNullElse(getText(), "") + startTags + text + closeTags);
93-
}
94-
95-
// LEGACY CODE
96-
@Deprecated(since = "2.0", forRemoval = true)
97-
private transient String summaryText;
98-
99-
/**
100-
* @deprecated kept for backwards compatibility.
101-
* Translates pre 2.0 build.xml to latest format for backwards compatibility.
102-
* @return this instance
103-
*/
104-
@Serial
105-
@Override
106-
@Deprecated(since = "2.0", forRemoval = true)
107-
protected Object readResolve() {
108-
super.readResolve();
109-
110-
// field renamed
111-
if (summaryText != null) {
112-
setText(summaryText);
113-
}
114-
115-
return this;
116-
}
11753
}

src/main/java/com/jenkinsci/plugins/badge/action/HtmlBadgeAction.java

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

0 commit comments

Comments
 (0)