Skip to content

Commit

Permalink
[JENKINS-73123] Upgrade HPI plugin from Jetty 10.x to 12.x (EE 8)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Aug 8, 2024
1 parent 502eb2d commit a76024f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
3 changes: 1 addition & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def runTests(Map params = [:]) {

parallel(
'linux-21': runTests(platform: 'linux', jdk: 21),
'windows-17': runTests(platform: 'windows', jdk: 17),
'linux-11': runTests(platform: 'linux', jdk: 11)
'windows-17': runTests(platform: 'windows', jdk: 17)
)
infra.maybePublishIncrementals()
40 changes: 35 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,30 @@
<dollar>$</dollar>
<openbracket>{</openbracket>
<gitHubRepo>jenkinsci/${project.artifactId}</gitHubRepo>
<jetty.version>12.0.11</jetty.version>
<!-- if we update this all consumers need to be running at least this version -->
<maven.version>3.8.1</maven.version>
<!-- TODO until a critical mass of plugins has migrated to Java 17 -->
<maven.compiler.release>11</maven.compiler.release>
<maven-plugin-tools.version>3.13.1</maven-plugin-tools.version>
<maven-resolver.version>2.0.0</maven-resolver.version>
<spotless.check.skip>false</spotless.check.skip>
</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.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-bom</artifactId>
<version>${jetty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-bom</artifactId>
Expand Down Expand Up @@ -159,15 +172,32 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>10.0.22</version>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-maven-plugin</artifactId>
<version>${jetty.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8.websocket</groupId>
<artifactId>jetty-ee8-websocket-jetty-server</artifactId>
<!-- or jetty-ee8-websocket-javax-server -->
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>version-number</artifactId>
Expand Down Expand Up @@ -289,7 +319,7 @@
<configuration>
<goalPrefix>hpi</goalPrefix>
<extractors>java-annotations</extractors>
<mojoDependencies>org.eclipse.jetty:jetty-maven-plugin</mojoDependencies>
<mojoDependencies>org.eclipse.jetty.ee8:jetty-ee8-maven-plugin</mojoDependencies>
</configuration>
<executions>
<execution>
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
import org.eclipse.jetty.ee8.maven.plugin.JettyRunWarMojo;
import org.eclipse.jetty.ee8.maven.plugin.MavenWebAppContext;
import org.eclipse.jetty.ee8.webapp.WebAppClassLoader;
import org.eclipse.jetty.ee8.webapp.WebAppContext;
import org.eclipse.jetty.ee8.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.maven.plugin.JettyRunWarMojo;
import org.eclipse.jetty.maven.plugin.MavenServerConnector;
import org.eclipse.jetty.maven.plugin.MavenWebAppContext;
import org.eclipse.jetty.maven.MavenServerConnector;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.UserStore;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.twdata.maven.mojoexecutor.MojoExecutor;
import sun.misc.Unsafe;

Expand Down Expand Up @@ -286,7 +286,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
"Please use `webApp/contextPath` configuration parameter in place of the deprecated `contextPath` parameter");
if (webApp == null) {
try {
webApp = new MavenWebAppContext();
webApp = new MavenWebAppContext() {
@Override
protected ClassLoader configureClassLoader(ClassLoader loader) {
return getWebAppClassLoader(this);
}
};
} catch (Exception e) {
throw new MojoExecutionException("Failed to initialize webApp configuration", e);
}
Expand Down Expand Up @@ -726,7 +731,9 @@ private void finishConfigurationBeforeStart() {
.getSessionCookieConfig()
.setName("JSESSIONID."
+ UUID.randomUUID().toString().replace("-", "").substring(0, 8));
}

private ClassLoader getWebAppClassLoader(WebAppContext wac) {
try {
// for Jenkins modules, swap the component from jenkins.war by target/classes
// via classloader magic
Expand Down Expand Up @@ -782,7 +789,7 @@ public void addJars(org.eclipse.jetty.util.resource.Resource lib) {
super.addJars(lib);
}
};
wac.setClassLoader(wacl);
return wacl;
} catch (IOException e) {
throw new Error(e);
}
Expand Down
1 change: 1 addition & 0 deletions src/spotbugs/excludesFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Class name="org.jenkinsci.maven.plugins.hpi.JarMojo"/>
<Class name="org.jenkinsci.maven.plugins.hpi.RunMojo"/>
<Class name="org.jenkinsci.maven.plugins.hpi.RunMojo$1"/>
<Class name="org.jenkinsci.maven.plugins.hpi.RunMojo$2"/>
<Class name="org.jenkinsci.maven.plugins.hpi.TagLibInterfaceGeneratorMojo"/>
<Class name="org.jenkinsci.maven.plugins.hpi.TestDependencyMojo"/>
<Class name="org.jenkinsci.maven.plugins.hpi.TestHplMojo"/>
Expand Down

0 comments on commit a76024f

Please sign in to comment.