* use maven annotations for jspc mojo Signed-off-by: olivier lamy <oliver.lamy@gmail.com> * use maven annotation for jetty-maven-plugin Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
8ec1504279
commit
42d9da56c0
|
@ -27,7 +27,7 @@
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>exec-plugin-doc</id>
|
<id>exec-plugin-doc</id>
|
||||||
<phase>generate-sources</phase>
|
<phase>process-classes</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>descriptor</goal>
|
<goal>descriptor</goal>
|
||||||
<goal>helpmojo</goal>
|
<goal>helpmojo</goal>
|
||||||
|
@ -54,6 +54,11 @@
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
@ -123,6 +128,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<debug>${it.debug}</debug>
|
<debug>${it.debug}</debug>
|
||||||
<addTestClassPath>true</addTestClassPath>
|
<addTestClassPath>true</addTestClassPath>
|
||||||
|
<timeoutInSeconds>60</timeoutInSeconds>
|
||||||
<projectsDirectory>src/it</projectsDirectory>
|
<projectsDirectory>src/it</projectsDirectory>
|
||||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
<pomIncludes>
|
<pomIncludes>
|
||||||
|
|
|
@ -42,6 +42,11 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Component;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.tomcat.JarScanner;
|
import org.apache.tomcat.JarScanner;
|
||||||
import org.apache.tomcat.util.scan.StandardJarScanner;
|
import org.apache.tomcat.util.scan.StandardJarScanner;
|
||||||
|
@ -64,11 +69,9 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
* href="https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html">Usage
|
* href="https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html">Usage
|
||||||
* Guide</a> for instructions on using this plugin.
|
* Guide</a> for instructions on using this plugin.
|
||||||
* </p>
|
* </p>
|
||||||
* @goal jspc
|
* Runs jspc compiler to produce .java and .class files
|
||||||
* @phase process-classes
|
|
||||||
* @requiresDependencyResolution compile+runtime
|
|
||||||
* @description Runs jspc compiler to produce .java and .class files
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "jspc", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
|
||||||
public class JspcMojo extends AbstractMojo
|
public class JspcMojo extends AbstractMojo
|
||||||
{
|
{
|
||||||
public static final String END_OF_WEBAPP = "</web-app>";
|
public static final String END_OF_WEBAPP = "</web-app>";
|
||||||
|
@ -124,46 +127,39 @@ public class JspcMojo extends AbstractMojo
|
||||||
* Use WITH CAUTION as you may wind up with duplicate jars/classes.
|
* Use WITH CAUTION as you may wind up with duplicate jars/classes.
|
||||||
*
|
*
|
||||||
* @since jetty-7.6.3
|
* @since jetty-7.6.3
|
||||||
* @parameter default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "false")
|
||||||
private boolean useProvidedScope;
|
private boolean useProvidedScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifacts for the project.
|
* The artifacts for the project.
|
||||||
*
|
*
|
||||||
* @since jetty-7.6.3
|
* @since jetty-7.6.3
|
||||||
* @parameter default-value="${project.artifacts}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project.artifacts}", readonly = true)
|
||||||
private Set projectArtifacts;
|
private Set projectArtifacts;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maven project.
|
* The maven project.
|
||||||
*
|
|
||||||
* @parameter default-value="${project}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project}", readonly = true , required = true)
|
||||||
private MavenProject project;
|
private MavenProject project;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifacts for the plugin itself.
|
* The artifacts for the plugin itself.
|
||||||
*
|
|
||||||
* @parameter default-value="${plugin.artifacts}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${plugin.artifacts}", readonly = true)
|
||||||
private List pluginArtifacts;
|
private List pluginArtifacts;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File into which to generate the <servlet> and
|
* File into which to generate the <servlet> and
|
||||||
* <servlet-mapping> tags for the compiled jsps
|
* <servlet-mapping> tags for the compiled jsps
|
||||||
*
|
|
||||||
* @parameter default-value="${basedir}/target/webfrag.xml"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${basedir}/target/webfrag.xml")
|
||||||
private String webXmlFragment;
|
private String webXmlFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,103 +168,89 @@ public class JspcMojo extends AbstractMojo
|
||||||
* will NOT be preserved during the insertion. Can be left blank, in which
|
* will NOT be preserved during the insertion. Can be left blank, in which
|
||||||
* case the generated fragment is inserted just before the </web-app>
|
* case the generated fragment is inserted just before the </web-app>
|
||||||
* line
|
* line
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String insertionMarker;
|
private String insertionMarker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge the generated fragment file with the web.xml from
|
* Merge the generated fragment file with the web.xml from
|
||||||
* webAppSourceDirectory. The merged file will go into the same directory as
|
* webAppSourceDirectory. The merged file will go into the same directory as
|
||||||
* the webXmlFragment.
|
* the webXmlFragment.
|
||||||
*
|
|
||||||
* @parameter default-value="true"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "true")
|
||||||
private boolean mergeFragment;
|
private boolean mergeFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The destination directory into which to put the compiled jsps.
|
* The destination directory into which to put the compiled jsps.
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.outputDirectory}"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project.build.outputDirectory}")
|
||||||
private String generatedClasses;
|
private String generatedClasses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls whether or not .java files generated during compilation will be
|
* Controls whether or not .java files generated during compilation will be
|
||||||
* preserved.
|
* preserved.
|
||||||
*
|
|
||||||
* @parameter default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "false")
|
||||||
private boolean keepSources;
|
private boolean keepSources;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root directory for all html/jsp etc files
|
* Root directory for all html/jsp etc files
|
||||||
*
|
|
||||||
* @parameter default-value="${basedir}/src/main/webapp"
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${basedir}/src/main/webapp")
|
||||||
private String webAppSourceDirectory;
|
private String webAppSourceDirectory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of web.xml. Defaults to src/main/webapp/web.xml.
|
* Location of web.xml. Defaults to src/main/webapp/web.xml.
|
||||||
* @parameter default-value="${basedir}/src/main/webapp/WEB-INF/web.xml"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${basedir}/src/main/webapp/WEB-INF/web.xml")
|
||||||
private String webXml;
|
private String webXml;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The comma separated list of patterns for file extensions to be processed. By default
|
* The comma separated list of patterns for file extensions to be processed. By default
|
||||||
* will include all .jsp and .jspx files.
|
* will include all .jsp and .jspx files.
|
||||||
*
|
|
||||||
* @parameter default-value="**\/*.jsp, **\/*.jspx"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "**\\/*.jsp, **\\/*.jspx")
|
||||||
private String includes;
|
private String includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The comma separated list of file name patters to exclude from compilation.
|
* The comma separated list of file name patters to exclude from compilation.
|
||||||
*
|
|
||||||
* @parameter default_value="**\/.svn\/**";
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "**\\/.svn\\/**")
|
||||||
private String excludes;
|
private String excludes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the compiled classes for the webapp
|
* The location of the compiled classes for the webapp
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.outputDirectory}"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project.build.outputDirectory}")
|
||||||
private File classesDirectory;
|
private File classesDirectory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patterns of jars on the system path that contain tlds. Use | to separate each pattern.
|
* Patterns of jars on the system path that contain tlds. Use | to separate each pattern.
|
||||||
*
|
|
||||||
* @parameter default-value=".*taglibs[^/]*\.jar|.*jstl[^/]*\.jar$
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = ".*taglibs[^/]*\\.jar|.*jstl[^/]*\\.jar$")
|
||||||
private String tldJarNamePatterns;
|
private String tldJarNamePatterns;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Source version - if not set defaults to jsp default (currently 1.7)
|
* Source version - if not set defaults to jsp default (currently 1.7)
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String sourceVersion;
|
private String sourceVersion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target version - if not set defaults to jsp default (currently 1.7)
|
* Target version - if not set defaults to jsp default (currently 1.7)
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String targetVersion;
|
private String targetVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* The JspC instance being used to compile the jsps.
|
* The JspC instance being used to compile the jsps.
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private JettyJspC jspc;
|
private JettyJspC jspc;
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,9 +258,8 @@ public class JspcMojo extends AbstractMojo
|
||||||
* Whether dirs on the classpath should be scanned as well as jars.
|
* Whether dirs on the classpath should be scanned as well as jars.
|
||||||
* True by default. This allows for scanning for tlds of dependent projects that
|
* True by default. This allows for scanning for tlds of dependent projects that
|
||||||
* are in the reactor as unassembled jars.
|
* are in the reactor as unassembled jars.
|
||||||
*
|
|
||||||
* @parameter default-value=true
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "true")
|
||||||
private boolean scanAllDirectories;
|
private boolean scanAllDirectories;
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,13 +307,13 @@ public class JspcMojo extends AbstractMojo
|
||||||
|
|
||||||
|
|
||||||
//Make a classloader so provided jars will be on the classpath
|
//Make a classloader so provided jars will be on the classpath
|
||||||
List<URL> sysUrls = new ArrayList<URL>();
|
List<URL> sysUrls = new ArrayList<>();
|
||||||
sysUrls.addAll(providedJars);
|
sysUrls.addAll(providedJars);
|
||||||
URLClassLoader sysClassLoader = new URLClassLoader((URL[])sysUrls.toArray(new URL[0]), currentClassLoader);
|
URLClassLoader sysClassLoader = new URLClassLoader(sysUrls.toArray(new URL[0]), currentClassLoader);
|
||||||
|
|
||||||
//make a classloader with the webapp classpath
|
//make a classloader with the webapp classpath
|
||||||
URLClassLoader webAppClassLoader = new URLClassLoader((URL[]) webAppUrls.toArray(new URL[0]), sysClassLoader);
|
URLClassLoader webAppClassLoader = new URLClassLoader(webAppUrls.toArray(new URL[0]), sysClassLoader);
|
||||||
StringBuffer webAppClassPath = new StringBuffer();
|
StringBuilder webAppClassPath = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < webAppUrls.size(); i++)
|
for (int i = 0; i < webAppUrls.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +321,7 @@ public class JspcMojo extends AbstractMojo
|
||||||
getLog().debug("webappclassloader contains: " + webAppUrls.get(i));
|
getLog().debug("webappclassloader contains: " + webAppUrls.get(i));
|
||||||
webAppClassPath.append(new File(webAppUrls.get(i).toURI()).getCanonicalPath());
|
webAppClassPath.append(new File(webAppUrls.get(i).toURI()).getCanonicalPath());
|
||||||
if (getLog().isDebugEnabled())
|
if (getLog().isDebugEnabled())
|
||||||
getLog().debug("added to classpath: " + ((URL) webAppUrls.get(i)).getFile());
|
getLog().debug("added to classpath: " + (webAppUrls.get(i)).getFile());
|
||||||
if (i+1<webAppUrls.size())
|
if (i+1<webAppUrls.size())
|
||||||
webAppClassPath.append(System.getProperty("path.separator"));
|
webAppClassPath.append(System.getProperty("path.separator"));
|
||||||
}
|
}
|
||||||
|
@ -385,7 +366,6 @@ public class JspcMojo extends AbstractMojo
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader(currentClassLoader);
|
Thread.currentThread().setContextClassLoader(currentClassLoader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,13 +393,8 @@ public class JspcMojo extends AbstractMojo
|
||||||
|
|
||||||
if(generatedClassesDir.exists() && generatedClassesDir.isDirectory())
|
if(generatedClassesDir.exists() && generatedClassesDir.isDirectory())
|
||||||
{
|
{
|
||||||
delete(generatedClassesDir, new FileFilter()
|
delete(generatedClassesDir, pathname -> {
|
||||||
{
|
return pathname.isDirectory() || pathname.getName().endsWith(".java");
|
||||||
@Override
|
|
||||||
public boolean accept(File f)
|
|
||||||
{
|
|
||||||
return f.isDirectory() || f.getName().endsWith(".java");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,6 +201,7 @@
|
||||||
<debug>${it.debug}</debug>
|
<debug>${it.debug}</debug>
|
||||||
<addTestClassPath>true</addTestClassPath>
|
<addTestClassPath>true</addTestClassPath>
|
||||||
<projectsDirectory>src/it</projectsDirectory>
|
<projectsDirectory>src/it</projectsDirectory>
|
||||||
|
<timeoutInSeconds>60</timeoutInSeconds>
|
||||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
<pomIncludes>
|
<pomIncludes>
|
||||||
<pomInclude>*/pom.xml</pomInclude>
|
<pomInclude>*/pom.xml</pomInclude>
|
||||||
|
|
|
@ -37,8 +37,10 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.eclipse.jetty.security.LoginService;
|
import org.eclipse.jetty.security.LoginService;
|
||||||
import org.eclipse.jetty.server.RequestLog;
|
import org.eclipse.jetty.server.RequestLog;
|
||||||
|
@ -62,16 +64,16 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Use WITH CAUTION as you may wind up with duplicate jars/classes.
|
* Use WITH CAUTION as you may wind up with duplicate jars/classes.
|
||||||
*
|
*
|
||||||
* @since jetty-7.5.2
|
* @since jetty-7.5.2
|
||||||
* @parameter default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "false")
|
||||||
protected boolean useProvidedScope;
|
protected boolean useProvidedScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of goals that are NOT to be used
|
* List of goals that are NOT to be used
|
||||||
*
|
*
|
||||||
* @since jetty-7.5.2
|
* @since jetty-7.5.2
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected String[] excludedGoals;
|
protected String[] excludedGoals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,9 +81,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* the <jettyXml> element to specify external jetty xml config file.
|
* the <jettyXml> element to specify external jetty xml config file.
|
||||||
* Optional.
|
* Optional.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected ContextHandler[] contextHandlers;
|
protected ContextHandler[] contextHandlers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,9 +90,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* the <jettyXml> element to specify external jetty xml config file.
|
* the <jettyXml> element to specify external jetty xml config file.
|
||||||
* Optional.
|
* Optional.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected LoginService[] loginServices;
|
protected LoginService[] loginServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,9 +99,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Consider using instead the <jettyXml> element to specify external jetty xml config file.
|
* Consider using instead the <jettyXml> element to specify external jetty xml config file.
|
||||||
* Optional.
|
* Optional.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected RequestLog requestLog;
|
protected RequestLog requestLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,8 +109,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* flexible method of configuration, rather than using the (deprecated) individual
|
* flexible method of configuration, rather than using the (deprecated) individual
|
||||||
* parameters like "tmpDirectory", "contextPath" etc.
|
* parameters like "tmpDirectory", "contextPath" etc.
|
||||||
*
|
*
|
||||||
* @parameter alias="webAppConfig"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(alias = "webAppConfig")
|
||||||
protected JettyWebAppContext webApp;
|
protected JettyWebAppContext webApp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,9 +118,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* and restart the context if necessary. Ignored if reload
|
* and restart the context if necessary. Ignored if reload
|
||||||
* is enabled. Disabled by default.
|
* is enabled. Disabled by default.
|
||||||
*
|
*
|
||||||
* @parameter property="jetty.scanIntervalSeconds" default-value="0"
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property = "jetty.scanIntervalSeconds", defaultValue = "0", required = true)
|
||||||
protected int scanIntervalSeconds;
|
protected int scanIntervalSeconds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,8 +128,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* if 'manual' then the context can be reloaded by a linefeed in the console
|
* if 'manual' then the context can be reloaded by a linefeed in the console
|
||||||
* if 'automatic' then traditional reloading on changed files is enabled.
|
* if 'automatic' then traditional reloading on changed files is enabled.
|
||||||
*
|
*
|
||||||
* @parameter property="jetty.reload" default-value="automatic"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property = "jetty.reload", defaultValue = "automatic")
|
||||||
protected String reload;
|
protected String reload;
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,8 +140,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* that have been set on the command line, by the JVM, or directly
|
* that have been set on the command line, by the JVM, or directly
|
||||||
* in the POM via systemProperties. Optional.
|
* in the POM via systemProperties. Optional.
|
||||||
*
|
*
|
||||||
* @parameter property="jetty.systemPropertiesFile"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property = "jetty.systemPropertiesFile")
|
||||||
protected File systemPropertiesFile;
|
protected File systemPropertiesFile;
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,8 +151,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* that have been set on the command line or by the JVM. They WILL
|
* that have been set on the command line or by the JVM. They WILL
|
||||||
* override System properties that have been set via systemPropertiesFile.
|
* override System properties that have been set via systemPropertiesFile.
|
||||||
* Optional.
|
* Optional.
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected SystemProperties systemProperties;
|
protected SystemProperties systemProperties;
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,9 +160,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Comma separated list of a jetty xml configuration files whose contents
|
* Comma separated list of a jetty xml configuration files whose contents
|
||||||
* will be applied before any plugin configuration. Optional.
|
* will be applied before any plugin configuration. Optional.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter alias="jettyConfig"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(alias="jettyConfig")
|
||||||
protected String jettyXml;
|
protected String jettyXml;
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,8 +169,8 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort>
|
* Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort>
|
||||||
* -DSTOP.KEY=<stopKey> -jar start.jar --stop
|
* -DSTOP.KEY=<stopKey> -jar start.jar --stop
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected int stopPort;
|
protected int stopPort;
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,23 +178,22 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
|
* Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
|
||||||
* -DSTOP.PORT=<stopPort> -jar start.jar --stop
|
* -DSTOP.PORT=<stopPort> -jar start.jar --stop
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected String stopKey;
|
protected String stopKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the dump() facility of jetty to print out the server configuration to logging
|
* Use the dump() facility of jetty to print out the server configuration to logging
|
||||||
*
|
*
|
||||||
* @parameter property="dumponStart" default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter( property="dumponStart", defaultValue="false")
|
||||||
protected boolean dumpOnStart;
|
protected boolean dumpOnStart;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip this mojo execution.
|
* Skip this mojo execution.
|
||||||
*
|
|
||||||
* @parameter property="jetty.skip" default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property="jetty.skip", defaultValue="false")
|
||||||
protected boolean skip;
|
protected boolean skip;
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,59 +201,49 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* Location of a context xml configuration file whose contents
|
* Location of a context xml configuration file whose contents
|
||||||
* will be applied to the webapp AFTER anything in <webApp>.Optional.
|
* will be applied to the webapp AFTER anything in <webApp>.Optional.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter alias="webAppXml"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(alias="webAppXml")
|
||||||
protected String contextXml;
|
protected String contextXml;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maven project.
|
* The maven project.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project}", readonly = true)
|
||||||
protected MavenProject project;
|
protected MavenProject project;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifacts for the project.
|
* The artifacts for the project.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project.artifacts}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
protected Set projectArtifacts;
|
@Parameter(defaultValue="${project.artifacts}", readonly = true)
|
||||||
|
protected Set<Artifact> projectArtifacts;
|
||||||
|
|
||||||
|
|
||||||
/**
|
@Parameter(defaultValue="${mojoExecution}", readonly = true)
|
||||||
* @parameter default-value="${mojoExecution}"
|
protected MojoExecution execution;
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
protected org.apache.maven.plugin.MojoExecution execution;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifacts for the plugin itself.
|
* The artifacts for the plugin itself.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${plugin.artifacts}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
protected List pluginArtifacts;
|
@Parameter(defaultValue="${plugin.artifacts}", readonly = true)
|
||||||
|
protected List<Artifact> pluginArtifacts;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ServerConnector to use.
|
* A ServerConnector to use.
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected MavenServerConnector httpConnector;
|
protected MavenServerConnector httpConnector;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for the Server object
|
* A wrapper for the Server object
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected Server server;
|
protected Server server;
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,7 +253,6 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
protected PathWatcher scanner;
|
protected PathWatcher scanner;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A scanner to check ENTER hits on the console
|
* A scanner to check ENTER hits on the console
|
||||||
*/
|
*/
|
||||||
|
@ -286,16 +271,16 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
* If true, the server will not block the execution of subsequent code. This
|
* If true, the server will not block the execution of subsequent code. This
|
||||||
* is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.
|
* is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.
|
||||||
* </p>
|
* </p>
|
||||||
* @parameter default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "false")
|
||||||
protected boolean nonBlocking = false;
|
protected boolean nonBlocking = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per default this goal support only <code>war</code> packaging.
|
* Per default this goal support only <code>war</code> packaging.
|
||||||
* If your project use an other type please configure it here.
|
* If your project use an other type please configure it here.
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected List<String> supportedPackagings = Collections.singletonList( "war");
|
protected List<String> supportedPackagings = Collections.singletonList( "war");
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,11 +346,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<URL> provided = new ArrayList<>();
|
List<URL> provided = new ArrayList<>();
|
||||||
URL[] urls = null;
|
|
||||||
|
|
||||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
for ( Artifact artifact : projectArtifacts)
|
||||||
{
|
{
|
||||||
Artifact artifact = iter.next();
|
|
||||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
||||||
{
|
{
|
||||||
provided.add(artifact.getFile().toURI().toURL());
|
provided.add(artifact.getFile().toURI().toURL());
|
||||||
|
@ -375,8 +358,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
|
|
||||||
if (!provided.isEmpty())
|
if (!provided.isEmpty())
|
||||||
{
|
{
|
||||||
urls = new URL[provided.size()];
|
URL[] urls = provided.stream().toArray(URL[]::new);
|
||||||
provided.toArray(urls);
|
|
||||||
URLClassLoader loader = new URLClassLoader(urls, getClass().getClassLoader());
|
URLClassLoader loader = new URLClassLoader(urls, getClass().getClassLoader());
|
||||||
Thread.currentThread().setContextClassLoader(loader);
|
Thread.currentThread().setContextClassLoader(loader);
|
||||||
getLog().info("Plugin classpath augmented with <scope>provided</scope> dependencies: "+Arrays.toString(urls));
|
getLog().info("Plugin classpath augmented with <scope>provided</scope> dependencies: "+Arrays.toString(urls));
|
||||||
|
@ -394,23 +376,22 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean isPluginArtifact = false;
|
for (Artifact pluginArtifact : pluginArtifacts )
|
||||||
for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext() && !isPluginArtifact; )
|
|
||||||
{
|
{
|
||||||
Artifact pluginArtifact = iter.next();
|
|
||||||
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
||||||
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) && pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) //
|
||||||
isPluginArtifact = true;
|
&& pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isPluginArtifact;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishConfigurationBeforeStart() throws Exception
|
public void finishConfigurationBeforeStart() throws Exception
|
||||||
{
|
{
|
||||||
HandlerCollection contexts = (HandlerCollection)server.getChildHandlerByClass(ContextHandlerCollection.class);
|
HandlerCollection contexts = server.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||||
if (contexts==null)
|
if (contexts==null)
|
||||||
contexts = (HandlerCollection)server.getChildHandlerByClass(HandlerCollection.class);
|
contexts = server.getChildHandlerByClass(HandlerCollection.class);
|
||||||
|
|
||||||
for (int i=0; (this.contextHandlers != null) && (i < this.contextHandlers.length); i++)
|
for (int i=0; (this.contextHandlers != null) && (i < this.contextHandlers.length); i++)
|
||||||
{
|
{
|
||||||
|
@ -648,12 +629,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
||||||
{
|
{
|
||||||
if (systemProperties != null)
|
if (systemProperties != null)
|
||||||
{
|
{
|
||||||
Iterator itor = systemProperties.getSystemProperties().iterator();
|
systemProperties.getSystemProperties().stream().forEach( prop -> {
|
||||||
while (itor.hasNext())
|
|
||||||
{
|
|
||||||
SystemProperty prop = (SystemProperty)itor.next();
|
|
||||||
getLog().debug("Property "+prop.getName()+"="+prop.getValue()+" was "+ (prop.isSet() ? "set" : "skipped"));
|
getLog().debug("Property "+prop.getName()+"="+prop.getValue()+" was "+ (prop.isSet() ? "set" : "skipped"));
|
||||||
}
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@ package org.eclipse.jetty.maven.plugin;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -36,13 +41,11 @@ import org.apache.maven.plugin.MojoFailureException;
|
||||||
* This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested
|
* This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested
|
||||||
* HTTP client components.
|
* HTTP client components.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* Deploy a pre-assembled war
|
||||||
* @goal deploy-war
|
|
||||||
* @requiresDependencyResolution runtime
|
|
||||||
* @execute phase="validate"
|
|
||||||
* @description Deploy a pre-assembled war
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "deploy-war", requiresDependencyResolution = ResolutionScope.RUNTIME)
|
||||||
|
@Execute(phase = LifecyclePhase.VALIDATE)
|
||||||
public class JettyDeployWar extends JettyRunWarMojo
|
public class JettyDeployWar extends JettyRunWarMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -52,9 +55,8 @@ public class JettyDeployWar extends JettyRunWarMojo
|
||||||
* plugin will block further execution and you will need to use
|
* plugin will block further execution and you will need to use
|
||||||
* cntrl-c to stop it.
|
* cntrl-c to stop it.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @parameter default-value="true"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "true")
|
||||||
protected boolean daemon = true;
|
protected boolean daemon = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
@ -37,31 +42,25 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
*
|
*
|
||||||
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
||||||
*
|
*
|
||||||
* @goal effective-web-xml
|
* Runs jetty on the unassembled webapp to generate the effective web.xml
|
||||||
* @requiresDependencyResolution test
|
|
||||||
* @execute phase="test-compile"
|
|
||||||
* @description Runs jetty on the unassembled webapp to generate the effective web.xml
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "effective-web-xml", requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
|
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||||
public class JettyEffectiveWebXml extends JettyRunMojo
|
public class JettyEffectiveWebXml extends JettyRunMojo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The target directory
|
* The target directory
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.directory}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project.build.directory}", readonly = true, required = true)
|
||||||
protected File target;
|
protected File target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the file to generate into
|
* The name of the file to generate into
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected File effectiveWebXml;
|
protected File effectiveWebXml;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected boolean deleteOnExit = true;
|
protected boolean deleteOnExit = true;
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,8 +79,6 @@ public class JettyEffectiveWebXml extends JettyRunMojo
|
||||||
{
|
{
|
||||||
//Only do enough setup to be able to produce a quickstart-web.xml file
|
//Only do enough setup to be able to produce a quickstart-web.xml file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueuedThreadPool tpool = null;
|
QueuedThreadPool tpool = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -48,6 +48,12 @@ import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
import org.apache.maven.plugins.annotations.Component;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||||
import org.apache.maven.project.ProjectBuildingRequest;
|
import org.apache.maven.project.ProjectBuildingRequest;
|
||||||
import org.apache.maven.shared.artifact.DefaultArtifactCoordinate;
|
import org.apache.maven.shared.artifact.DefaultArtifactCoordinate;
|
||||||
|
@ -76,12 +82,11 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
*
|
*
|
||||||
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
||||||
*
|
*
|
||||||
* @goal run-distro
|
* Runs unassembled webapp in a locally installed jetty distro
|
||||||
* @requiresDependencyResolution test
|
|
||||||
* @execute phase="test-compile"
|
|
||||||
* @description Runs unassembled webapp in a locally installed jetty distro
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "run-distro", requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
|
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||||
public class JettyRunDistro extends JettyRunMojo
|
public class JettyRunDistro extends JettyRunMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -91,112 +96,99 @@ public class JettyRunDistro extends JettyRunMojo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This plugin
|
* This plugin
|
||||||
*
|
|
||||||
* @parameter default-value="${plugin}"
|
|
||||||
* @readonly
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${plugin}", required = true, readonly = true)
|
||||||
protected PluginDescriptor plugin;
|
protected PluginDescriptor plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target directory
|
* The target directory
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.directory}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue = "${project.build.directory}", readonly = true, required = true)
|
||||||
protected File target;
|
protected File target;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional jetty.home dir
|
* Optional jetty.home dir
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private File jettyHome;
|
private File jettyHome;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional jetty.base dir
|
* Optional jetty.base dir
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private File jettyBase;
|
private File jettyBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional list of other modules to
|
* Optional list of other modules to
|
||||||
* activate.
|
* activate.
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String[] modules;
|
private String[] modules;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arbitrary jvm args to pass to the forked process
|
* Arbitrary jvm args to pass to the forked process
|
||||||
* @parameter property="jetty.jvmArgs"
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property = "jetty.jvmArgs")
|
||||||
private String jvmArgs;
|
private String jvmArgs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra environment variables to be passed to the forked process
|
* Extra environment variables to be passed to the forked process
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
private Map<String,String> env = new HashMap<String,String>();
|
@Parameter
|
||||||
|
private Map<String,String> env = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional list of jetty properties to put on the command line
|
* Optional list of jetty properties to put on the command line
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String[] jettyProperties;
|
private String[] jettyProperties;
|
||||||
|
|
||||||
/**
|
@Parameter(defaultValue = "${session}", required = true, readonly = true)
|
||||||
* @parameter default-value="${session}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
private MavenSession session;
|
private MavenSession session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project's remote repositories to use for the resolution.
|
* The project's remote repositories to use for the resolution.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project.remoteArtifactRepositories}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.remoteArtifactRepositories}", required = true, readonly = true)
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
/**
|
@Component
|
||||||
* @component
|
|
||||||
*/
|
|
||||||
private ArtifactResolver artifactResolver;
|
private ArtifactResolver artifactResolver;
|
||||||
|
|
||||||
|
|
||||||
/**
|
@Parameter( defaultValue="${plugin.version}", readonly = true)
|
||||||
* @parameter default-value="${plugin.version}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
private String pluginVersion;
|
private String pluginVersion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to wait for the child to finish or not.
|
* Whether to wait for the child to finish or not.
|
||||||
* @parameter default-value="true"
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="true")
|
||||||
private boolean waitForChild;
|
private boolean waitForChild;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max number of times to try checking if the
|
* Max number of times to try checking if the
|
||||||
* child has started successfully.
|
* child has started successfully.
|
||||||
*
|
*
|
||||||
* @parameter default-value="10"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="10")
|
||||||
private int maxChildChecks;
|
private int maxChildChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Millisecs to wait between each
|
* Millisecs to wait between each
|
||||||
* check to see if the child started successfully.
|
* check to see if the child started successfully.
|
||||||
*
|
|
||||||
* @parameter default-value="100"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="100")
|
||||||
private long maxChildCheckInterval;
|
private long maxChildCheckInterval;
|
||||||
|
|
||||||
private File targetBase;
|
private File targetBase;
|
||||||
|
|
|
@ -37,6 +37,11 @@ import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
@ -59,62 +64,49 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
* <p>
|
* <p>
|
||||||
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
||||||
*
|
*
|
||||||
* @goal run-forked
|
* Runs Jetty in forked JVM on an unassembled webapp
|
||||||
* @requiresDependencyResolution test
|
|
||||||
* @execute phase="test-compile"
|
|
||||||
* @description Runs Jetty in forked JVM on an unassembled webapp
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "run-forked", requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
|
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||||
public class JettyRunForkedMojo extends JettyRunMojo
|
public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The target directory
|
* The target directory
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.directory}"
|
|
||||||
* @required
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.directory}", readonly = true, required = true)
|
||||||
protected File target;
|
protected File target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file into which to generate the quickstart web xml for the forked process to use
|
* The file into which to generate the quickstart web xml for the forked process to use
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project.build.directory}/fork-web.xml"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.directory}/fork-web.xml")
|
||||||
protected File forkWebXml;
|
protected File forkWebXml;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arbitrary jvm args to pass to the forked process
|
* Arbitrary jvm args to pass to the forked process
|
||||||
* @parameter property="jetty.jvmArgs"
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter(property="jetty.jvmArgs")
|
||||||
private String jvmArgs;
|
private String jvmArgs;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional list of jetty properties to put on the command line
|
* Optional list of jetty properties to put on the command line
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
private String[] jettyProperties;
|
private String[] jettyProperties;
|
||||||
|
|
||||||
|
@Parameter(defaultValue="${plugin.artifacts}",readonly = true)
|
||||||
|
private List<Artifact> pluginArtifacts;
|
||||||
|
|
||||||
/**
|
@Parameter(defaultValue="${plugin}", readonly = true)
|
||||||
* @parameter default-value="${plugin.artifacts}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
private List pluginArtifacts;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @parameter default-value="${plugin}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
private PluginDescriptor plugin;
|
private PluginDescriptor plugin;
|
||||||
|
|
||||||
|
@Parameter(defaultValue="true")
|
||||||
/**
|
|
||||||
* @parameter default-value="true"
|
|
||||||
*/
|
|
||||||
private boolean waitForChild;
|
private boolean waitForChild;
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,24 +114,23 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
* Max number of times to try checking if the
|
* Max number of times to try checking if the
|
||||||
* child has started successfully.
|
* child has started successfully.
|
||||||
*
|
*
|
||||||
* @parameter alias="maxStartupLines" default-value="50"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(alias="maxStartupLines", defaultValue="50")
|
||||||
private int maxChildChecks;
|
private int maxChildChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Millisecs to wait between each
|
* Millisecs to wait between each
|
||||||
* check to see if the child started successfully.
|
* check to see if the child started successfully.
|
||||||
*
|
|
||||||
* @parameter default-value="100"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="100")
|
||||||
private long maxChildCheckInterval;
|
private long maxChildCheckInterval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra environment variables to be passed to the forked process
|
* Extra environment variables to be passed to the forked process
|
||||||
*
|
*
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
private Map<String,String> env = new HashMap<String,String>();
|
@Parameter
|
||||||
|
private Map<String,String> env = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The forked jetty instance
|
* The forked jetty instance
|
||||||
|
@ -279,7 +270,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
if (tpool != null)
|
if (tpool != null)
|
||||||
tpool.stop();
|
tpool.stop();
|
||||||
|
|
||||||
List<String> cmd = new ArrayList<String>();
|
List<String> cmd = new ArrayList<>();
|
||||||
cmd.add(getJavaBin());
|
cmd.add(getJavaBin());
|
||||||
|
|
||||||
if (jvmArgs != null)
|
if (jvmArgs != null)
|
||||||
|
@ -398,10 +389,9 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
if (useProvidedScope)
|
if (useProvidedScope)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<String> provided = new ArrayList<String>();
|
List<String> provided = new ArrayList<>();
|
||||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
for ( Artifact artifact : project.getArtifacts())
|
||||||
{
|
{
|
||||||
Artifact artifact = iter.next();
|
|
||||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
||||||
{
|
{
|
||||||
provided.add(artifact.getFile().getAbsolutePath());
|
provided.add(artifact.getFile().getAbsolutePath());
|
||||||
|
@ -438,22 +428,20 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean isPluginArtifact = false;
|
for (Artifact pluginArtifact : pluginArtifacts)
|
||||||
for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext() && !isPluginArtifact; )
|
|
||||||
{
|
{
|
||||||
Artifact pluginArtifact = iter.next();
|
|
||||||
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
||||||
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) && pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) && pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
||||||
isPluginArtifact = true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isPluginArtifact;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Artifact> getExtraJars()
|
private Set<Artifact> getExtraJars()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
Set<Artifact> extraJars = new HashSet<Artifact>();
|
Set<Artifact> extraJars = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
List l = pluginArtifacts;
|
List l = pluginArtifacts;
|
||||||
|
@ -461,6 +449,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
|
|
||||||
if (l != null)
|
if (l != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
Iterator itor = l.iterator();
|
Iterator itor = l.iterator();
|
||||||
while (itor.hasNext() && pluginArtifact == null)
|
while (itor.hasNext() && pluginArtifact == null)
|
||||||
{
|
{
|
||||||
|
@ -478,9 +467,8 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
||||||
public String getContainerClassPath() throws Exception
|
public String getContainerClassPath() throws Exception
|
||||||
{
|
{
|
||||||
StringBuilder classPath = new StringBuilder();
|
StringBuilder classPath = new StringBuilder();
|
||||||
for (Object obj : pluginArtifacts)
|
for (Artifact artifact : pluginArtifacts)
|
||||||
{
|
{
|
||||||
Artifact artifact = (Artifact) obj;
|
|
||||||
if ("jar".equals(artifact.getType()))
|
if ("jar".equals(artifact.getType()))
|
||||||
{
|
{
|
||||||
//ignore slf4j from inside maven
|
//ignore slf4j from inside maven
|
||||||
|
|
|
@ -34,7 +34,11 @@ import java.util.Set;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.eclipse.jetty.util.PathWatcher;
|
import org.eclipse.jetty.util.PathWatcher;
|
||||||
|
@ -61,11 +65,10 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
* <p>
|
* <p>
|
||||||
* There is a <a href="http://www.eclipse.org/jetty/documentation/current/maven-and-jetty.html">reference guide</a> to the configuration parameters for this plugin.
|
* There is a <a href="http://www.eclipse.org/jetty/documentation/current/maven-and-jetty.html">reference guide</a> to the configuration parameters for this plugin.
|
||||||
*
|
*
|
||||||
* @goal run
|
* Runs jetty directly from a maven project
|
||||||
* @requiresDependencyResolution test
|
|
||||||
* @execute phase="test-compile"
|
|
||||||
* @description Runs jetty directly from a maven project
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "run", requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
|
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||||
public class JettyRunMojo extends AbstractJettyMojo
|
public class JettyRunMojo extends AbstractJettyMojo
|
||||||
{
|
{
|
||||||
public static final String DEFAULT_WEBAPP_SRC = "src"+File.separator+"main"+File.separator+"webapp";
|
public static final String DEFAULT_WEBAPP_SRC = "src"+File.separator+"main"+File.separator+"webapp";
|
||||||
|
@ -78,8 +81,8 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
* and the dependencies of <scope>test<scope>
|
* and the dependencies of <scope>test<scope>
|
||||||
* will be put first on the runtime classpath.
|
* will be put first on the runtime classpath.
|
||||||
*
|
*
|
||||||
* @parameter alias="useTestClasspath" default-value="false"
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(alias="useTestClasspath", defaultValue="false")
|
||||||
protected boolean useTestScope;
|
protected boolean useTestScope;
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,59 +90,51 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
* The default location of the web.xml file. Will be used
|
* The default location of the web.xml file. Will be used
|
||||||
* if <webApp><descriptor> is not set.
|
* if <webApp><descriptor> is not set.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${maven.war.webxml}"
|
|
||||||
* @readonly
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${maven.war.webxml}", readonly = true)
|
||||||
protected String webXml;
|
protected String webXml;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory containing generated classes.
|
* The directory containing generated classes.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project.build.outputDirectory}"
|
|
||||||
* @required
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.outputDirectory}", required = true)
|
||||||
protected File classesDirectory;
|
protected File classesDirectory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional pattern for includes/excludes of classes in the classesDirectory
|
* An optional pattern for includes/excludes of classes in the classesDirectory
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected ScanPattern scanClassesPattern;
|
protected ScanPattern scanClassesPattern;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory containing generated test classes.
|
* The directory containing generated test classes.
|
||||||
*
|
*
|
||||||
* @parameter default-value="${project.build.testOutputDirectory}"
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.testOutputDirectory}", required = true)
|
||||||
protected File testClassesDirectory;
|
protected File testClassesDirectory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional pattern for includes/excludes of classes in the testClassesDirectory
|
* An optional pattern for includes/excludes of classes in the testClassesDirectory
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected ScanPattern scanTestClassesPattern;
|
protected ScanPattern scanTestClassesPattern;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root directory for all html/jsp etc files
|
* Root directory for all html/jsp etc files
|
||||||
*
|
*
|
||||||
* @parameter default-value="${maven.war.src}"
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${maven.war.src}")
|
||||||
protected File webAppSourceDirectory;
|
protected File webAppSourceDirectory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of files or directories to additionally periodically scan for changes. Optional.
|
* List of files or directories to additionally periodically scan for changes. Optional.
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected File[] scanTargets;
|
protected File[] scanTargets;
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,8 +142,9 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
* List of directories with ant-style <include> and <exclude> patterns
|
* List of directories with ant-style <include> and <exclude> patterns
|
||||||
* for extra targets to periodically scan for changes. Can be used instead of,
|
* for extra targets to periodically scan for changes. Can be used instead of,
|
||||||
* or in conjunction with <scanTargets>.Optional.
|
* or in conjunction with <scanTargets>.Optional.
|
||||||
* @parameter
|
*
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected ScanTargetPattern[] scanTargetPatterns;
|
protected ScanTargetPattern[] scanTargetPatterns;
|
||||||
|
|
||||||
|
|
||||||
|
@ -337,19 +333,6 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
getLog().info("Webapp directory = " + webAppSourceDirectory.getCanonicalPath());
|
getLog().info("Webapp directory = " + webAppSourceDirectory.getCanonicalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File toFile(Resource resource)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return resource.getFile();
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new RuntimeException( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jetty.maven.plugin.AbstractJettyMojo#configureScanner()
|
* @see org.eclipse.jetty.maven.plugin.AbstractJettyMojo#configureScanner()
|
||||||
*/
|
*/
|
||||||
|
@ -549,10 +532,8 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
private List<File> getDependencyFiles()
|
private List<File> getDependencyFiles()
|
||||||
{
|
{
|
||||||
List<File> dependencyFiles = new ArrayList<>();
|
List<File> dependencyFiles = new ArrayList<>();
|
||||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
for ( Artifact artifact : projectArtifacts)
|
||||||
{
|
{
|
||||||
Artifact artifact = iter.next();
|
|
||||||
|
|
||||||
// Include runtime and compile time libraries, and possibly test libs too
|
// Include runtime and compile time libraries, and possibly test libs too
|
||||||
if(artifact.getType().equals("war"))
|
if(artifact.getType().equals("war"))
|
||||||
{
|
{
|
||||||
|
@ -604,8 +585,8 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
//get copy of a list of war artifacts
|
//get copy of a list of war artifacts
|
||||||
Set<Artifact> matchedWarArtifacts = new HashSet<Artifact>();
|
Set<Artifact> matchedWarArtifacts = new HashSet<>();
|
||||||
List<Overlay> overlays = new ArrayList<Overlay>();
|
List<Overlay> overlays = new ArrayList<>();
|
||||||
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
||||||
{
|
{
|
||||||
//overlays can be individually skipped
|
//overlays can be individually skipped
|
||||||
|
@ -652,7 +633,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
if (overlays == null || overlays.isEmpty())
|
if (overlays == null || overlays.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<Resource> resourceBaseCollection = new ArrayList<Resource>();
|
List<Resource> resourceBaseCollection = new ArrayList<>();
|
||||||
|
|
||||||
for (Overlay o:overlays)
|
for (Overlay o:overlays)
|
||||||
{
|
{
|
||||||
|
@ -729,9 +710,8 @@ public class JettyRunMojo extends AbstractJettyMojo
|
||||||
return warArtifacts;
|
return warArtifacts;
|
||||||
|
|
||||||
warArtifacts = new ArrayList<>();
|
warArtifacts = new ArrayList<>();
|
||||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
for ( Artifact artifact : projectArtifacts)
|
||||||
{
|
{
|
||||||
Artifact artifact = iter.next();
|
|
||||||
if (artifact.getType().equals("war") || artifact.getType().equals("zip"))
|
if (artifact.getType().equals("war") || artifact.getType().equals("zip"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -24,6 +24,11 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.eclipse.jetty.util.PathWatcher;
|
import org.eclipse.jetty.util.PathWatcher;
|
||||||
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
||||||
|
|
||||||
|
@ -40,22 +45,16 @@ import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
||||||
* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration.
|
* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration.
|
||||||
* This can be used, for example, to deploy a static webapp that is not part of your maven build.
|
* This can be used, for example, to deploy a static webapp that is not part of your maven build.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*@goal run-exploded
|
|
||||||
*@requiresDependencyResolution compile+runtime
|
|
||||||
*@execute phase=package
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "run-exploded", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
|
||||||
|
@Execute(phase = LifecyclePhase.PACKAGE)
|
||||||
public class JettyRunWarExplodedMojo extends AbstractJettyMojo
|
public class JettyRunWarExplodedMojo extends AbstractJettyMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the war file.
|
* The location of the war file.
|
||||||
*
|
|
||||||
* @parameter default-value="${project.build.directory}/${project.build.finalName}"
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.directory}/${project.build.finalName}", required = true)
|
||||||
private File war;
|
private File war;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,11 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.eclipse.jetty.util.PathWatcher;
|
import org.eclipse.jetty.util.PathWatcher;
|
||||||
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
||||||
|
|
||||||
|
@ -39,21 +44,18 @@ import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
|
||||||
* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration.
|
* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration.
|
||||||
* This can be used, for example, to deploy a static webapp that is not part of your maven build.
|
* This can be used, for example, to deploy a static webapp that is not part of your maven build.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* Runs jetty on a war file
|
||||||
* @goal run-war
|
|
||||||
* @requiresDependencyResolution compile+runtime
|
|
||||||
* @execute phase="package"
|
|
||||||
* @description Runs jetty on a war file
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "run-war", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
|
||||||
|
@Execute(phase = LifecyclePhase.PACKAGE)
|
||||||
public class JettyRunWarMojo extends AbstractJettyMojo
|
public class JettyRunWarMojo extends AbstractJettyMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the war file.
|
* The location of the war file.
|
||||||
* @parameter default-value="${project.build.directory}/${project.build.finalName}.war"
|
*
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(defaultValue="${project.build.directory}/${project.build.finalName}.war", required = true)
|
||||||
private File war;
|
private File war;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,10 @@ package org.eclipse.jetty.maven.plugin;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Execute;
|
||||||
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,11 +37,10 @@ import org.apache.maven.plugin.MojoFailureException;
|
||||||
* the webapp already exist.
|
* the webapp already exist.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @goal start
|
* Runs jetty directly from a maven project from a binding to an execution in your pom
|
||||||
* @requiresDependencyResolution test
|
|
||||||
* @execute phase="validate"
|
|
||||||
* @description Runs jetty directly from a maven project from a binding to an execution in your pom
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "start", requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
|
@Execute(phase = LifecyclePhase.VALIDATE)
|
||||||
public class JettyStartMojo extends JettyRunMojo
|
public class JettyStartMojo extends JettyRunMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ import java.net.Socket;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This goal stops a running instance of jetty.
|
* This goal stops a running instance of jetty.
|
||||||
|
@ -35,32 +37,29 @@ import org.apache.maven.plugin.MojoFailureException;
|
||||||
* The <b>stopPort</b> and <b>stopKey</b> parameters can be used to
|
* The <b>stopPort</b> and <b>stopKey</b> parameters can be used to
|
||||||
* configure which jetty to stop.
|
* configure which jetty to stop.
|
||||||
*
|
*
|
||||||
* @goal stop
|
* Stops jetty that is configured with <stopKey> and <stopPort>.
|
||||||
* @description Stops jetty that is configured with <stopKey> and <stopPort>.
|
|
||||||
*/
|
*/
|
||||||
|
@Mojo( name = "stop")
|
||||||
public class JettyStopMojo extends AbstractMojo
|
public class JettyStopMojo extends AbstractMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Port to listen to stop jetty on sending stop command
|
* Port to listen to stop jetty on sending stop command
|
||||||
* @parameter
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(required = true)
|
||||||
protected int stopPort;
|
protected int stopPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
|
* Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
|
||||||
* -DSTOP.PORT=<stopPort> -jar start.jar --stop
|
* -DSTOP.PORT=<stopPort> -jar start.jar --stop
|
||||||
* @parameter
|
|
||||||
* @required
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter(required = true)
|
||||||
protected String stopKey;
|
protected String stopKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max time in seconds that the plugin will wait for confirmation that jetty has stopped.
|
* Max time in seconds that the plugin will wait for confirmation that jetty has stopped.
|
||||||
* @parameter
|
|
||||||
*/
|
*/
|
||||||
|
@Parameter
|
||||||
protected int stopWait;
|
protected int stopWait;
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,9 +77,9 @@ public class JettyStopMojo extends AbstractMojo
|
||||||
//also stops depends whether or not it was started with ShutdownMonitor.exitVm=true
|
//also stops depends whether or not it was started with ShutdownMonitor.exitVm=true
|
||||||
String command = "forcestop";
|
String command = "forcestop";
|
||||||
|
|
||||||
try
|
try(Socket s=new Socket(InetAddress.getByName("127.0.0.1"),stopPort);)
|
||||||
{
|
{
|
||||||
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),stopPort);
|
|
||||||
s.setSoLinger(false, 0);
|
s.setSoLinger(false, 0);
|
||||||
|
|
||||||
OutputStream out=s.getOutputStream();
|
OutputStream out=s.getOutputStream();
|
||||||
|
@ -105,7 +104,6 @@ public class JettyStopMojo extends AbstractMojo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.close();
|
|
||||||
}
|
}
|
||||||
catch (ConnectException e)
|
catch (ConnectException e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -563,7 +563,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
|
|
||||||
if (path != null)
|
if (path != null)
|
||||||
{
|
{
|
||||||
TreeSet<String> allPaths = new TreeSet<String>();
|
TreeSet<String> allPaths = new TreeSet<>();
|
||||||
allPaths.addAll(paths);
|
allPaths.addAll(paths);
|
||||||
|
|
||||||
//add in the dependency jars as a virtual WEB-INF/lib entry
|
//add in the dependency jars as a virtual WEB-INF/lib entry
|
||||||
|
|
|
@ -68,9 +68,8 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration
|
||||||
if (jwac.getClassPathFiles() != null)
|
if (jwac.getClassPathFiles() != null)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Setting up classpath ...");
|
if (LOG.isDebugEnabled()) LOG.debug("Setting up classpath ...");
|
||||||
Iterator itor = jwac.getClassPathFiles().iterator();
|
for(File classPathFile:jwac.getClassPathFiles())
|
||||||
while (itor.hasNext())
|
((WebAppClassLoader)context.getClassLoader()).addClassPath(classPathFile.getCanonicalPath());
|
||||||
((WebAppClassLoader)context.getClassLoader()).addClassPath(((File)itor.next()).getCanonicalPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set up the quickstart environment for the context
|
//Set up the quickstart environment for the context
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class Overlay
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer strbuff = new StringBuffer();
|
StringBuilder strbuff = new StringBuilder();
|
||||||
if (_resource != null)
|
if (_resource != null)
|
||||||
strbuff.append(_resource);
|
strbuff.append(_resource);
|
||||||
if (_config != null)
|
if (_config != null)
|
||||||
|
|
|
@ -143,13 +143,13 @@ public class OverlayConfig
|
||||||
for (int j=0; list != null && j < list.length;j++)
|
for (int j=0; list != null && j < list.length;j++)
|
||||||
{
|
{
|
||||||
if (includes == null)
|
if (includes == null)
|
||||||
includes = new ArrayList<String>();
|
includes = new ArrayList<>();
|
||||||
includes.add(list[j].getValue());
|
includes.add(list[j].getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includes == null && defaultIncludes != null)
|
if (includes == null && defaultIncludes != null)
|
||||||
{
|
{
|
||||||
includes = new ArrayList<String>();
|
includes = new ArrayList<>();
|
||||||
includes.addAll(defaultIncludes);
|
includes.addAll(defaultIncludes);
|
||||||
}
|
}
|
||||||
setIncludes(includes);
|
setIncludes(includes);
|
||||||
|
@ -163,13 +163,13 @@ public class OverlayConfig
|
||||||
for (int j=0; list != null && j < list.length;j++)
|
for (int j=0; list != null && j < list.length;j++)
|
||||||
{
|
{
|
||||||
if (excludes == null)
|
if (excludes == null)
|
||||||
excludes = new ArrayList<String>();
|
excludes = new ArrayList<>();
|
||||||
excludes.add(list[j].getValue());
|
excludes.add(list[j].getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (excludes == null && defaultExcludes != null)
|
if (excludes == null && defaultExcludes != null)
|
||||||
{
|
{
|
||||||
excludes = new ArrayList<String>();
|
excludes = new ArrayList<>();
|
||||||
excludes.addAll(defaultExcludes);
|
excludes.addAll(defaultExcludes);
|
||||||
}
|
}
|
||||||
setExcludes(excludes);
|
setExcludes(excludes);
|
||||||
|
@ -300,7 +300,7 @@ public class OverlayConfig
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer strbuff = new StringBuffer();
|
StringBuilder strbuff = new StringBuilder();
|
||||||
strbuff.append((groupId != null ? groupId : "")+",");
|
strbuff.append((groupId != null ? groupId : "")+",");
|
||||||
strbuff.append((artifactId != null ? artifactId : "")+",");
|
strbuff.append((artifactId != null ? artifactId : "")+",");
|
||||||
strbuff.append((classifier != null ? classifier : "")+",");
|
strbuff.append((classifier != null ? classifier : "")+",");
|
||||||
|
|
Loading…
Reference in New Issue