Skip to content

Commit

Permalink
Require Jenkins 2.479 or newer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MarkEWaite committed Oct 24, 2024
1 parent c7f791d commit 97cd890
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.88</version>
<version>5.2</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -45,8 +45,11 @@
<revision>5.2.1</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/priority-sorter-plugin</gitHubRepo>
<jenkins.baseline>2.452</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.4</jenkins.version>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.479</jenkins.baseline>
<!-- TODO Replace with the standard jenkins.baseline references after LTS requires Java 17 -->
<!-- <jenkins.version>${jenkins.baseline}.1</jenkins.version> -->
<jenkins.version>${jenkins.baseline}</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
<spotless.check.skip>false</spotless.check.skip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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<JobGroup>();
id2jobGroup = new HashMap<Integer, JobGroup>();
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,7 +55,7 @@ public class PriorityJobProperty extends JobProperty<Job<?, ?>> {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/jenkins/advancedqueue/test/SubmitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/kohsuke/stapler/MockStaplerRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 97cd890

Please sign in to comment.