-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Issue #7677 Exclude findbugs jsr305 jar from plugin Signed-off-by: Jan Bartel <[email protected]> * add IT test for those classes exclusions Signed-off-by: Olivier Lamy <[email protected]>
- Loading branch information
Showing
7 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
jetty-maven-plugin/src/it/exclude-javax-annotation/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals = test -e |
104 changes: 104 additions & 0 deletions
104
jetty-maven-plugin/src/it/exclude-javax-annotation/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?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.github.unb</groupId> | ||
<artifactId>jetty-7677</artifactId> | ||
<version>1.0</version> | ||
<packaging>war</packaging> | ||
|
||
<name>jetty-7677</name> | ||
|
||
<properties> | ||
<jetty.port.file>${project.build.directory}/jetty-start-it.txt</jetty.port.file> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>IntegrationTest*.java</include> | ||
</includes> | ||
<systemPropertyVariables> | ||
<jetty.port.file>${jetty.port.file}</jetty.port.file> | ||
<context.path>/</context.path> | ||
<pingServlet>fals</pingServlet> | ||
<helloServlet>false</helloServlet> | ||
<contentCheck>class javax.annotation.Nullable not found</contentCheck> | ||
<pathToCheck>/test</pathToCheck> | ||
<maven.it.name>${project.groupId}:${project.artifactId}</maven.it.name> | ||
</systemPropertyVariables> | ||
<dependenciesToScan> | ||
<dependency>org.eclipse.jetty:jetty-maven-plugin</dependency> | ||
</dependenciesToScan> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-jetty</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
<configuration> | ||
<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> |
24 changes: 24 additions & 0 deletions
24
jetty-maven-plugin/src/it/exclude-javax-annotation/postbuild.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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') | ||
assert buildLog.text.contains( 'Tests run: 1, Failures: 0, Errors: 0, Skipped: 0') | ||
assert buildLog.text.contains( 'contentCheck') | ||
|
40 changes: 40 additions & 0 deletions
40
jetty-maven-plugin/src/it/exclude-javax-annotation/src/config/jetty.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
81 changes: 81 additions & 0 deletions
81
...aven-plugin/src/it/exclude-javax-annotation/src/main/java/org/github/unb/TestServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// ======================================================================== | ||
// 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 | ||
// ======================================================================== | ||
// | ||
|
||
package org.github.unb; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@WebServlet("/test") | ||
public class TestServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
response.setContentType("text/plain"); | ||
|
||
try { | ||
HttpServlet.class.getClassLoader().loadClass("javax.annotation.Nullable"); | ||
} catch (ClassNotFoundException e) { | ||
response.getWriter().write("class javax.annotation.Nullable not found"); | ||
return; | ||
} | ||
|
||
Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF"); | ||
List<String> jars = new ArrayList<>(); | ||
while (resources.hasMoreElements()) { | ||
URL url = resources.nextElement(); | ||
String jar = getJar(url); | ||
if (jar != null) { | ||
jars.add(jar); | ||
} | ||
} | ||
|
||
|
||
|
||
Collections.sort(jars); | ||
String body = jars.stream().map(Object::toString).collect(Collectors.joining("\n", "", "\n")); | ||
response.getWriter().write(body); | ||
} | ||
|
||
/** | ||
* Tries to determine the JAR from a MANIFEST.MF url. | ||
* | ||
* @param url the MANIFEST.MF url | ||
* @return the corresponding jar, or {@code null} if one cannot be determined | ||
*/ | ||
private String getJar(URL url) { | ||
String result = null; | ||
String path = url.getPath(); | ||
int index = path.lastIndexOf('!'); | ||
if (index > 0) { | ||
path = path.substring(0, index); | ||
index = path.lastIndexOf('/'); | ||
if (index >= 0) { | ||
path = path.substring(index + 1); | ||
result = path.length() > 0 ? path : null; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters