diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/pom.xml new file mode 100644 index 00000000000..34b03a21e11 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/pom.xml @@ -0,0 +1,21 @@ + + + + jetty-issue + org.mehdi + 1.0-SNAPSHOT + + 4.0.0 + + MyLibrary + + + + javax.servlet + javax.servlet-api + provided + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyAnnotation.java b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyAnnotation.java new file mode 100644 index 00000000000..ae234730a87 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyAnnotation.java @@ -0,0 +1,29 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package jettyissue; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface MyAnnotation { +} diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyServletContainerInitializer.java b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyServletContainerInitializer.java new file mode 100644 index 00000000000..bcab61c875d --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/java/jettyissue/MyServletContainerInitializer.java @@ -0,0 +1,32 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package jettyissue; + +import javax.servlet.ServletContainerInitializer; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.annotation.HandlesTypes; +import java.util.Set; + +@HandlesTypes({MyAnnotation.class}) +public class MyServletContainerInitializer implements ServletContainerInitializer { + public void onStartup(Set> c, ServletContext ctx) throws ServletException { + System.out.println("STARTED"+c); + } +} diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer new file mode 100644 index 00000000000..9e9784f1616 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyLibrary/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer @@ -0,0 +1 @@ +jettyissue.MyServletContainerInitializer diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/pom.xml new file mode 100644 index 00000000000..f09564cf1a0 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/pom.xml @@ -0,0 +1,112 @@ + + + + jetty-issue + org.mehdi + 1.0-SNAPSHOT + + 4.0.0 + + MyWebApp + jar + + + ${project.build.directory}/jetty-run-mojo.txt + + + + + javax.servlet + javax.servlet-api + provided + + + org.mehdi + MyLibrary + + + + org.eclipse.jetty + jetty-client + test + + + org.apache.commons + commons-lang3 + test + + + org.eclipse.jetty + jetty-maven-plugin + tests + test-jar + test + + + * + * + + + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${jetty.port.file} + /setbycontextxml + false + false + false + ${project.groupId}:${project.artifactId} + + + org.eclipse.jetty:jetty-maven-plugin + + + + + org.eclipse.jetty + jetty-maven-plugin + + + start-jetty + test-compile + + start + + + + + jetty.port.file + ${jetty.port.file} + + + true + ${basedir}/src/config/jetty.xml + ${basedir}/src/config/context.xml + true + + jar + + + + + + + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/context.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/context.xml new file mode 100644 index 00000000000..3eb5570a37d --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/context.xml @@ -0,0 +1,7 @@ + + + + + /setbycontextxml + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/jetty.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/jetty.xml new file mode 100644 index 00000000000..9193b42df99 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/config/jetty.xml @@ -0,0 +1,39 @@ + + + + + https + + 32768 + 8192 + 8192 + 1024 + + + + + + + + + + + + + + + + + + + + + + + + 0 + 30000 + + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/java/jettyissue/NormalClass.java b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/java/jettyissue/NormalClass.java new file mode 100644 index 00000000000..9cea88de8a8 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/java/jettyissue/NormalClass.java @@ -0,0 +1,24 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package jettyissue; + + +@MyAnnotation +public class NormalClass { +} diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/webapp/index.html b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/webapp/index.html new file mode 100644 index 00000000000..b7b5cdc61de --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/MyWebApp/src/main/webapp/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + Hello World! + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/invoker.properties new file mode 100644 index 00000000000..e0222d4d54e --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/invoker.properties @@ -0,0 +1 @@ +invoker.goals = test \ No newline at end of file diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/pom.xml new file mode 100644 index 00000000000..1380e37256e --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + org.eclipse.jetty.its + it-parent-pom + 0.0.1-SNAPSHOT + + + + org.mehdi + jetty-issue + pom + 1.0-SNAPSHOT + + MyLibrary + MyWebApp + + + + + + org.mehdi + MyLibrary + ${project.version} + + + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/postbuild.groovy b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/postbuild.groovy new file mode 100644 index 00000000000..87a9e7b26cc --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-mojo-jar-scan-it/postbuild.groovy @@ -0,0 +1,3 @@ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( 'Started Jetty Server' ) +assert buildLog.text.contains( 'STARTED[class jettyissue.NormalClass]') diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java index 39b5a43bf6b..a826dc23c17 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java @@ -257,7 +257,7 @@ public class JettyRunMojo extends AbstractJettyMojo webApp.setTestClasses(testClassesDirectory); MavenProjectHelper mavenProjectHelper = new MavenProjectHelper(project); - List webInfLibs = getWebInfLibArtifacts(project).stream() + List webInfLibs = getWebInfLibArtifacts(project.getArtifacts()).stream() .map(a -> { Path p = mavenProjectHelper.getArtifactPath(a); @@ -479,16 +479,6 @@ public class JettyRunMojo extends AbstractJettyMojo .collect(Collectors.toList()); } - private Collection getWebInfLibArtifacts(MavenProject mavenProject) - { - String type = mavenProject.getArtifact().getType(); - if (!"war".equalsIgnoreCase(type) && !"zip".equalsIgnoreCase(type)) - { - return Collections.emptyList(); - } - return getWebInfLibArtifacts(mavenProject.getArtifacts()); - } - private boolean canPutArtifactInWebInfLib(Artifact artifact) { if ("war".equalsIgnoreCase(artifact.getType()))