From 97cd8908a728192ecd5ff7be1d2aa88eec5b4cdb Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 18 Oct 2024 14:21:12 -0600 Subject: [PATCH] Require Jenkins 2.479 or newer Updates to use StaplerRequest2 and StaplerResponse2 and to use Jakarta EE 9 instead of Java EE 8. Updates to use more recent parent pom and matching plugin BOM. --- pom.xml | 9 ++++++--- .../jenkins/advancedqueue/PriorityConfiguration.java | 8 ++++---- .../priority/strategy/PriorityJobProperty.java | 4 ++-- .../sorter/strategy/MultiBucketStrategy.java | 2 +- .../java/jenkins/advancedqueue/test/SubmitTest.java | 10 +++++----- .../java/org/kohsuke/stapler/MockStaplerRequest.java | 6 +++--- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index d012a4a5..e34c0e04 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.88 + 5.2 @@ -45,8 +45,11 @@ 5.2.1 -SNAPSHOT jenkinsci/priority-sorter-plugin - 2.452 - ${jenkins.baseline}.4 + + 2.479 + + + ${jenkins.baseline} Max Low false diff --git a/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java b/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java index fd56e1e9..257ea404 100644 --- a/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java +++ b/src/main/java/jenkins/advancedqueue/PriorityConfiguration.java @@ -40,6 +40,7 @@ import hudson.security.ACL; import hudson.util.FormValidation; import hudson.util.ListBoxModel; +import jakarta.servlet.ServletException; import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -50,7 +51,6 @@ import java.util.logging.Logger; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import javax.servlet.ServletException; import jenkins.advancedqueue.jobinclusion.JobInclusionStrategy; import jenkins.advancedqueue.priority.PriorityStrategy; import jenkins.model.GlobalConfiguration; @@ -62,8 +62,8 @@ import org.jenkins.ui.icon.IconSpec; import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution; import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; /** * @author Magnus Sandberg @@ -165,7 +165,7 @@ public ListBoxModel getPriorities() { return items; } - public void doPriorityConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { + public void doPriorityConfigSubmit(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException { jobGroups = new LinkedList(); id2jobGroup = new HashMap(); // diff --git a/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java b/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java index 3ceef741..26dafb0b 100644 --- a/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java +++ b/src/main/java/jenkins/advancedqueue/priority/strategy/PriorityJobProperty.java @@ -41,7 +41,7 @@ import jenkins.advancedqueue.priority.PriorityStrategy; import net.sf.json.JSONObject; import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * @author Magnus Sandberg @@ -55,7 +55,7 @@ public class PriorityJobProperty extends JobProperty> { public final int priority; @Override - public JobProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { + public JobProperty reconfigure(StaplerRequest2 req, JSONObject form) throws FormException { return super.reconfigure(req, form); } diff --git a/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java b/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java index b9a34e62..2e7a687d 100644 --- a/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java +++ b/src/main/java/jenkins/advancedqueue/sorter/strategy/MultiBucketStrategy.java @@ -25,8 +25,8 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.util.ListBoxModel; +import jakarta.servlet.ServletException; import java.io.IOException; -import javax.servlet.ServletException; import jenkins.advancedqueue.PrioritySorterConfiguration; import jenkins.advancedqueue.sorter.SorterStrategy; import jenkins.advancedqueue.sorter.SorterStrategyDescriptor; diff --git a/src/test/java/jenkins/advancedqueue/test/SubmitTest.java b/src/test/java/jenkins/advancedqueue/test/SubmitTest.java index 65c7b7ee..3009b095 100644 --- a/src/test/java/jenkins/advancedqueue/test/SubmitTest.java +++ b/src/test/java/jenkins/advancedqueue/test/SubmitTest.java @@ -6,10 +6,10 @@ import static org.mockito.Mockito.when; import com.google.common.base.Charsets; +import jakarta.servlet.ServletException; import java.io.IOException; import java.io.InputStream; import java.util.List; -import javax.servlet.ServletException; import jenkins.advancedqueue.JobGroup; import jenkins.advancedqueue.PriorityConfiguration; import jenkins.advancedqueue.jobinclusion.strategy.ViewBasedJobInclusionStrategy; @@ -20,8 +20,8 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.recipes.LocalData; import org.kohsuke.stapler.MockStaplerRequest; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; public class SubmitTest { @@ -33,8 +33,8 @@ public class SubmitTest { public void shouldGeneratePriorityConfigurationUsingDataBoundConstructor() throws IOException, ServletException { PriorityConfiguration priorityConfiguration = (PriorityConfiguration) j.jenkins.getDescriptor(PriorityConfiguration.class); - StaplerResponse staplerResponse = mock(StaplerResponse.class); - StaplerRequest staplerRequest = new MockStaplerRequest.MockStaplerRequestBuilder( + StaplerResponse2 staplerResponse = mock(StaplerResponse2.class); + StaplerRequest2 staplerRequest = new MockStaplerRequest.MockStaplerRequestBuilder( j, "advanced-build-queue/priorityConfigSubmit") .build(); diff --git a/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java b/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java index b94c9926..7f7b323a 100644 --- a/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java +++ b/src/test/java/org/kohsuke/stapler/MockStaplerRequest.java @@ -26,11 +26,11 @@ import static org.mockito.Mockito.mock; import edu.umd.cs.findbugs.annotations.NonNull; +import jakarta.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletRequest; import org.jvnet.hudson.test.JenkinsRule; public class MockStaplerRequest { @@ -63,14 +63,14 @@ public MockStaplerRequestBuilder withAncestor(AncestorImpl ancestor) { return this; } - public StaplerRequest build() throws AssertionError { + public StaplerRequest2 build() throws AssertionError { HttpServletRequest rawRequest = mock(HttpServletRequest.class); return new RequestImpl(stapler != null ? stapler : getStapler(), rawRequest, ancestors, tokens); } private Stapler getStapler() { final Stapler stapler = new Stapler(); - stapler.setWebApp(new WebApp(r.jenkins.servletContext)); + stapler.setWebApp(new WebApp(r.jenkins.getServletContext())); return stapler; } }