Merge pull request #2497 from eclipse/jetty-9.4.x-issue-2496-skip-unsupported-packaging

Issue #2496 - Improve plugin execution skip language
This commit is contained in:
Joakim Erdfelt 2018-05-03 07:26:39 -05:00 committed by GitHub
commit c152713311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 50 deletions

View File

@ -30,7 +30,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@ -42,6 +41,7 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.jetty.security.LoginService;
import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.Server;
@ -287,18 +287,31 @@ public abstract class AbstractJettyMojo extends AbstractMojo
public abstract void restartWebApp(boolean reconfigureScanner) throws Exception;
public abstract void checkPomConfiguration() throws MojoExecutionException;
public boolean checkPomConfiguration() throws MojoExecutionException
{
return true;
}
public abstract void configureScanner () throws MojoExecutionException;
protected String getSkipMessage(String reason)
{
String projectName = project.getName();
if (StringUtils.isBlank(projectName))
{
projectName = project.getGroupId() + ":" + project.getArtifactId();
}
return "Skipping " + projectName + " : " + reason;
}
public void checkPackagingConfiguration() throws MojoExecutionException
public boolean checkPackagingConfiguration()
{
if (!supportedPackagings.contains( project.getPackaging() ))
{
getLog().info( "Your project packaging is not supported by this plugin" );
return;
getLog().info(getSkipMessage("packaging type [" + project.getPackaging() + "] is unsupported"));
return false;
}
return true;
}
@ -308,30 +321,32 @@ public abstract class AbstractJettyMojo extends AbstractMojo
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
getLog().info("Configuring Jetty for project: " + this.project.getName());
if (skip)
if (isConfigurationSupported())
{
getLog().info("Skipping Jetty start: jetty.skip==true");
return;
}
if (skip)
{
getLog().info(getSkipMessage("jetty.skip==true"));
return;
}
if (isExcluded(execution.getMojoDescriptor().getGoal()))
{
getLog().info("The goal \""+execution.getMojoDescriptor().getFullGoalName()+
"\" has been made unavailable for this web application by an <excludedGoal> configuration.");
return;
getLog().info("Configuring Jetty for project: " + this.project.getName());
if (isExcluded(execution.getMojoDescriptor().getGoal()))
{
getLog().info("The goal \""+execution.getMojoDescriptor().getFullGoalName()+
"\" has been made unavailable for this web application by an <excludedGoal> configuration.");
return;
}
configurePluginClasspath();
PluginLog.setLog(getLog());
startJetty();
}
configurePluginClasspath();
PluginLog.setLog(getLog());
checkConfiguration();
startJetty();
}
public void checkConfiguration() throws MojoExecutionException
public boolean isConfigurationSupported() throws MojoExecutionException
{
checkPackagingConfiguration();
checkPomConfiguration();
return (checkPackagingConfiguration() && checkPomConfiguration());
}

View File

@ -24,10 +24,8 @@ import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -181,7 +179,7 @@ public class JettyRunMojo extends AbstractJettyMojo
* @see AbstractJettyMojo#checkPomConfiguration()
*/
@Override
public void checkPomConfiguration () throws MojoExecutionException
public boolean checkPomConfiguration () throws MojoExecutionException
{
// check the location of the static content/jsps etc
try
@ -238,6 +236,8 @@ public class JettyRunMojo extends AbstractJettyMojo
{
throw new MojoExecutionException("Location of classesDirectory does not exist");
}
return true;
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.maven.plugin;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
@ -75,19 +74,7 @@ public class JettyRunWarExplodedMojo extends AbstractJettyMojo
super.finishConfigurationBeforeStart();
}
/**
*
* @see AbstractJettyMojo#checkPomConfiguration()
*/
@Override
public void checkPomConfiguration() throws MojoExecutionException
{
return;
}
/**
* @see AbstractJettyMojo#configureScanner()
*/

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.maven.plugin;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
@ -87,16 +86,6 @@ public class JettyRunWarMojo extends AbstractJettyMojo
/**
* @see AbstractJettyMojo#checkPomConfiguration()
*/
@Override
public void checkPomConfiguration() throws MojoExecutionException
{
return;
}
/**
* @see AbstractJettyMojo#configureScanner()
*/