Skip to content

Commit 51ff97a

Browse files
Require Jenkins 2.479.1 and Jakarta EE 9
1 parent ab31631 commit 51ff97a

File tree

75 files changed

+2202
-2130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2202
-2130
lines changed

Jenkinsfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
buildPlugin(jdkVersions: [11])
1+
/*
2+
See the documentation for more options:
3+
https://github.com/jenkins-infra/pipeline-library/
4+
*/
5+
buildPlugin(
6+
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
7+
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
8+
configurations: [
9+
[platform: 'linux', jdk: 21],
10+
[platform: 'windows', jdk: 17],
11+
])

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trigger:
2121
steps:
2222
- task: JavaToolInstaller@0
2323
inputs:
24-
versionSpec: '11'
24+
versionSpec: '17'
2525
jdkArchitectureOption: 'x64'
2626
jdkSourceOption: 'PreInstalled'
2727

@@ -34,4 +34,4 @@ steps:
3434
codeCoverageToolOption: 'JaCoCo'
3535
goals: 'verify'
3636
displayName: 'Build $(imageName)'
37-
37+

pom.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.75</version>
7+
<version>5.7</version>
88
<relativePath />
99
</parent>
1010

@@ -56,16 +56,16 @@
5656
<changelist>999999-SNAPSHOT</changelist>
5757
<gitHubRepo>jenkinsci/matlab-plugin</gitHubRepo>
5858
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
59-
<jenkins.baseline>2.387</jenkins.baseline>
60-
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
59+
<jenkins.baseline>2.479</jenkins.baseline>
60+
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
6161
</properties>
6262

6363
<dependencyManagement>
6464
<dependencies>
6565
<dependency>
6666
<groupId>io.jenkins.tools.bom</groupId>
6767
<artifactId>bom-${jenkins.baseline}.x</artifactId>
68-
<version>2543.vfb_1a_5fb_9496d</version>
68+
<version>4136.vca_c3202a_7fd1</version>
6969
<type>pom</type>
7070
<scope>import</scope>
7171
</dependency>
@@ -78,6 +78,12 @@
7878
<groupId>com.googlecode.json-simple</groupId>
7979
<artifactId>json-simple</artifactId>
8080
<version>1.1.1</version>
81+
<exclusions>
82+
<exclusion>
83+
<groupId>junit</groupId>
84+
<artifactId>junit</artifactId>
85+
</exclusion>
86+
</exclusions>
8187
</dependency>
8288
<!-- Pipeline Step dependencies -->
8389
<dependency>
@@ -116,22 +122,18 @@
116122
<dependency>
117123
<groupId>org.mockito</groupId>
118124
<artifactId>mockito-core</artifactId>
119-
<version>3.1.0</version>
120125
<scope>test</scope>
121126
</dependency>
122127
<dependency>
123128
<groupId>org.eclipse.jetty</groupId>
124129
<artifactId>jetty-util</artifactId>
125-
<version>11.0.24</version>
130+
<!-- must match version from core -->
131+
<version>12.0.16</version>
126132
<scope>test</scope>
127133
</dependency>
128134
</dependencies>
129135
<build>
130136
<plugins>
131-
<plugin>
132-
<groupId>org.jenkins-ci.tools</groupId>
133-
<artifactId>maven-hpi-plugin</artifactId>
134-
</plugin>
135137
<!-- Plugin to download the matlab run scripts and keep it under class resource folder -->
136138
<plugin>
137139
<groupId>com.googlecode.maven-download-plugin</groupId>

src/main/java/com/mathworks/ci/BuildArtifactAction.java

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.FileInputStream;
1212
import java.io.IOException;
1313
import java.io.InputStreamReader;
14+
import java.nio.charset.StandardCharsets;
1415
import java.util.ArrayList;
1516
import java.util.Iterator;
1617
import java.util.List;
@@ -27,7 +28,7 @@ public class BuildArtifactAction implements Action {
2728
private int totalCount;
2829
private int skipCount;
2930
private int failCount;
30-
private String actionID;
31+
private final String actionID;
3132
private static final String ROOT_ELEMENT = "taskDetails";
3233

3334
public BuildArtifactAction(Run<?, ?> build, String actionID) {
@@ -37,9 +38,7 @@ public BuildArtifactAction(Run<?, ?> build, String actionID) {
3738
// Setting the counts of task when Action is created.
3839
try {
3940
setCounts();
40-
} catch (ParseException e) {
41-
throw new RuntimeException(e);
42-
} catch (InterruptedException e) {
41+
} catch (ParseException | InterruptedException e) {
4342
throw new RuntimeException(e);
4443
}
4544
}
@@ -67,7 +66,7 @@ public String getUrlName() {
6766
}
6867

6968
public List<BuildArtifactData> getBuildArtifact() throws ParseException, InterruptedException, IOException {
70-
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
69+
List<BuildArtifactData> artifactData = new ArrayList<>();
7170
FilePath fl;
7271
if (this.actionID == null) {
7372
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
@@ -76,11 +75,10 @@ public List<BuildArtifactData> getBuildArtifact() throws ParseException, Interru
7675
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
7776
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
7877
}
79-
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
78+
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), StandardCharsets.UTF_8)) {
8079
Object obj = new JSONParser().parse(reader);
8180
JSONObject jo = (JSONObject) obj;
82-
if (jo.get(ROOT_ELEMENT) instanceof JSONArray) {
83-
JSONArray ja = (JSONArray) jo.get(ROOT_ELEMENT);
81+
if (jo.get(ROOT_ELEMENT) instanceof JSONArray ja) {
8482
Iterator itr2 = ja.iterator();
8583
Iterator<Entry> itr1;
8684
while (itr2.hasNext()) {
@@ -144,7 +142,7 @@ public void setOwner(Run owner) {
144142
}
145143

146144
private void setCounts() throws InterruptedException, ParseException {
147-
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
145+
List<BuildArtifactData> artifactData = new ArrayList<>();
148146
FilePath fl;
149147
if (this.actionID == null) {
150148
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
@@ -153,13 +151,12 @@ private void setCounts() throws InterruptedException, ParseException {
153151
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
154152
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
155153
}
156-
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
154+
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), StandardCharsets.UTF_8)) {
157155
Object obj = new JSONParser().parse(reader);
158156
JSONObject jo = (JSONObject) obj;
159157

160158
// getting taskDetails
161-
if (jo.get(ROOT_ELEMENT) instanceof JSONArray) {
162-
JSONArray ja = (JSONArray) jo.get(ROOT_ELEMENT);
159+
if (jo.get(ROOT_ELEMENT) instanceof JSONArray ja) {
163160
Iterator itr2 = ja.iterator();
164161
Iterator<Entry> itr1;
165162
while (itr2.hasNext()) {
@@ -223,22 +220,12 @@ private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
223220
break;
224221
case "skipReason":
225222
String skipReasonKey = pair.getValue().toString();
226-
String skipReason;
227-
switch (skipReasonKey) {
228-
case "UpToDate":
229-
skipReason = "up-to-date";
230-
break;
231-
case "UserSpecified":
232-
case "UserRequested":
233-
skipReason = "user requested";
234-
break;
235-
case "DependencyFailed":
236-
skipReason = "dependency failed";
237-
break;
238-
default:
239-
skipReason = skipReasonKey;
240-
break;
241-
}
223+
String skipReason = switch (skipReasonKey) {
224+
case "UpToDate" -> "up-to-date";
225+
case "UserSpecified", "UserRequested" -> "user requested";
226+
case "DependencyFailed" -> "dependency failed";
227+
default -> skipReasonKey;
228+
};
242229
data.setSkipReason(skipReason);
243230
break;
244231
default:

src/main/java/com/mathworks/ci/BuildConsoleAnnotator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.ByteArrayOutputStream;
1212
import java.io.IOException;
1313
import java.io.OutputStream;
14+
import java.io.Serial;
1415
import java.io.Serializable;
1516
import java.nio.ByteBuffer;
1617
import java.nio.charset.Charset;
@@ -67,10 +68,12 @@ public void close() throws IOException {
6768
}
6869

6970
private static class ConsoleLogFilterImpl extends ConsoleLogFilter implements Serializable {
71+
@Serial
7072
private static final long serialVersionUID = 1;
7173
private byte[][] buildNotes = createBuildNotes();
7274

7375
// Taking care of old MATLAB build actions.
76+
@Serial
7477
private Object readResolve() {
7578
if (buildNotes == null) {
7679
buildNotes = createBuildNotes();
@@ -79,7 +82,7 @@ private Object readResolve() {
7982
}
8083

8184
@Override
82-
public OutputStream decorateLogger(Run build, OutputStream logger) throws IOException, InterruptedException {
85+
public OutputStream decorateLogger(Run build, OutputStream logger) {
8386
return new BuildConsoleAnnotator(logger, Charsets.UTF_8, buildNotes);
8487
}
8588
}

src/main/java/com/mathworks/ci/BuildTargetNote.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import com.google.common.annotations.VisibleForTesting;
8+
import edu.umd.cs.findbugs.annotations.NonNull;
89
import hudson.Extension;
910
import hudson.MarkupText;
1011
import hudson.console.ConsoleAnnotationDescriptor;
@@ -31,6 +32,8 @@ public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
3132

3233
@Extension
3334
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor {
35+
@NonNull
36+
@Override
3437
public String getDisplayName() {
3538
return "Build targets";
3639
}

src/main/java/com/mathworks/ci/FormValidationUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Copyright 2019-2024 The MathWorks, Inc.
5-
*
5+
* <p>
66
* This is Utility class which provides commonly used methods for form validations across builders
77
*/
88

src/main/java/com/mathworks/ci/ListenerLogDecorator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
import java.io.IOException;
88
import java.io.OutputStream;
99
import java.nio.charset.Charset;
10+
import java.nio.charset.StandardCharsets;
11+
1012
import hudson.console.LineTransformationOutputStream;
1113
import hudson.model.TaskListener;
1214

1315
public class ListenerLogDecorator extends LineTransformationOutputStream {
14-
private OutputStream listener;
15-
private final Charset charsetUtf8 = Charset.forName("UTF-8");
16+
private final OutputStream listener;
17+
private final Charset charsetUtf8 = StandardCharsets.UTF_8;
1618

17-
public ListenerLogDecorator(TaskListener listner) throws IOException {
19+
public ListenerLogDecorator(TaskListener listner) {
1820
this.listener = listner != null ? listner.getLogger() : null;
1921
}
2022

src/main/java/com/mathworks/ci/MatlabBuildWrapperContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Copyright 2020-2024 The MathWorks, Inc.
5-
*
5+
* <p>
66
* Class to parse Stapler request for Use MATLAB Version build wrapper.
77
*/
88

src/main/java/com/mathworks/ci/MatlabBuilderConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class MatlabBuilderConstants {
4141
public static final String TASK_RUN_PROGRESS_PLUGIN = "+ciplugins/+jenkins/TaskRunProgressPlugin.m";
4242
public static final String BUILD_ARTIFACT = "buildArtifact";
4343

44-
public static final String NEW_LINE = System.getProperty("line.separator");
44+
public static final String NEW_LINE = System.lineSeparator();
4545

4646
// MATLAB Runner Script
4747
public static final String TEST_RUNNER_SCRIPT = String.join(NEW_LINE,

0 commit comments

Comments
 (0)