Skip to content

Commit

Permalink
Jetty 10 based JenkinsRule
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Aug 2, 2022
1 parent a7cb85d commit 5a0551f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 154 deletions.
3 changes: 1 addition & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* allowing one to test against multiple Jenkins versions.
*/
buildPlugin(useContainerAgent: true, configurations: [
[ platform: 'linux', jdk: '8' ],
[ platform: 'linux', jdk: '11' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17', jenkins: '2.360' ],
[ platform: 'linux', jdk: '17' ],
])
172 changes: 20 additions & 152 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ THE SOFTWARE.

<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.249</jenkins.version>
<jenkins.version>2.362-rc32715.7e7a_5ef84107</jenkins.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>9.4.48.v20220622</jetty.version>
<jetty.version>10.0.11</jetty.version>
<hamcrest.version>2.2</hamcrest.version>
<jmh.version>1.35</jmh.version>
<gitHubRepo>jenkinsci/${project.artifactId}</gitHubRepo>
Expand All @@ -67,10 +67,19 @@ THE SOFTWARE.
<concurrency>1</concurrency>

<spotbugs.excludeFilterFile>${project.basedir}/src/spotbugs/excludesFilter.xml</spotbugs.excludeFilterFile>

<jenkins.insaneHook>--patch-module=java.base=${project.build.outputDirectory}/netbeans/harness/modules/ext/org-netbeans-insane-hook.jar --add-exports=java.base/org.netbeans.insane.hook=ALL-UNNAMED</jenkins.insaneHook>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-bom</artifactId>
<version>${jetty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
Expand Down Expand Up @@ -137,23 +146,22 @@ THE SOFTWARE.
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-api</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<!-- or javax-websocket-server-impl -->
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${jetty.version}</version>
<!-- or websocket-javax-server -->
<artifactId>websocket-jetty-server</artifactId>
<!-- until Jetty release including https://github.com/eclipse/jetty.project/pull/8199 -->
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down Expand Up @@ -244,25 +252,6 @@ THE SOFTWARE.
</pluginRepositories>
<build>
<plugins>
<!-- TODO When the minimum Jenkins baseline is bumped past 2.357, this can be deleted. -->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>display-info</id>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8.0,]</version>
</requireJavaVersion>
<enforceBytecodeVersion>
<maxJdkVersion>1.8</maxJdkVersion>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -290,25 +279,6 @@ THE SOFTWARE.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<requireUpperBoundDeps>
<excludes combine.children="append">
<!--
Stapler requests Guava 14.0 and Jenkins core requests Guice 4.0 which requests
Guava 16.0.1. Core actually provides 11.0.1. Work around this mess by just
excluding Guava from the RequireUpperBoundDeps check. The long-term fix is
tracked in JENKINS-36779.
-->
<exclude>com.google.guava:guava</exclude>
</excludes>
</requireUpperBoundDeps>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -365,66 +335,6 @@ THE SOFTWARE.
</build>

<profiles>
<profile>
<id>jdk-9-and-above</id>
<!-- TODO When the minimum Jenkins baseline is bumped past 2.357, this can be lifted out of the profile. -->
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<jenkins.insaneHook>--patch-module=java.base=${project.build.outputDirectory}/netbeans/harness/modules/ext/org-netbeans-insane-hook.jar --add-exports=java.base/org.netbeans.insane.hook=ALL-UNNAMED</jenkins.insaneHook>
</properties>
<!-- TODO When the minimum Jenkins baseline is bumped past 2.357, this can be deleted. -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>8</release>
<testRelease>8</testRelease>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- TODO When the minimum Jenkins baseline is bumped past 2.357, this can be deleted. -->
<profile>
<id>jdk-8-and-below</id>
<activation>
<jdk>(,1.8]</jdk>
</activation>
<properties>
<jenkins.insaneHook>-Xbootclasspath/p:${project.build.outputDirectory}/netbeans/harness/modules/ext/org-netbeans-insane-hook.jar</jenkins.insaneHook>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
<release combine.self="override" />
<testRelease combine.self="override" />
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>1.8</source>
<release combine.self="override" />
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>skip-tests-on-release</id>
<activation>
Expand Down Expand Up @@ -473,48 +383,6 @@ THE SOFTWARE.
</plugins>
</build>
</profile>
<!--
Our Jenkinsfile has a Java 17 branch that tests a recent weekly release for two reasons:

1. We want to test on all versions of Java, but only recent weeklies support Java 17.

2. Testing against a recent weekly release ensures that the test harness can be compiled
against the latest core APIs.

When we are testing against a recent weekly that requires Java 11, the bytecode version
check naturally fails. To work around this, we relax the bytecode version check
when we are executing the Java 17 branch in the CI environment.

TODO When the minimum Jenkins baseline is bumped past 2.357, this can be deleted.
-->
<profile>
<id>test-recent-cores-on-ci</id>
<activation>
<jdk>17</jdk>
<property>
<name>env.CI</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>display-info</id>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>11</maxJdkVersion>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
6 changes: 6 additions & 0 deletions src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.apache.commons.beanutils.PropertyUtils;
import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.LoginService;
import org.eclipse.jetty.security.UserStore;
Expand All @@ -179,6 +181,7 @@
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.jvnet.hudson.test.HudsonHomeLoader.CopyExisting;
import org.jvnet.hudson.test.recipes.Recipe;
import org.jvnet.hudson.test.recipes.Recipe.Runner;
Expand Down Expand Up @@ -543,6 +546,7 @@ protected ServletContext createWebServer() throws Exception {
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
JettyWebSocketServletContainerInitializer.configure(context, null);
context.setMimeTypes(MIME_TYPES);
context.getSecurityHandler().setLoginService(configureUserRealm());

Expand All @@ -551,6 +555,8 @@ protected ServletContext createWebServer() throws Exception {
HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
// use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
config.setRequestHeaderSize(12 * 1024);
config.setHttpCompliance(HttpCompliance.RFC7230);
config.setUriCompliance(UriCompliance.LEGACY);
connector.setHost("localhost");

server.addConnector(connector);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.LoginService;
import org.eclipse.jetty.security.UserStore;
Expand All @@ -219,6 +221,7 @@
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -804,6 +807,7 @@ public static ImmutablePair<Server, ServletContext> _createWebServer(String cont
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
JettyWebSocketServletContainerInitializer.configure(context, null);
context.setMimeTypes(MIME_TYPES);
context.getSecurityHandler().setLoginService(loginServiceSupplier.get());
context.setResourceBase(WarExploder.getExplodedDir().getPath());
Expand All @@ -812,6 +816,8 @@ public static ImmutablePair<Server, ServletContext> _createWebServer(String cont
HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
// use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
config.setRequestHeaderSize(12 * 1024);
config.setHttpCompliance(HttpCompliance.RFC7230);
config.setUriCompliance(UriCompliance.LEGACY);
connector.setHost("localhost");
if (System.getProperty("port") != null) {
connector.setPort(Integer.parseInt(System.getProperty("port")));
Expand Down

0 comments on commit 5a0551f

Please sign in to comment.