Skip to content

Commit 5e29133

Browse files
New major version
* remove deprecations introduced in 2.0
1 parent b6a6145 commit 5e29133

34 files changed

+16
-1972
lines changed

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: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: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@
5454
<properties>
5555
<changelist>-SNAPSHOT</changelist>
5656
<gitHubRepo>jenkinsci/badge-plugin</gitHubRepo>
57-
<hpi.compatibleSinceVersion>2.0</hpi.compatibleSinceVersion>
57+
<hpi.compatibleSinceVersion>3.0</hpi.compatibleSinceVersion>
5858
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
59-
<jenkins.baseline>2.492</jenkins.baseline>
60-
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
61-
<revision>2.11</revision>
59+
<jenkins.baseline>2.516</jenkins.baseline>
60+
<jenkins.version>${jenkins.baseline}.2</jenkins.version>
61+
<revision>3.0</revision>
6262
<spotbugs.effort>Max</spotbugs.effort>
6363
<spotbugs.threshold>Low</spotbugs.threshold>
6464
<spotless.check.skip>false</spotless.check.skip>
6565
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
66+
<hpi.strictBundledArtifacts>true</hpi.strictBundledArtifacts>
6667
</properties>
6768

6869
<dependencyManagement>
@@ -78,10 +79,6 @@
7879
</dependencyManagement>
7980

8081
<dependencies>
81-
<dependency>
82-
<groupId>io.jenkins.plugins</groupId>
83-
<artifactId>commons-text-api</artifactId>
84-
</dependency>
8582
<dependency>
8683
<groupId>io.jenkins.plugins</groupId>
8784
<artifactId>emoji-symbols-api</artifactId>
@@ -94,10 +91,6 @@
9491
<groupId>org.jenkins-ci.plugins</groupId>
9592
<artifactId>script-security</artifactId>
9693
</dependency>
97-
<dependency>
98-
<groupId>org.jenkins-ci.plugins</groupId>
99-
<artifactId>structs</artifactId>
100-
</dependency>
10194
<dependency>
10295
<groupId>org.jenkins-ci.plugins.workflow</groupId>
10396
<artifactId>workflow-step-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
@@ -35,8 +35,6 @@
3535
import java.util.logging.Logger;
3636
import jenkins.model.Jenkins;
3737
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
38-
import org.kohsuke.accmod.Restricted;
39-
import org.kohsuke.accmod.restrictions.NoExternalUse;
4038
import org.kohsuke.stapler.export.Exported;
4139
import org.kohsuke.stapler.export.ExportedBean;
4240

@@ -71,7 +69,7 @@ public abstract class AbstractBadgeAction implements Action, Serializable {
7169
*
7270
* @deprecated Use {@link AbstractBadgeAction#AbstractBadgeAction(String, String, String, String, String, String, String)} instead.
7371
*/
74-
@Deprecated(since = "2.8")
72+
@Deprecated(since = "2.8", forRemoval = true)
7573
protected AbstractBadgeAction(String id, String icon, String text, String cssClass, String style, String link) {
7674
this(id, icon, text, cssClass, style, link, null);
7775
}
@@ -120,7 +118,7 @@ public String getIcon() {
120118
return icon;
121119
}
122120

123-
// backwards compatible replacement for old GIFs
121+
// backwards compatible replacement for old GIFs - since 2.8
124122
return switch (icon) {
125123
case "completed.gif" -> "symbol-status-blue";
126124
case "db_in.gif" -> Ionicons.getIconClassName("cloud-upload-outline");
@@ -222,101 +220,4 @@ public String getIconFileName() {
222220
public String getUrlName() {
223221
return "";
224222
}
225-
226-
// LEGACY CODE
227-
@Deprecated(since = "2.0", forRemoval = true)
228-
private transient String iconPath;
229-
230-
@Deprecated(since = "2.0", forRemoval = true)
231-
private transient String color;
232-
233-
@Deprecated(since = "2.0", forRemoval = true)
234-
private transient String background;
235-
236-
@Deprecated(since = "2.0", forRemoval = true)
237-
private transient String border;
238-
239-
@Deprecated(since = "2.0", forRemoval = true)
240-
private transient String borderColor;
241-
242-
/**
243-
* @deprecated kept for backwards compatibility.
244-
* Translates pre 2.0 build.xml to latest format for backwards compatibility.
245-
* @return this instance
246-
*/
247-
@Serial
248-
@Deprecated(since = "2.0", forRemoval = true)
249-
protected Object readResolve() {
250-
// field renamed - see AbstractBadgeAction
251-
if (iconPath != null) {
252-
setIcon(iconPath);
253-
}
254-
255-
// field reworked - see AddShortTextStep
256-
String style = "";
257-
if (border != null) {
258-
style += "border: " + border + " solid " + (borderColor != null ? borderColor : "") + ";";
259-
}
260-
if (background != null) {
261-
style += "background: " + background + ";";
262-
}
263-
if (color != null) {
264-
if (color.startsWith("jenkins-!-color")) {
265-
style += "color: var(--" + color.replaceFirst("jenkins-!-color-", "") + ");";
266-
} else if (color.startsWith("jenkins-!-")) {
267-
style += "color: var(--" + color.replaceFirst("jenkins-!-", "") + ");";
268-
} else {
269-
style += "color: " + getJenkinsColorStyle(color) + ";";
270-
}
271-
}
272-
if (!style.isEmpty()) {
273-
setStyle(style);
274-
}
275-
276-
return this;
277-
}
278-
279-
/**
280-
* Get the Jenkins color style for the given color reference. Returns {@code color} if the color is not a
281-
* known Jenkins palette color or semantic color.
282-
* @param color color reference
283-
* @return jenkins color style variable
284-
*/
285-
@NonNull
286-
@Restricted(NoExternalUse.class)
287-
public static String getJenkinsColorStyle(@NonNull String color) {
288-
String primary = color;
289-
if (color.startsWith("light-") && color.length() > 6) {
290-
primary = color.substring(6);
291-
} else if (color.startsWith("dark-") && color.length() > 5) {
292-
primary = color.substring(5);
293-
}
294-
// spotless:off
295-
// https://github.com/jenkinsci/jenkins/blob/master/src/main/scss/abstracts/_theme.scss
296-
return switch (primary) {
297-
case "blue",
298-
"brown",
299-
"cyan",
300-
"green",
301-
"indigo",
302-
"orange",
303-
"pink",
304-
"purple",
305-
"red",
306-
"yellow",
307-
"white",
308-
"black" -> "var(--" + color + ")"; // palette
309-
case "accent",
310-
"text",
311-
"error",
312-
"warning",
313-
"success",
314-
"destructive",
315-
"build",
316-
"danger",
317-
"info" -> "var(--" + color + "-color)"; // semantics
318-
default -> color;
319-
};
320-
// spotless:on
321-
}
322223
}

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)