fix run forked support of reactor projects
Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
parent
1e7e356865
commit
d72718b67f
|
@ -15,6 +15,7 @@
|
|||
<bundle-symbolic-name>${project.groupId}.maven.plugin</bundle-symbolic-name>
|
||||
<it.debug>false</it.debug>
|
||||
<jetty.stopKey>FOOBEER</jetty.stopKey>
|
||||
<jetty.jvmArgs></jetty.jvmArgs>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -193,7 +194,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
|
@ -212,14 +213,12 @@
|
|||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<preBuildHookScript>setup</preBuildHookScript>
|
||||
<postBuildHookScript>verify</postBuildHookScript>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<jetty.stopKey>${jetty.stopKey}</jetty.stopKey>
|
||||
<jetty.stopPort>${jetty.stopPort}</jetty.stopPort>
|
||||
<jetty.runPort>${jetty.runPort}</jetty.runPort>
|
||||
<jettyStopKey>${jetty.stopKey}</jettyStopKey>
|
||||
<jettyStopPort>${jetty.stopPort}</jettyStopPort>
|
||||
<jettyRunPort>${jetty.runPort}</jettyRunPort>
|
||||
</scriptVariables>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
<properties>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -89,8 +90,10 @@
|
|||
<nonBlocking>true</nonBlocking>
|
||||
<waitForChild>false</waitForChild>
|
||||
<jettyXml>${project.build.directory}/config/jetty.xml</jettyXml>
|
||||
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--
|
||||
<execution>
|
||||
<id>stop-jetty</id>
|
||||
<phase>test</phase>
|
||||
|
@ -98,6 +101,7 @@
|
|||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
-->
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),Integer.getInteger( "jetty.runPort" ));
|
||||
s.setSoLinger(false, 0);
|
||||
|
||||
OutputStream out=s.getOutputStream();
|
||||
out.write((System.getProperty( "jetty.stopKey" )+"\r\n"+command+"\r\n").getBytes());
|
||||
out.flush();
|
||||
s.close()
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
|
||||
System.out.println( "running postbuild.groovy port " + jettyStopPort + ", key:" + jettyStopKey )
|
||||
|
||||
int port = Integer.parseInt( jettyStopPort )
|
||||
|
||||
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),port )
|
||||
s.setSoLinger(false, 0)
|
||||
|
||||
OutputStream out=s.getOutputStream()
|
||||
out.write(( jettyStopKey +"\r\nforcestop\r\n").getBytes())
|
||||
out.flush()
|
||||
s.close()
|
|
@ -18,6 +18,17 @@
|
|||
|
||||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -40,18 +51,6 @@ import java.util.Properties;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
|
||||
/**
|
||||
* This goal is used to deploy your unassembled webapp into a forked JVM.
|
||||
|
@ -172,15 +171,14 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
/**
|
||||
* we o
|
||||
*/
|
||||
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
// protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
// {
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* ConsoleStreamer
|
||||
|
@ -519,6 +517,19 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
props.put("testClasses.dir", webApp.getTestClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
if ( !webApp.getClassPathFiles().isEmpty() )
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for ( File dependency : webApp.getClassPathFiles() )
|
||||
{
|
||||
if (dependency.isDirectory())
|
||||
{
|
||||
stringBuilder.append( dependency.getCanonicalPath() ).append( '|' );
|
||||
}
|
||||
}
|
||||
props.put( "projects.classes.dir", stringBuilder.toString() );
|
||||
}
|
||||
|
||||
//web-inf lib
|
||||
List<File> deps = webApp.getWebInfLib();
|
||||
StringBuffer strbuff = new StringBuffer();
|
||||
|
@ -587,7 +598,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
List<Artifact> warArtifacts = new ArrayList<Artifact>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
Artifact artifact = iter.next();
|
||||
|
||||
if (artifact.getType().equals("war"))
|
||||
warArtifacts.add(artifact);
|
||||
|
|
|
@ -164,7 +164,7 @@ public class ServerSupport
|
|||
if (server == null)
|
||||
return null;
|
||||
|
||||
return (ContextHandlerCollection)server.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||
return server.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -30,6 +32,8 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -174,31 +178,31 @@ public class Starter
|
|||
|
||||
//apply a properties file that defines the things that we configure in the jetty:run plugin:
|
||||
// - the context path
|
||||
String str = (String)props.get("context.path");
|
||||
String str = props.getProperty("context.path");
|
||||
if (str != null)
|
||||
webApp.setContextPath(str);
|
||||
|
||||
|
||||
// - web.xml
|
||||
str = (String)props.get("web.xml");
|
||||
str = props.getProperty("web.xml");
|
||||
if (str != null)
|
||||
webApp.setDescriptor(str);
|
||||
|
||||
str = (String)props.get("quickstart.web.xml");
|
||||
str = props.getProperty("quickstart.web.xml");
|
||||
if (str != null)
|
||||
webApp.setQuickStartWebDescriptor(Resource.newResource(new File(str)));
|
||||
|
||||
// - the tmp directory
|
||||
str = (String)props.getProperty("tmp.dir");
|
||||
str = props.getProperty("tmp.dir");
|
||||
if (str != null)
|
||||
webApp.setTempDirectory(new File(str.trim()));
|
||||
|
||||
str = (String)props.getProperty("tmp.dir.persist");
|
||||
str = props.getProperty("tmp.dir.persist");
|
||||
if (str != null)
|
||||
webApp.setPersistTempDirectory(Boolean.valueOf(str));
|
||||
|
||||
//Get the calculated base dirs which includes the overlays
|
||||
str = (String)props.getProperty("base.dirs");
|
||||
str = props.getProperty("base.dirs");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
|
||||
|
@ -207,7 +211,7 @@ public class Starter
|
|||
}
|
||||
|
||||
//Get the original base dirs without the overlays
|
||||
str = (String)props.get("base.dirs.orig");
|
||||
str = props.getProperty("base.dirs.orig");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
|
||||
|
@ -215,9 +219,9 @@ public class Starter
|
|||
}
|
||||
|
||||
//For overlays
|
||||
str = (String)props.getProperty("maven.war.includes");
|
||||
str = props.getProperty("maven.war.includes");
|
||||
List<String> defaultWarIncludes = fromCSV(str);
|
||||
str = (String)props.getProperty("maven.war.excludes");
|
||||
str = props.getProperty("maven.war.excludes");
|
||||
List<String> defaultWarExcludes = fromCSV(str);
|
||||
|
||||
//List of war artifacts
|
||||
|
@ -288,19 +292,18 @@ public class Starter
|
|||
|
||||
|
||||
// - the equivalent of web-inf classes
|
||||
str = (String)props.getProperty("classes.dir");
|
||||
str = props.getProperty("classes.dir");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
webApp.setClasses(new File(str));
|
||||
}
|
||||
|
||||
str = (String)props.getProperty("testClasses.dir");
|
||||
str = props.getProperty("testClasses.dir");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
webApp.setTestClasses(new File(str));
|
||||
}
|
||||
|
||||
|
||||
// - the equivalent of web-inf lib
|
||||
str = props.getProperty("lib.jars");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
|
@ -311,6 +314,15 @@ public class Starter
|
|||
jars.add(new File(names[j].trim()));
|
||||
webApp.setWebInfLib(jars);
|
||||
}
|
||||
|
||||
str = props.getProperty( "projects.classes.dir" );
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
List<File> classesDirectories = //
|
||||
Arrays.stream(str.split( Pattern.quote("|") )) //
|
||||
.map( s -> Paths.get( s).toFile() ).collect( Collectors.toList() );
|
||||
webApp.getWebInfLib().addAll( classesDirectories );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue