Jetty 10.0.x add plugin overlay test (#9045)

* Add overlay test for jetty-maven-plugin 

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2022-12-19 09:17:09 +11:00 committed by GitHub
parent d24a521930
commit aa40193d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 283 additions and 4 deletions

View File

@ -0,0 +1 @@
invoker.goals = verify

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>jetty-simple-base-webapp</artifactId>
<packaging>war</packaging>
<name>Jetty :: Simple :: Base Webapp</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,5 @@
<html>
<body>
<h1>Simple Base Webapp Index</h1>
</body>
</html>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>jetty-simple-webapp</artifactId>
<packaging>war</packaging>
<name>Jetty :: Simple :: Webapp</name>
<properties>
<jetty.port.file>${project.build.directory}/jetty-start-port.txt</jetty.port.file>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-base-webapp</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<overlays>
<overlay>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-base-webapp</artifactId>
<includes>
<include>index.html</include>
</includes>
</overlay>
<overlay/>
</overlays>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>run-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>IntegrationTest*.java</include>
</includes>
<systemPropertyVariables>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
<context.path>/setbycontextxml</context.path>
<contentCheck>Simple Base Webapp Index</contentCheck>
<pathToCheck>/index.html</pathToCheck>
<maven.it.name>${project.groupId}:${project.artifactId}</maven.it.name>
</systemPropertyVariables>
<dependenciesToScan>
<dependency>org.eclipse.jetty:jetty-maven-plugin</dependency>
</dependenciesToScan>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<contextXml>${basedir}/src/config/context.xml</contextXml>
<systemProperties>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
<jetty.deployMode>EMBED</jetty.deployMode>
</systemProperties>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/setbycontextxml</Set>
</Configure>

View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme">https</Set>
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
<Set name="outputBufferSize">32768</Set>
<Set name="requestHeaderSize">8192</Set>
<Set name="responseHeaderSize">8192</Set>
<Set name="headerCacheSize">1024</Set>
</New>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="httpConfig" /></Arg>
</New>
</Item>
</Array>
</Arg>
<Call name="addEventListener">
<Arg>
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
</New>
</Arg>
</Call>
<Set name="host" property="jetty.host"/>
<Set name="port" property="jetty.port"/>
<Set name="idleTimeout">30000</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,5 @@
<html>
<body>
<h1>Simple WebApp Index</h1>
</body>
</html>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its</groupId>
<artifactId>it-parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jetty :: Simple Overlay</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jetty.version>@project.version@</jetty.version>
</properties>
<modules>
<module>jetty-simple-base-webapp</module>
<module>jetty-simple-webapp</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-start-overlay-it</groupId>
<artifactId>jetty-simple-base-webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.IntegrationTestGetContent')

View File

@ -176,6 +176,7 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo
if (webApp.getDescriptor() == null && webApp.getBaseResource() != null)
{
Resource r = webApp.getBaseResource().addPath("WEB-INF/web.xml");
if (r.exists() && !r.isDirectory())
{
webApp.setDescriptor(r.toString());
@ -192,7 +193,7 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo
}
}
}
//process any overlays and the war type artifacts, and
//sets up the base resource collection for the webapp
mavenProjectHelper.getOverlayManager().applyOverlays(webApp);

View File

@ -95,7 +95,7 @@ public class OverlayManager
//if a war matches an overlay config
Artifact a = warPlugin.getWarArtifact(config.getGroupId(), config.getArtifactId(), config.getClassifier());
if (a != null)
{
{
matchedWarArtifacts.add(a);
SelectiveJarResource r = new SelectiveJarResource(new URL("jar:" + Resource.toURL(a.getFile()).toString() + "!/"));
r.setIncludes(config.getIncludes());
@ -126,7 +126,7 @@ public class OverlayManager
*/
protected Resource unpackOverlay(Overlay overlay)
throws IOException
{
{
if (overlay.getResource() == null)
return null; //nothing to unpack

View File

@ -106,6 +106,8 @@ public class MavenProjectHelper
*/
public MavenProject getMavenProjectFor(Artifact artifact)
{
if (artifact == null)
return null;
return artifactToReactorProjectMap.get(artifact.getId());
}
@ -136,7 +138,7 @@ public class MavenProjectHelper
}
return path;
}
/**
* Given the coordinates for an artifact, resolve the artifact from the
* remote repositories.