diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 31a195c1407..286dcccae2c 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -40,13 +40,13 @@ public class TestHelloServlet
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse hello annotation servlet:" + response );
Assert.assertEquals( "hello beer", response.trim() );
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse ping fragment servlet:" + response );
Assert.assertEquals( "pong beer", response.trim() );
}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
index 7fb521911d7..a7e8ccdba9b 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
@@ -21,6 +21,11 @@
jetty-simple-base
+
+ org.slf4j
+ slf4j-simple
+
+
org.eclipse.jetty
jetty-servlet
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 5d700a60525..6fc5cb06e25 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -41,13 +41,13 @@ public class TestHelloServlet
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse hello annotation servlet:" + response );
Assert.assertEquals( "hello beer", response.trim() );
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse ping fragment servlet:" + response );
Assert.assertEquals( "pong beer", response.trim() );
}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
index 213a79af16b..313904bfff4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
@@ -46,6 +46,12 @@
1.7.21
+
+ org.slf4j
+ slf4j-simple
+ 1.7.21
+
+
commons-io
commons-io
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 94102e9db95..3db13bf6f90 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
@@ -32,6 +32,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
@@ -283,24 +284,13 @@ public class JettyRunMojo extends AbstractJettyMojo
if (useTestScope && (testClassesDirectory != null))
webApp.setTestClasses (testClassesDirectory);
- List dependencyProjects = getDependencyProjects();
- webApp.getClassPathFiles().addAll( dependencyProjects );
- List dependencyResources = //
- dependencyProjects.stream() //
- .map( file -> Resource.newResource( file ) ) //
- .collect( Collectors.toList() );
- webApp.getMetaData().getContainerResources().addAll( dependencyResources );
- webApp.setWebInfLib (getDependencyFiles());
-// webApp.getWebInfLib().addAll( dependencyResources //
-// .stream() //
-// .map( resource -> toFile(resource) ) //
-// .collect( Collectors.toList() ) );
- webApp.getDependentProjects().addAll( dependencyResources );
+ webApp.setWebInfLib(getDependencyFiles());
+
//get copy of a list of war artifacts
Set matchedWarArtifacts = new HashSet();
//process any overlays and the war type artifacts
- List overlays = new ArrayList();
+ List overlays = new ArrayList<>();
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
{
//overlays can be individually skipped
@@ -596,8 +586,12 @@ public class JettyRunMojo extends AbstractJettyMojo
{
continue;
}
- if (getProjectReferences( artifact, project )!=null)
+ MavenProject mavenProject = getProjectReferences( artifact, project );
+ if (mavenProject != null)
{
+ File projectPath = Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile();
+ getLog().debug( "Adding project directory " + projectPath.toString() );
+ dependencyFiles.add( projectPath );
continue;
}
@@ -614,38 +608,6 @@ public class JettyRunMojo extends AbstractJettyMojo
return dependencyFiles;
}
- private List getDependencyProjects()
- {
- List dependencyFiles = new ArrayList<>();
- for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
- {
- Artifact artifact = iter.next();
-
- // Include runtime and compile time libraries, and possibly test libs too
- if(artifact.getType().equals("war"))
- {
- continue;
- }
-
- if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
- continue; //never add dependencies of scope=provided to the webapp's classpath (see also param)
-
- if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
- continue; //only add dependencies of scope=test if explicitly required
-
- MavenProject mavenProject = getProjectReferences( artifact, project );
- if (mavenProject != null)
- {
- dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
- getLog().debug( "Adding project reference " + mavenProject.getBuild().getOutputDirectory()
- + " for WEB-INF/classes " );
- }
- }
-
- return dependencyFiles;
- }
-
-
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
{
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index 3ec20ce8081..fbd9a36e4ec 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -104,7 +104,6 @@ public class JettyWebAppContext extends WebAppContext
private Resource _quickStartWebXml;
private String _originAttribute;
private boolean _generateOrigin;
- private List dependentProjects = new ArrayList<>();
/**
* Set the "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" with a pattern for matching jars on
@@ -320,9 +319,9 @@ public class JettyWebAppContext extends WebAppContext
return _webInfJars;
}
- public List getDependentProjects()
+ public List getWebInfClasses()
{
- return dependentProjects;
+ return _webInfClasses;
}
/* ------------------------------------------------------------ */
@@ -336,7 +335,7 @@ public class JettyWebAppContext extends WebAppContext
{
return _isGenerateQuickStart;
}
-
+
/* ------------------------------------------------------------ */
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
index 440238d22b4..e875c19c0d7 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
@@ -84,23 +84,6 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
context.setServerClasses( newServerClasses );
}
-
-
-
- /**
- * @see org.eclipse.jetty.webapp.WebInfConfiguration#preConfigure(org.eclipse.jetty.webapp.WebAppContext)
- */
- public void preConfigure(WebAppContext context) throws Exception
- {
- super.preConfigure(context);
- ((JettyWebAppContext)context).getDependentProjects()
- .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
-
- }
-
-
-
-
/**
* @see org.eclipse.jetty.webapp.AbstractConfiguration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
*/
@@ -197,24 +180,26 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
protected List findJars (WebAppContext context)
throws Exception
{
- List list = new ArrayList();
+ List list = new ArrayList<>();
JettyWebAppContext jwac = (JettyWebAppContext)context;
- if (jwac.getClassPathFiles() != null)
+ List files = jwac.getWebInfLib();
+ if (files != null)
{
- for (File f: jwac.getClassPathFiles())
- {
- if (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar"))
+ files.forEach( file -> {
+ if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")
+ || file.isDirectory())
{
try
{
- list.add(Resource.newResource(f.toURI()));
+ LOG.debug( " add resource to resources to examine {}", file );
+ list.add(Resource.newResource(file.toURI()));
}
catch (Exception e)
{
LOG.warn("Bad url ", e);
}
}
- }
+ } );
}
List superList = super.findJars(context);
@@ -234,25 +219,26 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
@Override
protected List findClassDirs(WebAppContext context) throws Exception
{
- List list = new ArrayList();
+ List list = new ArrayList<>();
JettyWebAppContext jwac = (JettyWebAppContext)context;
- if (jwac.getClassPathFiles() != null)
+ List files = jwac.getWebInfClasses();
+ if (files != null)
{
- for (File f: jwac.getClassPathFiles())
- {
- if (f.exists() && f.isDirectory())
+ files.forEach( file -> {
+ if (file.exists() && file.isDirectory())
{
try
{
- list.add(Resource.newResource(f.toURI()));
+ list.add(Resource.newResource(file.toURI()));
}
catch (Exception e)
{
LOG.warn("Bad url ", e);
}
}
- }
+ } );
+
}
List classesDirs = super.findClassDirs(context);