Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x
This commit is contained in:
commit
cf493908c5
|
@ -0,0 +1 @@
|
|||
invoker.goals = test
|
|
@ -0,0 +1,40 @@
|
|||
<?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>test.jetty-effective-web-xml-it</groupId>
|
||||
<artifactId>jetty-effective-web-xml-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: effective web xml multi-module project</name>
|
||||
|
||||
<modules>
|
||||
<module>resources</module>
|
||||
<module>webapp-war</module>
|
||||
</modules>
|
||||
|
||||
<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>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>test.jetty-effective-web-xml-it</groupId>
|
||||
<artifactId>resources</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
def rootNode = new XmlParser().parse(new File( basedir, 'webapp-war/target/effective-web.xml'))
|
||||
// find context-param node with param-name == org.eclipse.jetty.resources
|
||||
def ctxParam = rootNode.'**'.find{it.text() == "org.eclipse.jetty.resources"}.parent()
|
||||
def paramValue = ctxParam.'param-value'.get(0).text().trim()
|
||||
// assert the value of param-value child node
|
||||
assert paramValue.contains('${user.dir.uri}/resources/target/classes/META-INF/resources')
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>test.jetty-effective-web-xml-it</groupId>
|
||||
<artifactId>jetty-effective-web-xml-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>resources</artifactId>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
public class Placeholder
|
||||
{
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<html>
|
||||
<h1>Extra Resource</h1>
|
||||
</html>
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>test.jetty-effective-web-xml-it</groupId>
|
||||
<artifactId>jetty-effective-web-xml-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>webapp-war</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>test.jetty-effective-web-xml-it</groupId>
|
||||
<artifactId>resources</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<jetty.port.file>${project.build.directory}/jetty-effective-web-xml-mojo.txt</jetty.port.file>
|
||||
<jetty.deployMode>EMBED</jetty.deployMode>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>gen-effective-web-xml</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>effective-web-xml</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<webApp>
|
||||
<war>src/main/webapp</war>
|
||||
</webApp>
|
||||
<systemProperties>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemProperties>
|
||||
<jettyXmls>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
</jettyXmls>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -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>
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
import java.net.URL;
|
||||
import jakarta.servlet.ServletContextEvent;
|
||||
import jakarta.servlet.ServletContextListener;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
public class WebAppServletListener implements ServletContextListener
|
||||
{
|
||||
|
||||
//Empty class, just to have something in src/main/java
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!DOCTYPE web-app
|
||||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
<listener>
|
||||
<listener-class>WebAppServletListener</listener-class>
|
||||
</listener>
|
||||
</web-app>
|
|
@ -14,6 +14,12 @@
|
|||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
|
@ -38,11 +44,30 @@ public class JettyEffectiveWebXml extends AbstractUnassembledWebAppMojo
|
|||
@Override
|
||||
public void configureWebApp() throws Exception
|
||||
{
|
||||
//Use a nominated war file for which to generate the effective web.xml, or
|
||||
//if that is not set, try to use the details of the current project's
|
||||
//unassembled webapp
|
||||
super.configureWebApp();
|
||||
if (StringUtil.isBlank(webApp.getWar()))
|
||||
|
||||
//Try to determine if we're using an unassembled webapp, or an
|
||||
//external||prebuilt webapp
|
||||
String war = webApp.getWar();
|
||||
Path path = null;
|
||||
if (war != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = new URL(war);
|
||||
path = Paths.get(url.toURI());
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
path = Paths.get(war);
|
||||
}
|
||||
}
|
||||
|
||||
Path start = path.getName(0);
|
||||
int count = path.getNameCount();
|
||||
Path end = path.getName(count > 0 ? count - 1 : count);
|
||||
//if the war is not assembled, we must configure it
|
||||
if (start.startsWith("src") || !end.toString().endsWith(".war"))
|
||||
super.configureUnassembledWebApp();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue