PR: MNG-629

preparing for executing the lifecycle by passing reports into the site plugin, rather than extracting them from the plugin manager

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290634 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-21 06:45:50 +00:00
parent 881aa8b860
commit 8858d8f85c
18 changed files with 336 additions and 265 deletions

View File

@ -31,6 +31,8 @@ import org.apache.maven.model.Goal;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement; import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.event.MavenEvents; import org.apache.maven.monitor.event.MavenEvents;
import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecution;
@ -47,6 +49,7 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.project.injection.ModelDefaultsInjector; import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.apache.maven.reactor.ReactorException; import org.apache.maven.reactor.ReactorException;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -474,6 +477,13 @@ public class DefaultLifecycleExecutor
forkLifecycle( mojoDescriptor, session, project ); forkLifecycle( mojoDescriptor, session, project );
} }
if ( mojoDescriptor.isRequiresReports() )
{
List reports = getReports( project, mojoExecution, session );
mojoExecution.setReports( reports );
}
try try
{ {
pluginManager.executeMojo( project, mojoExecution, session ); pluginManager.executeMojo( project, mojoExecution, session );
@ -485,6 +495,91 @@ public class DefaultLifecycleExecutor
} }
} }
private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws ArtifactResolutionException, LifecycleExecutionException
{
List reportPlugins = project.getReportPlugins();
if ( project.getModel().getReports() != null )
{
getLogger().error(
"DEPRECATED: Plugin contains a <reports/> section: this is IGNORED - please use <reporting/> instead." );
}
List reports = new ArrayList();
if ( reportPlugins != null )
{
for ( Iterator it = reportPlugins.iterator(); it.hasNext(); )
{
ReportPlugin reportPlugin = (ReportPlugin) it.next();
List reportSets = reportPlugin.getReportSets();
try
{
if ( reportSets == null || reportSets.isEmpty() )
{
reports.addAll( getReports( reportPlugin, null, project, session, mojoExecution ) );
}
else
{
for ( Iterator j = reportSets.iterator(); j.hasNext(); )
{
ReportSet reportSet = (ReportSet) j.next();
reports.addAll( getReports( reportPlugin, reportSet, project, session, mojoExecution ) );
}
}
}
catch ( PluginManagerException e )
{
throw new LifecycleExecutionException( "Error getting reports", e );
}
catch ( PluginVersionResolutionException e )
{
throw new LifecycleExecutionException( "Error getting reports", e );
}
}
}
return reports;
}
private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
MojoExecution mojoExecution )
throws PluginManagerException, PluginVersionResolutionException, ArtifactResolutionException
{
PluginDescriptor pluginDescriptor = pluginManager.verifyReportPlugin( reportPlugin, project, session );
List reports = new ArrayList();
for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
{
MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
// TODO: check ID is correct for reports
// if the POM configured no reports, give all from plugin
if ( reportSet == null || reportSet.getReports().contains( mojoDescriptor.getGoal() ) )
{
String id = null;
if ( reportSet != null )
{
id = reportSet.getId();
}
MojoExecution reportExecution = new MojoExecution( mojoDescriptor, id );
MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
// Comes back null if it was a plugin, not a report - these are mojos in the reporting plugins that are not reports
if ( reportMojo != null )
{
reports.add( reportMojo );
mojoExecution.addMojoExecution( reportExecution );
}
}
}
return reports;
}
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project ) private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
{ {

View File

@ -17,7 +17,6 @@ package org.apache.maven.plugin;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@ -36,7 +35,6 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.execution.RuntimeInformation;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.event.MavenEvents; import org.apache.maven.monitor.event.MavenEvents;
import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.monitor.logging.DefaultLog;
@ -160,6 +158,13 @@ public class DefaultPluginManager
plugin.setVersion( version ); plugin.setVersion( version );
} }
return verifyVersionedPlugin( plugin, project, localRepository );
}
private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
ArtifactRepository localRepository )
throws PluginVersionResolutionException, PluginManagerException, ArtifactResolutionException
{
// TODO: this might result in an artifact "RELEASE" being resolved continuously // TODO: this might result in an artifact "RELEASE" being resolved continuously
// FIXME: need to find out how a plugin gets marked as 'installed' // FIXME: need to find out how a plugin gets marked as 'installed'
// and no ChildContainer exists. The check for that below fixes // and no ChildContainer exists. The check for that below fixes
@ -327,7 +332,7 @@ public class DefaultPluginManager
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
} }
plugin = getConfiguredMojo( mojoDescriptor, session, dom, project, false ); plugin = getConfiguredMojo( session, dom, project, false, mojoExecution );
} }
catch ( PluginConfigurationException e ) catch ( PluginConfigurationException e )
{ {
@ -390,69 +395,55 @@ public class DefaultPluginManager
} }
} }
public List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session ) public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException, throws PluginManagerException
ArtifactResolutionException
{ {
Plugin forLookup = new Plugin(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(),
mojoExecution.getExecutionId() );
if ( mojoExecution.getConfiguration() != null )
{
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
}
String groupId = reportPlugin.getGroupId(); MavenReport reportMojo;
String artifactId = reportPlugin.getArtifactId(); try
{
forLookup.setGroupId( groupId ); reportMojo = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
forLookup.setArtifactId( artifactId ); }
catch ( ComponentLookupException e )
{
throw new PluginManagerException( "Error looking up report: ", e );
}
catch ( PluginConfigurationException e )
{
throw new PluginManagerException( "Error configuring report: ", e );
}
return reportMojo;
}
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException
{
String version = reportPlugin.getVersion(); String version = reportPlugin.getVersion();
Artifact existingPluginArtifact = (Artifact) project.getReportArtifactMap().get( reportPlugin.getKey() ); if ( version == null )
if ( existingPluginArtifact == null ||
!reportPlugin.getKey().equals( ArtifactUtils.versionlessKey( existingPluginArtifact ) ) || version == null )
{ {
version = pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, session.getSettings(), version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(),
session.getLocalRepository(), true ); reportPlugin.getArtifactId(), project,
session.getSettings(),
session.getLocalRepository() );
reportPlugin.setVersion( version );
} }
Plugin forLookup = new Plugin();
forLookup.setGroupId( reportPlugin.getGroupId() );
forLookup.setArtifactId( reportPlugin.getArtifactId() );
forLookup.setVersion( version ); forLookup.setVersion( version );
PluginDescriptor pluginDescriptor = verifyPlugin( forLookup, project, session return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() );
.getSettings(), session.getLocalRepository() );
List reports = new ArrayList();
for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
{
MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
// TODO: check ID is correct for reports
// if the POM configured no reports, give all from plugin
if ( reportSet == null || reportSet.getReports().contains( mojoDescriptor.getGoal() ) )
{
try
{
String id = null;
if ( reportSet != null )
{
id = reportSet.getId();
}
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, id );
String executionId = mojoExecution.getExecutionId();
Xpp3Dom dom = project.getReportConfiguration( reportPlugin.getGroupId(),
reportPlugin.getArtifactId(), executionId );
Mojo reportMojo = getConfiguredMojo( mojoDescriptor, session, dom, project, true );
if ( reportMojo != null )
{
reports.add( reportMojo );
}
}
catch ( ComponentLookupException e )
{
throw new PluginManagerException( "Error looking up plugin: ", e );
}
}
}
return reports;
} }
private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor ) private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor )
@ -469,10 +460,12 @@ public class DefaultPluginManager
return pluginContainer; return pluginContainer;
} }
private Mojo getConfiguredMojo( MojoDescriptor mojoDescriptor, MavenSession session, Xpp3Dom dom, private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
MavenProject project, boolean report ) MojoExecution mojoExecution )
throws ComponentLookupException, PluginConfigurationException, PluginManagerException throws ComponentLookupException, PluginConfigurationException, PluginManagerException
{ {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );
@ -511,7 +504,7 @@ public class DefaultPluginManager
// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
// mojoDescriptor.getConfiguration() ); // mojoDescriptor.getConfiguration() );
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoDescriptor, ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution,
pathTranslator, getLogger(), pathTranslator, getLogger(),
project ); project );
@ -1019,8 +1012,8 @@ public class DefaultPluginManager
configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE ); configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE );
} }
configurator.configureComponent( plugin, configuration, expressionEvaluator, pluginContainer configurator.configureComponent( plugin, configuration, expressionEvaluator,
.getContainerRealm() ); pluginContainer.getContainerRealm() );
} }
catch ( ComponentConfigurationException e ) catch ( ComponentConfigurationException e )
{ {

View File

@ -19,6 +19,9 @@ package org.apache.maven.plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
import java.util.List;
/** /**
* Describes a single mojo invocation. * Describes a single mojo invocation.
* *
@ -33,6 +36,10 @@ public class MojoExecution
private final Xpp3Dom configuration; private final Xpp3Dom configuration;
private List forkedExecutions = new ArrayList();
private List reports;
public MojoExecution( MojoDescriptor mojoDescriptor ) public MojoExecution( MojoDescriptor mojoDescriptor )
{ {
this.mojoDescriptor = mojoDescriptor; this.mojoDescriptor = mojoDescriptor;
@ -68,4 +75,19 @@ public class MojoExecution
{ {
return configuration; return configuration;
} }
public void addMojoExecution( MojoExecution execution )
{
forkedExecutions.add( execution );
}
public void setReports( List reports )
{
this.reports = reports;
}
public List getReports()
{
return reports;
}
} }

View File

@ -19,16 +19,15 @@ package org.apache.maven.plugin;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -42,6 +41,9 @@ public interface PluginManager
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException; throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws PluginManagerException;
PluginDescriptor getPluginDescriptorForPrefix( String prefix ) PluginDescriptor getPluginDescriptorForPrefix( String prefix )
throws PluginManagerException; throws PluginManagerException;
@ -52,9 +54,8 @@ public interface PluginManager
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException; throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException;
List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session ) PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException, throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException;
ArtifactResolutionException;
Object getPluginComponent( Plugin plugin, String role, String roleHint ) Object getPluginComponent( Plugin plugin, String role, String roleHint )
throws ComponentLookupException, PluginManagerException; throws ComponentLookupException, PluginManagerException;

View File

@ -62,15 +62,15 @@ public class PluginParameterExpressionEvaluator
private final Logger logger; private final Logger logger;
private final MojoDescriptor mojoDescriptor; private final MojoExecution mojoExecution;
private final MavenProject project; private final MavenProject project;
public PluginParameterExpressionEvaluator( MavenSession context, MojoDescriptor mojoDescriptor, public PluginParameterExpressionEvaluator( MavenSession context, MojoExecution mojoExecution,
PathTranslator pathTranslator, Logger logger, MavenProject project ) PathTranslator pathTranslator, Logger logger, MavenProject project )
{ {
this.context = context; this.context = context;
this.mojoDescriptor = mojoDescriptor; this.mojoExecution = mojoExecution;
this.pathTranslator = pathTranslator; this.pathTranslator = pathTranslator;
this.logger = logger; this.logger = logger;
this.project = project; this.project = project;
@ -106,18 +106,20 @@ public class PluginParameterExpressionEvaluator
return expression; return expression;
} }
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
if ( BANNED_EXPRESSIONS.containsKey( expression ) ) if ( BANNED_EXPRESSIONS.containsKey( expression ) )
{ {
throw new ExpressionEvaluationException( "The parameter expression: \'" + expression throw new ExpressionEvaluationException( "The parameter expression: \'" + expression +
+ "\' used in mojo: \'" + mojoDescriptor.getGoal() + "\' is banned. Use \'" "\' used in mojo: \'" + mojoDescriptor.getGoal() + "\' is banned. Use \'" +
+ BANNED_EXPRESSIONS.get( expression ) + "\' instead." ); BANNED_EXPRESSIONS.get( expression ) + "\' instead." );
} }
else if ( DEPRECATED_EXPRESSIONS.containsKey( expression ) ) else if ( DEPRECATED_EXPRESSIONS.containsKey( expression ) )
{ {
logger.warn( "The parameter expression: \'" + expression + "\' used in mojo: \'" + mojoDescriptor.getGoal() logger.warn( "The parameter expression: \'" + expression + "\' used in mojo: \'" +
+ "\' has been deprecated. Use \'" + DEPRECATED_EXPRESSIONS.get( expression ) + "\' instead." ); mojoDescriptor.getGoal() + "\' has been deprecated. Use \'" + DEPRECATED_EXPRESSIONS.get( expression ) +
"\' instead." );
} }
if ( "localRepository".equals( expression ) ) if ( "localRepository".equals( expression ) )
{ {
value = context.getLocalRepository(); value = context.getLocalRepository();
@ -130,6 +132,10 @@ public class PluginParameterExpressionEvaluator
{ {
value = context.getSortedProjects(); value = context.getSortedProjects();
} }
else if ( "reports".equals( expression ) )
{
value = mojoExecution.getReports();
}
else if ( "project".equals( expression ) ) else if ( "project".equals( expression ) )
{ {
value = project; value = project;
@ -233,7 +239,7 @@ public class PluginParameterExpressionEvaluator
logger.error( "Got expression '" + expression + "' that was not recognised" ); logger.error( "Got expression '" + expression + "' that was not recognised" );
} }
} }
if ( value == null ) if ( value == null )
{ {
// Check properties that have been injected via profiles before we default over to // Check properties that have been injected via profiles before we default over to

View File

@ -80,8 +80,15 @@ public class DefaultPluginVersionManager
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false ); return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false );
} }
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
ArtifactRepository localRepository, boolean resolveAsReportPlugin ) Settings settings, ArtifactRepository localRepository )
throws PluginVersionResolutionException
{
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, true );
}
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
ArtifactRepository localRepository, boolean resolveAsReportPlugin )
throws PluginVersionResolutionException throws PluginVersionResolutionException
{ {
// first pass...if the plugin is specified in the pom, try to retrieve the version from there. // first pass...if the plugin is specified in the pom, try to retrieve the version from there.

View File

@ -1,9 +1,5 @@
package org.apache.maven.plugin.version; package org.apache.maven.plugin.version;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
/* /*
* Copyright 2001-2005 The Apache Software Foundation. * Copyright 2001-2005 The Apache Software Foundation.
* *
@ -20,15 +16,20 @@ import org.apache.maven.settings.Settings;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
public interface PluginVersionManager public interface PluginVersionManager
{ {
String ROLE = PluginVersionManager.class.getName(); String ROLE = PluginVersionManager.class.getName();
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository ) String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
ArtifactRepository localRepository )
throws PluginVersionResolutionException; throws PluginVersionResolutionException;
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository, boolean resolveAsReportPlugin ) String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
ArtifactRepository localRepository )
throws PluginVersionResolutionException; throws PluginVersionResolutionException;
} }

View File

@ -69,8 +69,8 @@ public class PluginParameterExpressionEvaluatorTest
assertEquals( expected, actual ); assertEquals( expected, actual );
} }
private static MavenSession createSession( PlexusContainer container, private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo )
ArtifactRepository repo ) throws CycleDetectedException throws CycleDetectedException
{ {
return new MavenSession( container, new Settings(), repo, new DefaultEventDispatcher(), return new MavenSession( container, new Settings(), repo, new DefaultEventDispatcher(),
new ReactorManager( Collections.EMPTY_LIST ), Collections.EMPTY_LIST, "." ); new ReactorManager( Collections.EMPTY_LIST ), Collections.EMPTY_LIST, "." );
@ -141,12 +141,14 @@ public class PluginParameterExpressionEvaluatorTest
PlexusContainer container = getContainer(); PlexusContainer container = getContainer();
MavenSession session = createSession( container, repo ); MavenSession session = createSession( container, repo );
MojoDescriptor mojo = new MojoDescriptor(); MojoDescriptor mojo = new MojoDescriptor();
mojo.setPluginDescriptor( pluginDescriptor ); mojo.setPluginDescriptor( pluginDescriptor );
mojo.setGoal( "goal" ); mojo.setGoal( "goal" );
return (ExpressionEvaluator) new PluginParameterExpressionEvaluator( session, mojo, null, MojoExecution mojoExecution = new MojoExecution( mojo );
return (ExpressionEvaluator) new PluginParameterExpressionEvaluator( session, mojoExecution, null,
container.getLogger(), project ); container.getLogger(), project );
} }
@ -159,4 +161,4 @@ public class PluginParameterExpressionEvaluatorTest
return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
} }
} }

View File

@ -61,7 +61,7 @@ public class MojoDescriptor
private String executeLifecycle; private String executeLifecycle;
private String deprecated; private String deprecated;
private boolean aggregator = false; private boolean aggregator = false;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -79,9 +79,11 @@ public class MojoDescriptor
private PluginDescriptor pluginDescriptor; private PluginDescriptor pluginDescriptor;
private boolean inheritedByDefault = true; private boolean inheritedByDefault = true;
private boolean directInvocationOnly = false; private boolean directInvocationOnly = false;
private boolean requiresReports = false;
public MojoDescriptor() public MojoDescriptor()
{ {
setInstantiationStrategy( DEFAULT_INSTANTIATION_STRATEGY ); setInstantiationStrategy( DEFAULT_INSTANTIATION_STRATEGY );
@ -132,9 +134,9 @@ public class MojoDescriptor
{ {
if ( parameters != null && parameters.contains( parameter ) ) if ( parameters != null && parameters.contains( parameter ) )
{ {
throw new DuplicateParameterException( parameter.getName() throw new DuplicateParameterException( parameter.getName() +
+ " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " +
+ getImplementation() + ")" ); getImplementation() + ")" );
} }
else else
{ {
@ -393,12 +395,12 @@ public class MojoDescriptor
{ {
this.executeLifecycle = executeLifecycle; this.executeLifecycle = executeLifecycle;
} }
public void setAggregator( boolean aggregator ) public void setAggregator( boolean aggregator )
{ {
this.aggregator = aggregator; this.aggregator = aggregator;
} }
public boolean isAggregator() public boolean isAggregator()
{ {
return aggregator; return aggregator;
@ -413,4 +415,14 @@ public class MojoDescriptor
{ {
this.directInvocationOnly = directInvocationOnly; this.directInvocationOnly = directInvocationOnly;
} }
public boolean isRequiresReports()
{
return requiresReports;
}
public void setRequiresReports( boolean requiresReports )
{
this.requiresReports = requiresReports;
}
} }

View File

@ -37,10 +37,10 @@ public class PluginDescriptorBuilder
pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() ); pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() );
pluginDescriptor.setVersion( c.getChild( "version" ).getValue() ); pluginDescriptor.setVersion( c.getChild( "version" ).getValue() );
pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() ); pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() );
String isolatedRealm = c.getChild( "isolatedRealm" ).getValue(); String isolatedRealm = c.getChild( "isolatedRealm" ).getValue();
if( isolatedRealm != null ) if ( isolatedRealm != null )
{ {
pluginDescriptor.setIsolatedRealm( Boolean.valueOf( isolatedRealm ).booleanValue() ); pluginDescriptor.setIsolatedRealm( Boolean.valueOf( isolatedRealm ).booleanValue() );
} }
@ -63,7 +63,7 @@ public class PluginDescriptorBuilder
PlexusConfiguration component = mojoConfigurations[i]; PlexusConfiguration component = mojoConfigurations[i];
MojoDescriptor mojoDescriptor = buildComponentDescriptor( component, pluginDescriptor ); MojoDescriptor mojoDescriptor = buildComponentDescriptor( component, pluginDescriptor );
pluginDescriptor.addMojo( mojoDescriptor ); pluginDescriptor.addMojo( mojoDescriptor );
} }
@ -174,6 +174,13 @@ public class PluginDescriptorBuilder
mojo.setProjectRequired( Boolean.valueOf( requiresProject ).booleanValue() ); mojo.setProjectRequired( Boolean.valueOf( requiresProject ).booleanValue() );
} }
String requiresReports = c.getChild( "requiresReports" ).getValue();
if ( requiresReports != null )
{
mojo.setRequiresReports( Boolean.valueOf( requiresReports ).booleanValue() );
}
String aggregator = c.getChild( "aggregator" ).getValue(); String aggregator = c.getChild( "aggregator" ).getValue();
if ( aggregator != null ) if ( aggregator != null )
@ -194,7 +201,7 @@ public class PluginDescriptorBuilder
{ {
mojo.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() ); mojo.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() );
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Parameters // Parameters
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -139,6 +139,12 @@ public class PluginDescriptorGenerator
// //
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
element( w, "requiresReports", "" + mojoDescriptor.isRequiresReports() );
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
element( w, "aggregator", "" + mojoDescriptor.isAggregator() ); element( w, "aggregator", "" + mojoDescriptor.isAggregator() );
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -140,6 +140,10 @@ extract( file, mojoDescriptor )
this.parameter = createParameter( text, method ); this.parameter = createParameter( text, method );
if ( parameter != null ) if ( parameter != null )
{ {
if ( "${reports}".equals( parameter.getExpression() ) )
{
mojoDescriptor.setRequiresReports( true );
}
mojoDescriptor.addParameter( parameter ); mojoDescriptor.addParameter( parameter );
} }

View File

@ -29,8 +29,8 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.Requirement; import org.apache.maven.plugin.descriptor.Requirement;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor; import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -68,8 +68,7 @@ public class JavaMojoDescriptorExtractor
* Would say there is a getProject() method and a setProject(Project) method. Here the field * Would say there is a getProject() method and a setProject(Project) method. Here the field
* name would not be the basis for the parameter's name. This mode of operation will allow the * name would not be the basis for the parameter's name. This mode of operation will allow the
* mojos to be usable as beans and will be the promoted form of use. * mojos to be usable as beans and will be the promoted form of use.
* */
**/
public static final String PARAMETER_PROPERTY = "property"; public static final String PARAMETER_PROPERTY = "property";
public static final String REQUIRED = "required"; public static final String REQUIRED = "required";
@ -90,6 +89,8 @@ public class JavaMojoDescriptorExtractor
public static final String GOAL_REQUIRES_PROJECT = "requiresProject"; public static final String GOAL_REQUIRES_PROJECT = "requiresProject";
public static final String GOAL_REQUIRES_REPORTS = "requiresReports";
public static final String GOAL_IS_AGGREGATOR = "aggregator"; public static final String GOAL_IS_AGGREGATOR = "aggregator";
public static final String GOAL_REQUIRES_ONLINE = "requiresOnline"; public static final String GOAL_REQUIRES_ONLINE = "requiresOnline";
@ -414,6 +415,11 @@ public class JavaMojoDescriptorExtractor
pd.setExpression( parameter.getNamedParameter( PARAMETER_EXPRESSION ) ); pd.setExpression( parameter.getNamedParameter( PARAMETER_EXPRESSION ) );
if ( "${reports}".equals( pd.getExpression() ) )
{
mojoDescriptor.setRequiresReports( true );
}
pd.setDefaultValue( parameter.getNamedParameter( PARAMETER_DEFAULT_VALUE ) ); pd.setDefaultValue( parameter.getNamedParameter( PARAMETER_DEFAULT_VALUE ) );
} }

View File

@ -11,52 +11,32 @@
<version>2.0-beta-2-SNAPSHOT</version> <version>2.0-beta-2-SNAPSHOT</version>
<inceptionYear>2001</inceptionYear> <inceptionYear>2001</inceptionYear>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId> <artifactId>maven-project</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId> <artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-beta-1</version> <version>2.0-beta-2-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-java</artifactId> <artifactId>maven-plugin-tools-java</artifactId>
<version>2.0-beta-1</version> <version>2.0-beta-2-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-beanshell</artifactId> <artifactId>maven-plugin-tools-beanshell</artifactId>
<version>2.0-beta-1</version> <version>2.0-beta-2-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-marmalade</artifactId> <artifactId>maven-plugin-tools-marmalade</artifactId>
<version>2.0-beta-1</version> <version>2.0-beta-2-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -9,6 +9,9 @@
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<name>Maven Site plugin</name> <name>Maven Site plugin</name>
<version>2.0-beta-2-SNAPSHOT</version> <version>2.0-beta-2-SNAPSHOT</version>
<prerequisites>
<maven>2.0-beta-2-SNAPSHOT</maven>
</prerequisites>
<developers> <developers>
<developer> <developer>
<id>vsiveton</id> <id>vsiveton</id>
@ -22,21 +25,11 @@
</developer> </developer>
</developers> </developers>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>plexus</groupId> <groupId>plexus</groupId>
<artifactId>plexus-site-renderer</artifactId> <artifactId>plexus-site-renderer</artifactId>
<version>1.0-alpha-2</version> <version>1.0-alpha-2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>plexus</groupId> <groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
@ -46,6 +39,11 @@
<artifactId>maven-reporting-api</artifactId> <artifactId>maven-reporting-api</artifactId>
<version>2.0-beta-1</version> <version>2.0-beta-1</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-beta-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId> <artifactId>wagon-ssh</artifactId>

View File

@ -16,16 +16,8 @@ package org.apache.maven.doxia;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
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.PluginConfigurationException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport; import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportException; import org.apache.maven.reporting.MavenReportException;
@ -106,19 +98,19 @@ public class DoxiaMojo
* @parameter expression="${basedir}/src/site" * @parameter expression="${basedir}/src/site"
* @required * @required
*/ */
private String siteDirectory; private File siteDirectory;
/** /**
* @parameter alias="workingDirectory" expression="${project.build.directory}/generated-site" * @parameter alias="workingDirectory" expression="${project.build.directory}/generated-site"
* @required * @required
*/ */
private String generatedSiteDirectory; private File generatedSiteDirectory;
/** /**
* @parameter expression="${project.build.directory}/site" * @parameter expression="${project.build.directory}/site"
* @required * @required
*/ */
private String outputDirectory; private File outputDirectory;
/** /**
* @parameter expression="${basedir}/src/site/resources" * @parameter expression="${basedir}/src/site/resources"
@ -127,17 +119,17 @@ public class DoxiaMojo
private File resourcesDirectory; private File resourcesDirectory;
/** /**
* @parameter expression="${templateDirectory} * @parameter expression="${templateDirectory}"
*/ */
private String templateDirectory; private String templateDirectory;
/** /**
* @parameter expression="${template} * @parameter expression="${template}"
*/ */
private String template = DEFAULT_TEMPLATE; private String template = DEFAULT_TEMPLATE;
/** /**
* @parameter expression="${attributes} * @parameter expression="${attributes}"
*/ */
private Map attributes; private Map attributes;
@ -145,7 +137,7 @@ public class DoxiaMojo
* A comma separated list of locales supported by Maven. The first valid token will be the default Locale * A comma separated list of locales supported by Maven. The first valid token will be the default Locale
* for this instance of the Java Virtual Machine. * for this instance of the Java Virtual Machine.
* *
* @parameter expression="${locales} * @parameter expression="${locales}"
*/ */
private String locales; private String locales;
@ -183,18 +175,11 @@ public class DoxiaMojo
private MavenProject project; private MavenProject project;
/** /**
* @parameter expression="${component.org.apache.maven.plugin.PluginManager}" * @parameter expression="${reports}"
* @required * @required
* @readonly * @readonly
*/ */
private PluginManager pluginManager; private List reports;
/**
* @parameter expression="${session}"
* @required
* @readonly
*/
private MavenSession session;
/** /**
* @see org.apache.maven.plugin.Mojo#execute() * @see org.apache.maven.plugin.Mojo#execute()
@ -239,6 +224,21 @@ public class DoxiaMojo
attributes.put( "outputEncoding", outputEncoding ); attributes.put( "outputEncoding", outputEncoding );
} }
Map categories = categorizeReports( reports );
List projectInfos = (List) categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );
List projectReports = (List) categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
if ( projectInfos == null )
{
projectInfos = Collections.EMPTY_LIST;
}
if ( projectReports == null )
{
projectReports = Collections.EMPTY_LIST;
}
try try
{ {
List localesList = initLocalesList(); List localesList = initLocalesList();
@ -264,7 +264,7 @@ public class DoxiaMojo
} }
// Generate static site // Generate static site
File siteDirectoryFile = new File( siteDirectory ); File siteDirectoryFile = siteDirectory;
if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) ) if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) )
{ {
siteDirectoryFile = new File( siteDirectory, locale.getLanguage() ); siteDirectoryFile = new File( siteDirectory, locale.getLanguage() );
@ -278,11 +278,9 @@ public class DoxiaMojo
} }
// Handle the GeneratedSite Directory // Handle the GeneratedSite Directory
File generatedSiteFile = new File( generatedSiteDirectory ); if ( generatedSiteDirectory.exists() )
if ( generatedSiteFile.exists() )
{ {
tryToFindDuplicates( generatedSiteFile, duplicate ); tryToFindDuplicates( generatedSiteDirectory, duplicate );
} }
// Exception if a file is duplicate // Exception if a file is duplicate
@ -292,28 +290,11 @@ public class DoxiaMojo
throw new MavenReportException( msg ); throw new MavenReportException( msg );
} }
List reports = getReports();
Map categories = categorizeReports( reports );
List projectInfos = (List) categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );
List projectReports = (List) categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
if ( projectInfos == null )
{
projectInfos = Collections.EMPTY_LIST;
}
if ( projectReports == null )
{
projectReports = Collections.EMPTY_LIST;
}
String siteDescriptor = getSiteDescriptor( reports, locale, projectInfos, projectReports ); String siteDescriptor = getSiteDescriptor( reports, locale, projectInfos, projectReports );
if ( generatedSiteFile.exists() ) if ( generatedSiteDirectory.exists() )
{ {
siteRenderer.render( generatedSiteFile, outputDirectory, siteDescriptor, template, attributes, siteRenderer.render( generatedSiteDirectory, outputDirectory, siteDescriptor, template, attributes,
locale ); locale );
} }
@ -437,6 +418,7 @@ public class DoxiaMojo
MavenReport report = (MavenReport) i.next(); MavenReport report = (MavenReport) i.next();
List category = (List) categories.get( report.getCategoryName() ); List category = (List) categories.get( report.getCategoryName() );
if ( category == null ) if ( category == null )
{ {
category = new ArrayList(); category = new ArrayList();
@ -699,7 +681,7 @@ public class DoxiaMojo
{ {
String outputFileName = "index.html"; String outputFileName = "index.html";
SiteRendererSink sink = siteRenderer.createSink( new File( siteDirectory ), outputFileName, siteDescriptor ); SiteRendererSink sink = siteRenderer.createSink( siteDirectory, outputFileName, siteDescriptor );
String title = i18n.getString( "site-plugin", locale, "report.index.title" ).trim() + " " + project.getName(); String title = i18n.getString( "site-plugin", locale, "report.index.title" ).trim() + " " + project.getName();
@ -775,8 +757,7 @@ public class DoxiaMojo
String outputFileName = reportFileName + ".html"; String outputFileName = reportFileName + ".html";
SiteRendererSink sink = siteRenderer.createSink( new File( siteDirectory ), outputFileName, SiteRendererSink sink = siteRenderer.createSink( siteDirectory, outputFileName, siteDescriptor );
siteDescriptor );
report.generate( sink, locale ); report.generate( sink, locale );
@ -803,7 +784,7 @@ public class DoxiaMojo
{ {
String outputFileName = "project-info.html"; String outputFileName = "project-info.html";
SiteRendererSink sink = siteRenderer.createSink( new File( siteDirectory ), outputFileName, siteDescriptor ); SiteRendererSink sink = siteRenderer.createSink( siteDirectory, outputFileName, siteDescriptor );
String title = i18n.getString( "site-plugin", locale, "report.information.title" ); String title = i18n.getString( "site-plugin", locale, "report.information.title" );
@ -884,7 +865,7 @@ public class DoxiaMojo
{ {
String outputFileName = "maven-reports.html"; String outputFileName = "maven-reports.html";
SiteRendererSink sink = siteRenderer.createSink( new File( siteDirectory ), outputFileName, siteDescriptor ); SiteRendererSink sink = siteRenderer.createSink( siteDirectory, outputFileName, siteDescriptor );
String title = i18n.getString( "site-plugin", locale, "report.project.title" ); String title = i18n.getString( "site-plugin", locale, "report.project.title" );
@ -1037,76 +1018,12 @@ public class DoxiaMojo
{ {
if ( locale.getLanguage().equals( defaultLocale.getLanguage() ) ) if ( locale.getLanguage().equals( defaultLocale.getLanguage() ) )
{ {
return new File( outputDirectory ); return outputDirectory;
} }
return new File( outputDirectory, locale.getLanguage() ); return new File( outputDirectory, locale.getLanguage() );
} }
private List getReports()
throws MojoExecutionException
{
// TODO: not the best solution. Perhaps a mojo tag that causes the plugin manager to populate project reports instead?
List reportPlugins = project.getReportPlugins();
if ( project.getModel().getReports() != null )
{
getLog().error(
"DEPRECATED: Plugin contains a <reports/> section: this is IGNORED - please use <reporting/> instead." );
}
List reports = new ArrayList();
if ( reportPlugins != null )
{
for ( Iterator it = reportPlugins.iterator(); it.hasNext(); )
{
ReportPlugin reportPlugin = (ReportPlugin) it.next();
try
{
List reportSets = reportPlugin.getReportSets();
List reportsList = new ArrayList();
if ( reportSets == null || reportSets.isEmpty() )
{
reportsList = pluginManager.getReports( reportPlugin, null, project, session );
}
else
{
for ( Iterator j = reportSets.iterator(); j.hasNext(); )
{
ReportSet reportSet = (ReportSet) j.next();
reportsList = pluginManager.getReports( reportPlugin, reportSet, project, session );
}
}
reports.addAll( reportsList );
}
catch ( PluginManagerException e )
{
throw new MojoExecutionException( "Error getting reports", e );
}
catch ( PluginVersionResolutionException e )
{
throw new MojoExecutionException( "Error getting reports", e );
}
catch ( PluginConfigurationException e )
{
throw new MojoExecutionException( "Error getting reports", e );
}
catch ( ArtifactResolutionException e )
{
throw new MojoExecutionException( "Cannot find report plugin", e );
}
}
}
return reports;
}
/** /**
* Convenience method that try to find duplicate files in sub-directories of a given directory. * Convenience method that try to find duplicate files in sub-directories of a given directory.
* <p>The scan is case sensitive.</p> * <p>The scan is case sensitive.</p>

View File

@ -63,6 +63,8 @@ public class MetadataTag
private String lifecyclePhase; private String lifecyclePhase;
private boolean requiresReports;
protected boolean alwaysProcessChildren() protected boolean alwaysProcessChildren()
{ {
return false; return false;
@ -132,7 +134,8 @@ public class MetadataTag
{ {
throw new TagExecutionException( getTagInfo(), "One or more mojo parameters is invalid.", e ); throw new TagExecutionException( getTagInfo(), "One or more mojo parameters is invalid.", e );
} }
descriptor.setRequiresReports( requiresReports );
descriptor.setDependencyResolutionRequired( requiresDependencyResolution ); descriptor.setDependencyResolutionRequired( requiresDependencyResolution );
descriptor.setProjectRequired( requiresProject ); descriptor.setProjectRequired( requiresProject );
descriptor.setAggregator( aggregator ); descriptor.setAggregator( aggregator );
@ -201,12 +204,12 @@ public class MetadataTag
public void setAggregator( boolean aggregator ) public void setAggregator( boolean aggregator )
{ {
this.aggregator = aggregator; this.aggregator = aggregator;
} }
public void setInheritByDefault( boolean inheritByDefault ) public void setInheritByDefault( boolean inheritByDefault )
{ {
this.inheritByDefault = inheritByDefault; this.inheritByDefault = inheritByDefault;
} }
public void setRequiresOnline( boolean requiresOnline ) public void setRequiresOnline( boolean requiresOnline )
@ -229,4 +232,8 @@ public class MetadataTag
this.lifecyclePhase = lifecyclePhase; this.lifecyclePhase = lifecyclePhase;
} }
public void setRequiresReports( boolean requiresReports )
{
this.requiresReports = requiresReports;
}
} }

View File

@ -30,19 +30,26 @@ import java.util.List;
public class ParametersTag public class ParametersTag
extends AbstractMarmaladeTag extends AbstractMarmaladeTag
{ {
private boolean requiresReports = false;
private List parameters = new ArrayList(); private List parameters = new ArrayList();
protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeExecutionException protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{ {
processChildren( context ); processChildren( context );
MetadataTag metadataTag = (MetadataTag) requireParent( MetadataTag.class ); MetadataTag metadataTag = (MetadataTag) requireParent( MetadataTag.class );
metadataTag.setParameters( parameters ); metadataTag.setParameters( parameters );
metadataTag.setRequiresReports( requiresReports );
} }
public void addParameter( Parameter parameter ) public void addParameter( Parameter parameter )
{ {
if ( "${reports}".equals( parameter.getExpression() ) )
{
requiresReports = true;
}
this.parameters.add( parameter ); this.parameters.add( parameter );
} }