You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/01/28 19:58:47 UTC
[maven-reporting-exec] branch master updated: [MSHARED-1180] Upgrade Parent to 39
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-reporting-exec.git
The following commit(s) were added to refs/heads/master by this push:
new a25cddb [MSHARED-1180] Upgrade Parent to 39
a25cddb is described below
commit a25cddb987221e26122ec84fdd970d6ffc03ec45
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Jan 28 20:58:16 2023 +0100
[MSHARED-1180] Upgrade Parent to 39
---
pom.xml | 6 +-
.../exec/DefaultMavenPluginManagerHelper.java | 37 +-
.../reporting/exec/DefaultMavenReportExecutor.java | 629 +++++++++------------
.../reporting/exec/MavenPluginManagerHelper.java | 26 +-
.../maven/reporting/exec/MavenReportExecution.java | 68 +--
.../maven/reporting/exec/MavenReportExecutor.java | 14 +-
.../reporting/exec/MavenReportExecutorRequest.java | 65 +--
.../apache/maven/reporting/exec/ReportPlugin.java | 54 +-
.../org/apache/maven/reporting/exec/ReportSet.java | 31 +-
src/main/java/org/codehaus/doxia/sink/Sink.java | 7 +-
.../exec/TestDefaultMavenReportExecutor.java | 311 +++++-----
11 files changed, 537 insertions(+), 711 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7739ec9..b8b3960 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
- <version>36</version>
+ <version>39</version>
<relativePath />
</parent>
@@ -37,8 +37,8 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-reporting-exec.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-reporting-exec.git</developerConnection>
- <url>https://github.com/apache/maven-reporting-exec/tree/${project.scm.tag}</url>
<tag>maven-reporting-exec-2.0.0-M1</tag>
+ <url>https://github.com/apache/maven-reporting-exec/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
diff --git a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
index 8c68b00..b9f4c65 100644
--- a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
+++ b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import javax.inject.Inject;
import javax.inject.Named;
@@ -45,40 +44,38 @@ import static java.util.Objects.requireNonNull;
*/
@Singleton
@Named
-public class DefaultMavenPluginManagerHelper
- implements MavenPluginManagerHelper
-{
+public class DefaultMavenPluginManagerHelper implements MavenPluginManagerHelper {
private final MavenPluginManager mavenPluginManager;
@Inject
- public DefaultMavenPluginManagerHelper( MavenPluginManager mavenPluginManager )
- {
- this.mavenPluginManager = requireNonNull( mavenPluginManager );
+ public DefaultMavenPluginManagerHelper(MavenPluginManager mavenPluginManager) {
+ this.mavenPluginManager = requireNonNull(mavenPluginManager);
}
- private DependencyFilter createExclusionsDependencyFilter( List<String> artifactIdsList )
- {
- return new ExclusionsDependencyFilter( artifactIdsList );
+ private DependencyFilter createExclusionsDependencyFilter(List<String> artifactIdsList) {
+ return new ExclusionsDependencyFilter(artifactIdsList);
}
/** {@inheritDoc} */
@Override
- public PluginDescriptor getPluginDescriptor( Plugin plugin, MavenSession session )
- throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
- {
+ public PluginDescriptor getPluginDescriptor(Plugin plugin, MavenSession session)
+ throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {
RepositorySystemSession repositorySystemSession = session.getRepositorySession();
List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories();
- return mavenPluginManager.getPluginDescriptor( plugin, remoteRepositories, repositorySystemSession );
+ return mavenPluginManager.getPluginDescriptor(plugin, remoteRepositories, repositorySystemSession);
}
/** {@inheritDoc} */
@Override
- public void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,
- List<String> imports, List<String> excludeArtifactIds )
- throws PluginResolutionException, PluginContainerException
- {
+ public void setupPluginRealm(
+ PluginDescriptor pluginDescriptor,
+ MavenSession session,
+ ClassLoader parent,
+ List<String> imports,
+ List<String> excludeArtifactIds)
+ throws PluginResolutionException, PluginContainerException {
mavenPluginManager.setupPluginRealm(
- pluginDescriptor, session, parent, imports, createExclusionsDependencyFilter( excludeArtifactIds ) );
+ pluginDescriptor, session, parent, imports, createExclusionsDependencyFilter(excludeArtifactIds));
}
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
index 2c7b8a5..372176f 100644
--- a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
+++ b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import javax.inject.Inject;
import javax.inject.Named;
@@ -101,10 +100,8 @@ import static java.util.Objects.requireNonNull;
*/
@Singleton
@Named
-public class DefaultMavenReportExecutor
- implements MavenReportExecutor
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultMavenReportExecutor.class );
+public class DefaultMavenReportExecutor implements MavenReportExecutor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMavenReportExecutor.class);
private final MavenPluginManager mavenPluginManager;
@@ -114,40 +111,39 @@ public class DefaultMavenReportExecutor
private final PluginVersionResolver pluginVersionResolver;
- private static final List<String> IMPORTS = Arrays.asList( "org.apache.maven.reporting.MavenReport",
- "org.apache.maven.reporting.MavenMultiPageReport",
- "org.apache.maven.doxia.siterenderer.Renderer",
- "org.apache.maven.doxia.sink.SinkFactory",
- // TODO Will be removed with Doxia 2.0.0
- "org.codehaus.doxia.sink.Sink",
- "org.apache.maven.doxia.sink.Sink",
- "org.apache.maven.doxia.sink.SinkEventAttributes",
- // TODO Will be removed with Doxia 2.0.0
- "org.apache.maven.doxia.logging.LogEnabled",
- // TODO Will be removed with Doxia 2.0.0
- "org.apache.maven.doxia.logging.Log" );
-
- private static final List<String> EXCLUDES = Arrays.asList( "doxia-site-renderer", "doxia-sink-api",
- "maven-reporting-api" );
+ private static final List<String> IMPORTS = Arrays.asList(
+ "org.apache.maven.reporting.MavenReport",
+ "org.apache.maven.reporting.MavenMultiPageReport",
+ "org.apache.maven.doxia.siterenderer.Renderer",
+ "org.apache.maven.doxia.sink.SinkFactory",
+ // TODO Will be removed with Doxia 2.0.0
+ "org.codehaus.doxia.sink.Sink",
+ "org.apache.maven.doxia.sink.Sink",
+ "org.apache.maven.doxia.sink.SinkEventAttributes",
+ // TODO Will be removed with Doxia 2.0.0
+ "org.apache.maven.doxia.logging.LogEnabled",
+ // TODO Will be removed with Doxia 2.0.0
+ "org.apache.maven.doxia.logging.Log");
+
+ private static final List<String> EXCLUDES =
+ Arrays.asList("doxia-site-renderer", "doxia-sink-api", "maven-reporting-api");
@Inject
- public DefaultMavenReportExecutor( MavenPluginManager mavenPluginManager,
- MavenPluginManagerHelper mavenPluginManagerHelper,
- LifecycleExecutor lifecycleExecutor,
- PluginVersionResolver pluginVersionResolver )
- {
- this.mavenPluginManager = requireNonNull( mavenPluginManager );
- this.mavenPluginManagerHelper = requireNonNull( mavenPluginManagerHelper );
- this.lifecycleExecutor = requireNonNull( lifecycleExecutor );
- this.pluginVersionResolver = requireNonNull( pluginVersionResolver );
+ public DefaultMavenReportExecutor(
+ MavenPluginManager mavenPluginManager,
+ MavenPluginManagerHelper mavenPluginManagerHelper,
+ LifecycleExecutor lifecycleExecutor,
+ PluginVersionResolver pluginVersionResolver) {
+ this.mavenPluginManager = requireNonNull(mavenPluginManager);
+ this.mavenPluginManagerHelper = requireNonNull(mavenPluginManagerHelper);
+ this.lifecycleExecutor = requireNonNull(lifecycleExecutor);
+ this.pluginVersionResolver = requireNonNull(pluginVersionResolver);
}
@Override
- public List<MavenReportExecution> buildMavenReports( MavenReportExecutorRequest mavenReportExecutorRequest )
- throws MojoExecutionException
- {
- if ( mavenReportExecutorRequest.getReportPlugins() == null )
- {
+ public List<MavenReportExecution> buildMavenReports(MavenReportExecutorRequest mavenReportExecutorRequest)
+ throws MojoExecutionException {
+ if (mavenReportExecutorRequest.getReportPlugins() == null) {
return Collections.emptyList();
}
@@ -155,125 +151,106 @@ public class DefaultMavenReportExecutor
List<MavenReportExecution> reportExecutions = new ArrayList<>();
String pluginKey = "";
- try
- {
- for ( ReportPlugin reportPlugin : mavenReportExecutorRequest.getReportPlugins() )
- {
+ try {
+ for (ReportPlugin reportPlugin : mavenReportExecutorRequest.getReportPlugins()) {
pluginKey = reportPlugin.getGroupId() + ':' + reportPlugin.getArtifactId();
- if ( !reportPluginKeys.add( pluginKey ) )
- {
- LOGGER.info( "Plugin {} will be executed more than one time", pluginKey );
+ if (!reportPluginKeys.add(pluginKey)) {
+ LOGGER.info("Plugin {} will be executed more than one time", pluginKey);
}
- reportExecutions.addAll( buildReportPlugin( mavenReportExecutorRequest, reportPlugin ) );
+ reportExecutions.addAll(buildReportPlugin(mavenReportExecutorRequest, reportPlugin));
}
- }
- catch ( Exception e )
- {
- throw new MojoExecutionException( "Failed to get report for " + pluginKey, e );
+ } catch (Exception e) {
+ throw new MojoExecutionException("Failed to get report for " + pluginKey, e);
}
return reportExecutions;
}
- protected List<MavenReportExecution> buildReportPlugin( MavenReportExecutorRequest mavenReportExecutorRequest,
- ReportPlugin reportPlugin )
- throws Exception
- {
+ protected List<MavenReportExecution> buildReportPlugin(
+ MavenReportExecutorRequest mavenReportExecutorRequest, ReportPlugin reportPlugin) throws Exception {
// step 1: prepare the plugin
Plugin plugin = new Plugin();
- plugin.setGroupId( reportPlugin.getGroupId() );
- plugin.setArtifactId( reportPlugin.getArtifactId() );
- plugin.setVersion( resolvePluginVersion( reportPlugin, mavenReportExecutorRequest ) );
- LOGGER.info( "Configuring report plugin {}", plugin.getId() );
+ plugin.setGroupId(reportPlugin.getGroupId());
+ plugin.setArtifactId(reportPlugin.getArtifactId());
+ plugin.setVersion(resolvePluginVersion(reportPlugin, mavenReportExecutorRequest));
+ LOGGER.info("Configuring report plugin {}", plugin.getId());
- mergePluginToReportPlugin( mavenReportExecutorRequest, plugin, reportPlugin );
+ mergePluginToReportPlugin(mavenReportExecutorRequest, plugin, reportPlugin);
PluginDescriptor pluginDescriptor =
- mavenPluginManagerHelper.getPluginDescriptor( plugin, mavenReportExecutorRequest.getMavenSession() );
+ mavenPluginManagerHelper.getPluginDescriptor(plugin, mavenReportExecutorRequest.getMavenSession());
// step 2: prepare the goals
List<GoalWithConf> goalsWithConfiguration = new ArrayList<>();
- boolean hasUserDefinedReports = prepareGoals( reportPlugin, pluginDescriptor, goalsWithConfiguration );
+ boolean hasUserDefinedReports = prepareGoals(reportPlugin, pluginDescriptor, goalsWithConfiguration);
// step 3: prepare the reports
- List<MavenReportExecution> reports = new ArrayList<>( goalsWithConfiguration.size() );
- for ( GoalWithConf report : goalsWithConfiguration )
- {
+ List<MavenReportExecution> reports = new ArrayList<>(goalsWithConfiguration.size());
+ for (GoalWithConf report : goalsWithConfiguration) {
MavenReportExecution mavenReportExecution =
- prepareReportExecution( mavenReportExecutorRequest, report, hasUserDefinedReports );
+ prepareReportExecution(mavenReportExecutorRequest, report, hasUserDefinedReports);
- if ( mavenReportExecution != null )
- {
+ if (mavenReportExecution != null) {
// ok, report is ready to generate
- reports.add( mavenReportExecution );
+ reports.add(mavenReportExecution);
}
}
- if ( !reports.isEmpty() )
- {
+ if (!reports.isEmpty()) {
// log reports, either configured or detected
StringBuilder buff = new StringBuilder();
- for ( MavenReportExecution mre : reports )
- {
- if ( buff.length() > 0 )
- {
- buff.append( ", " );
+ for (MavenReportExecution mre : reports) {
+ if (buff.length() > 0) {
+ buff.append(", ");
}
- buff.append( mre.getGoal() );
+ buff.append(mre.getGoal());
}
- LOGGER.info( "{} report{} {} for {}:{}: {}", reports.size(), ( reports.size() > 1 ? "s" : "" ),
- ( hasUserDefinedReports ? "configured" : "detected" ), plugin.getArtifactId(),
- plugin.getVersion(), buff );
+ LOGGER.info(
+ "{} report{} {} for {}:{}: {}",
+ reports.size(),
+ (reports.size() > 1 ? "s" : ""),
+ (hasUserDefinedReports ? "configured" : "detected"),
+ plugin.getArtifactId(),
+ plugin.getVersion(),
+ buff);
}
return reports;
}
- private boolean prepareGoals( ReportPlugin reportPlugin, PluginDescriptor pluginDescriptor,
- List<GoalWithConf> goalsWithConfiguration )
- {
- if ( reportPlugin.getReportSets().isEmpty() && reportPlugin.getReports().isEmpty() )
- {
+ private boolean prepareGoals(
+ ReportPlugin reportPlugin, PluginDescriptor pluginDescriptor, List<GoalWithConf> goalsWithConfiguration) {
+ if (reportPlugin.getReportSets().isEmpty() && reportPlugin.getReports().isEmpty()) {
// by default, use every goal, which will be filtered later to only keep reporting goals
List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
- for ( MojoDescriptor mojoDescriptor : mojoDescriptors )
- {
- goalsWithConfiguration.add( new GoalWithConf( reportPlugin, pluginDescriptor, mojoDescriptor.getGoal(),
- mojoDescriptor.getConfiguration() ) );
+ for (MojoDescriptor mojoDescriptor : mojoDescriptors) {
+ goalsWithConfiguration.add(new GoalWithConf(
+ reportPlugin, pluginDescriptor, mojoDescriptor.getGoal(), mojoDescriptor.getConfiguration()));
}
return false;
}
Set<String> goals = new HashSet<>();
- for ( String report : reportPlugin.getReports() )
- {
- if ( goals.add( report ) )
- {
- goalsWithConfiguration.add( new GoalWithConf( reportPlugin, pluginDescriptor, report,
- reportPlugin.getConfiguration() ) );
- }
- else
- {
- LOGGER.warn( "{} report is declared twice in default reports", report );
+ for (String report : reportPlugin.getReports()) {
+ if (goals.add(report)) {
+ goalsWithConfiguration.add(
+ new GoalWithConf(reportPlugin, pluginDescriptor, report, reportPlugin.getConfiguration()));
+ } else {
+ LOGGER.warn("{} report is declared twice in default reports", report);
}
}
- for ( ReportSet reportSet : reportPlugin.getReportSets() )
- {
+ for (ReportSet reportSet : reportPlugin.getReportSets()) {
goals = new HashSet<>();
- for ( String report : reportSet.getReports() )
- {
- if ( goals.add( report ) )
- {
- goalsWithConfiguration.add( new GoalWithConf( reportPlugin, pluginDescriptor, report,
- reportSet.getConfiguration() ) );
- }
- else
- {
- LOGGER.warn( "{} report is declared twice in {} reportSet", report, reportSet.getId() );
+ for (String report : reportSet.getReports()) {
+ if (goals.add(report)) {
+ goalsWithConfiguration.add(
+ new GoalWithConf(reportPlugin, pluginDescriptor, report, reportSet.getConfiguration()));
+ } else {
+ LOGGER.warn("{} report is declared twice in {} reportSet", report, reportSet.getId());
}
}
}
@@ -281,149 +258,132 @@ public class DefaultMavenReportExecutor
return true;
}
- private MavenReportExecution prepareReportExecution( MavenReportExecutorRequest mavenReportExecutorRequest,
- GoalWithConf report, boolean hasUserDefinedReports )
- throws Exception
- {
+ private MavenReportExecution prepareReportExecution(
+ MavenReportExecutorRequest mavenReportExecutorRequest, GoalWithConf report, boolean hasUserDefinedReports)
+ throws Exception {
ReportPlugin reportPlugin = report.getReportPlugin();
PluginDescriptor pluginDescriptor = report.getPluginDescriptor();
- MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( report.getGoal() );
- if ( mojoDescriptor == null )
- {
- throw new MojoNotFoundException( report.getGoal(), pluginDescriptor );
+ MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(report.getGoal());
+ if (mojoDescriptor == null) {
+ throw new MojoNotFoundException(report.getGoal(), pluginDescriptor);
}
MavenProject project = mavenReportExecutorRequest.getProject();
- if ( !hasUserDefinedReports && mojoDescriptor.isAggregator() && !canAggregate( project ) )
- {
+ if (!hasUserDefinedReports && mojoDescriptor.isAggregator() && !canAggregate(project)) {
// aggregator mojos automatically added from plugin are only run at execution root
return null;
}
- MojoExecution mojoExecution = new MojoExecution( pluginDescriptor.getPlugin(), report.getGoal(), null );
+ MojoExecution mojoExecution = new MojoExecution(pluginDescriptor.getPlugin(), report.getGoal(), null);
- mojoExecution.setMojoDescriptor( mojoDescriptor );
+ mojoExecution.setMojoDescriptor(mojoDescriptor);
- mavenPluginManagerHelper.setupPluginRealm( pluginDescriptor, mavenReportExecutorRequest.getMavenSession(),
- Thread.currentThread().getContextClassLoader(), IMPORTS,
- EXCLUDES );
+ mavenPluginManagerHelper.setupPluginRealm(
+ pluginDescriptor,
+ mavenReportExecutorRequest.getMavenSession(),
+ Thread.currentThread().getContextClassLoader(),
+ IMPORTS,
+ EXCLUDES);
- if ( !isMavenReport( mojoExecution, pluginDescriptor ) )
- {
- if ( hasUserDefinedReports )
- {
+ if (!isMavenReport(mojoExecution, pluginDescriptor)) {
+ if (hasUserDefinedReports) {
// reports were explicitly written in the POM
- LOGGER.warn( "Ignoring {}:{}"
- + " goal since it is not a report: should be removed from reporting configuration in POM",
- mojoExecution.getPlugin().getId(), report.getGoal() );
+ LOGGER.warn(
+ "Ignoring {}:{}"
+ + " goal since it is not a report: should be removed from reporting configuration in POM",
+ mojoExecution.getPlugin().getId(),
+ report.getGoal());
}
return null;
}
Xpp3Dom pluginMgmtConfiguration = null;
- if ( project.getBuild() != null && project.getBuild().getPluginManagement() != null )
- {
- Plugin pluginMgmt = find( reportPlugin, project.getBuild().getPluginManagement().getPlugins() );
+ if (project.getBuild() != null && project.getBuild().getPluginManagement() != null) {
+ Plugin pluginMgmt =
+ find(reportPlugin, project.getBuild().getPluginManagement().getPlugins());
- if ( pluginMgmt != null )
- {
+ if (pluginMgmt != null) {
pluginMgmtConfiguration = (Xpp3Dom) pluginMgmt.getConfiguration();
}
}
- mojoExecution.setConfiguration( mergeConfiguration( mojoDescriptor.getMojoConfiguration(),
- pluginMgmtConfiguration,
- reportPlugin.getConfiguration(),
- report.getConfiguration(),
- mojoDescriptor.getParameterMap().keySet() ) );
+ mojoExecution.setConfiguration(mergeConfiguration(
+ mojoDescriptor.getMojoConfiguration(),
+ pluginMgmtConfiguration,
+ reportPlugin.getConfiguration(),
+ report.getConfiguration(),
+ mojoDescriptor.getParameterMap().keySet()));
- MavenReport mavenReport =
- getConfiguredMavenReport( mojoExecution, pluginDescriptor, mavenReportExecutorRequest );
+ MavenReport mavenReport = getConfiguredMavenReport(mojoExecution, pluginDescriptor, mavenReportExecutorRequest);
- MavenReportExecution mavenReportExecution =
- new MavenReportExecution( report.getGoal(), mojoExecution.getPlugin(), mavenReport,
- pluginDescriptor.getClassRealm() );
+ MavenReportExecution mavenReportExecution = new MavenReportExecution(
+ report.getGoal(), mojoExecution.getPlugin(), mavenReport, pluginDescriptor.getClassRealm());
- lifecycleExecutor.calculateForkedExecutions( mojoExecution,
- mavenReportExecutorRequest.getMavenSession() );
+ lifecycleExecutor.calculateForkedExecutions(mojoExecution, mavenReportExecutorRequest.getMavenSession());
- if ( !mojoExecution.getForkedExecutions().isEmpty() )
- {
+ if (!mojoExecution.getForkedExecutions().isEmpty()) {
String reportDescription = pluginDescriptor.getArtifactId() + ":" + report.getGoal() + " report";
String execution;
- if ( StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() ) )
- {
+ if (StringUtils.isNotEmpty(mojoDescriptor.getExecutePhase())) {
// forked phase
execution = "'"
- + ( StringUtils.isEmpty( mojoDescriptor.getExecuteLifecycle() ) ? ""
- : ( '[' + mojoDescriptor.getExecuteLifecycle() + ']' ) )
- + mojoDescriptor.getExecutePhase() + "' forked phase execution";
- }
- else
- {
+ + (StringUtils.isEmpty(mojoDescriptor.getExecuteLifecycle())
+ ? ""
+ : ('[' + mojoDescriptor.getExecuteLifecycle() + ']'))
+ + mojoDescriptor.getExecutePhase() + "' forked phase execution";
+ } else {
// forked goal
execution = "'" + mojoDescriptor.getExecuteGoal() + "' forked goal execution";
}
- LOGGER.info( "Preparing {} requires {}", reportDescription, execution );
+ LOGGER.info("Preparing {} requires {}", reportDescription, execution);
- lifecycleExecutor.executeForkedExecutions( mojoExecution,
- mavenReportExecutorRequest.getMavenSession() );
+ lifecycleExecutor.executeForkedExecutions(mojoExecution, mavenReportExecutorRequest.getMavenSession());
- LOGGER.info( "{} for {} preparation done", execution, reportDescription );
+ LOGGER.info("{} for {} preparation done", execution, reportDescription);
}
return mavenReportExecution;
}
- private boolean canAggregate( MavenProject project )
- {
- return project.isExecutionRoot() && "pom".equals( project.getPackaging() ) && ( project.getModules() != null )
- && !project.getModules().isEmpty();
+ private boolean canAggregate(MavenProject project) {
+ return project.isExecutionRoot()
+ && "pom".equals(project.getPackaging())
+ && (project.getModules() != null)
+ && !project.getModules().isEmpty();
}
- private MavenReport getConfiguredMavenReport( MojoExecution mojoExecution, PluginDescriptor pluginDescriptor,
- MavenReportExecutorRequest mavenReportExecutorRequest )
- throws PluginContainerException, PluginConfigurationException
- {
- try
- {
- Mojo mojo =
- mavenPluginManager.getConfiguredMojo( Mojo.class, mavenReportExecutorRequest.getMavenSession(),
- mojoExecution );
+ private MavenReport getConfiguredMavenReport(
+ MojoExecution mojoExecution,
+ PluginDescriptor pluginDescriptor,
+ MavenReportExecutorRequest mavenReportExecutorRequest)
+ throws PluginContainerException, PluginConfigurationException {
+ try {
+ Mojo mojo = mavenPluginManager.getConfiguredMojo(
+ Mojo.class, mavenReportExecutorRequest.getMavenSession(), mojoExecution);
return (MavenReport) mojo;
- }
- catch ( ClassCastException e )
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.warn( "Skipping ClassCastException", e );
- }
- else
- {
- LOGGER.warn( "Skipping ClassCastException" );
+ } catch (ClassCastException e) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.warn("Skipping ClassCastException", e);
+ } else {
+ LOGGER.warn("Skipping ClassCastException");
}
return null;
- }
- catch ( PluginContainerException e )
- {
+ } catch (PluginContainerException e) {
/*
* ignore old plugin which are using removed PluginRegistry [INFO] Caused by:
* java.lang.NoClassDefFoundError: org/apache/maven/plugin/registry/PluginRegistry
*/
- if ( e.getCause() != null && e.getCause() instanceof NoClassDefFoundError
- && e.getMessage().contains( "PluginRegistry" ) )
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.warn( "Skipping NoClassDefFoundError with PluginRegistry", e );
- }
- else
- {
- LOGGER.warn( "Skipping NoClassDefFoundError with PluginRegistry" );
+ if (e.getCause() != null
+ && e.getCause() instanceof NoClassDefFoundError
+ && e.getMessage().contains("PluginRegistry")) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.warn("Skipping NoClassDefFoundError with PluginRegistry", e);
+ } else {
+ LOGGER.warn("Skipping NoClassDefFoundError with PluginRegistry");
}
return null;
}
@@ -431,75 +391,62 @@ public class DefaultMavenReportExecutor
}
}
- private boolean isMavenReport( MojoExecution mojoExecution, PluginDescriptor pluginDescriptor )
- {
+ private boolean isMavenReport(MojoExecution mojoExecution, PluginDescriptor pluginDescriptor) {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
// get the plugin's goal Mojo class
Class<?> mojoClass;
- try
- {
- Thread.currentThread().setContextClassLoader( mojoExecution.getMojoDescriptor().getRealm() );
-
- mojoClass =
- pluginDescriptor.getClassRealm().loadClass( mojoExecution.getMojoDescriptor().getImplementation() );
- }
- catch ( ClassNotFoundException e )
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.warn( "Skipping ClassNotFoundException mojoExecution.goal {}", mojoExecution.getGoal(), e );
- }
- else
- {
- LOGGER.warn( "Skipping ClassNotFoundException mojoExecution.goal {}", mojoExecution.getGoal() );
+ try {
+ Thread.currentThread()
+ .setContextClassLoader(mojoExecution.getMojoDescriptor().getRealm());
+
+ mojoClass = pluginDescriptor
+ .getClassRealm()
+ .loadClass(mojoExecution.getMojoDescriptor().getImplementation());
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.warn("Skipping ClassNotFoundException mojoExecution.goal {}", mojoExecution.getGoal(), e);
+ } else {
+ LOGGER.warn("Skipping ClassNotFoundException mojoExecution.goal {}", mojoExecution.getGoal());
}
return false;
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( originalClassLoader );
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
// check if it is a report
- try
- {
- Thread.currentThread().setContextClassLoader( mojoExecution.getMojoDescriptor().getRealm() );
- MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoExecution.getGoal() );
-
- boolean isMavenReport = MavenReport.class.isAssignableFrom( mojoClass );
-
- if ( LOGGER.isDebugEnabled() )
- {
- if ( mojoDescriptor != null && mojoDescriptor.getImplementationClass() != null )
- {
- LOGGER.debug( "Class {} is MavenReport: ",
- mojoDescriptor.getImplementationClass().getName(), isMavenReport );
+ try {
+ Thread.currentThread()
+ .setContextClassLoader(mojoExecution.getMojoDescriptor().getRealm());
+ MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(mojoExecution.getGoal());
+
+ boolean isMavenReport = MavenReport.class.isAssignableFrom(mojoClass);
+
+ if (LOGGER.isDebugEnabled()) {
+ if (mojoDescriptor != null && mojoDescriptor.getImplementationClass() != null) {
+ LOGGER.debug(
+ "Class {} is MavenReport: ",
+ mojoDescriptor.getImplementationClass().getName(),
+ isMavenReport);
}
- if ( !isMavenReport )
- {
- LOGGER.debug( "Skipping non MavenReport {}", mojoExecution.getMojoDescriptor().getId() );
+ if (!isMavenReport) {
+ LOGGER.debug(
+ "Skipping non MavenReport {}",
+ mojoExecution.getMojoDescriptor().getId());
}
}
return isMavenReport;
- }
- catch ( LinkageError e )
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.warn( "Skipping LinkageError mojoExecution.goal {}", mojoExecution.getGoal(), e );
- }
- else
- {
- LOGGER.warn( "Skipping LinkageError mojoExecution.goal {}", mojoExecution.getGoal() );
+ } catch (LinkageError e) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.warn("Skipping LinkageError mojoExecution.goal {}", mojoExecution.getGoal(), e);
+ } else {
+ LOGGER.warn("Skipping LinkageError mojoExecution.goal {}", mojoExecution.getGoal());
}
return false;
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( originalClassLoader );
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
@@ -514,32 +461,30 @@ public class DefaultMavenReportExecutor
* @param parameters set of supported parameters: any other parameter will be removed
* @return the effective configuration to be used
*/
- private Xpp3Dom mergeConfiguration( PlexusConfiguration mojoConf, Xpp3Dom pluginMgmtConfig,
- PlexusConfiguration pluginConf, PlexusConfiguration reportSetConf,
- Set<String> parameters )
- {
- Xpp3Dom mojoConfig = ( mojoConf != null ) ? convert( mojoConf ) : new Xpp3Dom( "configuration" );
+ private Xpp3Dom mergeConfiguration(
+ PlexusConfiguration mojoConf,
+ Xpp3Dom pluginMgmtConfig,
+ PlexusConfiguration pluginConf,
+ PlexusConfiguration reportSetConf,
+ Set<String> parameters) {
+ Xpp3Dom mojoConfig = (mojoConf != null) ? convert(mojoConf) : new Xpp3Dom("configuration");
- if ( pluginMgmtConfig != null || pluginConf != null || reportSetConf != null )
- {
- Xpp3Dom pluginConfig = ( pluginConf == null ) ? new Xpp3Dom( "fake" ) : convert( pluginConf );
+ if (pluginMgmtConfig != null || pluginConf != null || reportSetConf != null) {
+ Xpp3Dom pluginConfig = (pluginConf == null) ? new Xpp3Dom("fake") : convert(pluginConf);
// merge pluginConf into reportSetConf
- Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom( convert( reportSetConf ), pluginConfig );
+ Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(convert(reportSetConf), pluginConfig);
// then merge pluginMgmtConfig
- mergedConfig = Xpp3DomUtils.mergeXpp3Dom( mergedConfig, pluginMgmtConfig );
+ mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, pluginMgmtConfig);
// then merge mojoConf
- mergedConfig = Xpp3DomUtils.mergeXpp3Dom( mergedConfig, mojoConfig );
+ mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, mojoConfig);
// clean result
- Xpp3Dom cleanedConfig = new Xpp3Dom( "configuration" );
- if ( mergedConfig.getChildren() != null )
- {
- for ( Xpp3Dom parameter : mergedConfig.getChildren() )
- {
- if ( parameters.contains( parameter.getName() ) )
- {
- cleanedConfig.addChild( parameter );
+ Xpp3Dom cleanedConfig = new Xpp3Dom("configuration");
+ if (mergedConfig.getChildren() != null) {
+ for (Xpp3Dom parameter : mergedConfig.getChildren()) {
+ if (parameters.contains(parameter.getName())) {
+ cleanedConfig.addChild(parameter);
}
}
}
@@ -550,24 +495,20 @@ public class DefaultMavenReportExecutor
return mojoConfig;
}
- private Xpp3Dom convert( PlexusConfiguration config )
- {
- if ( config == null )
- {
+ private Xpp3Dom convert(PlexusConfiguration config) {
+ if (config == null) {
return null;
}
- Xpp3Dom dom = new Xpp3Dom( config.getName() );
- dom.setValue( config.getValue( null ) );
+ Xpp3Dom dom = new Xpp3Dom(config.getName());
+ dom.setValue(config.getValue(null));
- for ( String attrib : config.getAttributeNames() )
- {
- dom.setAttribute( attrib, config.getAttribute( attrib, null ) );
+ for (String attrib : config.getAttributeNames()) {
+ dom.setAttribute(attrib, config.getAttribute(attrib, null));
}
- for ( int n = config.getChildCount(), i = 0; i < n; i++ )
- {
- dom.addChild( convert( config.getChild( i ) ) );
+ for (int n = config.getChildCount(), i = 0; i < n; i++) {
+ dom.addChild(convert(config.getChild(i)));
}
return dom;
@@ -589,66 +530,65 @@ public class DefaultMavenReportExecutor
* @return the report plugin version
* @throws PluginVersionResolutionException on plugin version resolution issue
*/
- protected String resolvePluginVersion( ReportPlugin reportPlugin,
- MavenReportExecutorRequest mavenReportExecutorRequest )
- throws PluginVersionResolutionException
- {
+ protected String resolvePluginVersion(
+ ReportPlugin reportPlugin, MavenReportExecutorRequest mavenReportExecutorRequest)
+ throws PluginVersionResolutionException {
String reportPluginKey = reportPlugin.getGroupId() + ':' + reportPlugin.getArtifactId();
- LOGGER.debug( "Resolving version for {}", reportPluginKey );
+ LOGGER.debug("Resolving version for {}", reportPluginKey);
// look for version defined in the reportPlugin configuration
- if ( reportPlugin.getVersion() != null )
- {
- LOGGER.debug( "Resolved {} version from the reporting.plugins section: {}",
- reportPluginKey, reportPlugin.getVersion() );
+ if (reportPlugin.getVersion() != null) {
+ LOGGER.debug(
+ "Resolved {} version from the reporting.plugins section: {}",
+ reportPluginKey,
+ reportPlugin.getVersion());
return reportPlugin.getVersion();
}
MavenProject project = mavenReportExecutorRequest.getProject();
// search in the build section
- if ( project.getBuild() != null )
- {
- Plugin plugin = find( reportPlugin, project.getBuild().getPlugins() );
-
- if ( plugin != null && plugin.getVersion() != null )
- {
- LOGGER.debug( "Resolved {} version from the build.plugins section: {}",
- reportPluginKey, plugin.getVersion() );
+ if (project.getBuild() != null) {
+ Plugin plugin = find(reportPlugin, project.getBuild().getPlugins());
+
+ if (plugin != null && plugin.getVersion() != null) {
+ LOGGER.debug(
+ "Resolved {} version from the build.plugins section: {}", reportPluginKey, plugin.getVersion());
return plugin.getVersion();
}
}
// search in pluginManagement section
- if ( project.getBuild() != null && project.getBuild().getPluginManagement() != null )
- {
- Plugin plugin = find( reportPlugin, project.getBuild().getPluginManagement().getPlugins() );
-
- if ( plugin != null && plugin.getVersion() != null )
- {
- LOGGER.debug( "Resolved {} version from the build.pluginManagement.plugins section: {}",
- reportPluginKey, plugin.getVersion() );
+ if (project.getBuild() != null && project.getBuild().getPluginManagement() != null) {
+ Plugin plugin =
+ find(reportPlugin, project.getBuild().getPluginManagement().getPlugins());
+
+ if (plugin != null && plugin.getVersion() != null) {
+ LOGGER.debug(
+ "Resolved {} version from the build.pluginManagement.plugins section: {}",
+ reportPluginKey,
+ plugin.getVersion());
return plugin.getVersion();
}
}
- LOGGER.warn( "Report plugin {} has an empty version.", reportPluginKey );
- LOGGER.warn( "" );
- LOGGER.warn( "It is highly recommended to fix these problems"
- + " because they threaten the stability of your build." );
- LOGGER.warn( "" );
- LOGGER.warn( "For this reason, future Maven versions might no"
- + " longer support building such malformed projects." );
+ LOGGER.warn("Report plugin {} has an empty version.", reportPluginKey);
+ LOGGER.warn("");
+ LOGGER.warn("It is highly recommended to fix these problems"
+ + " because they threaten the stability of your build.");
+ LOGGER.warn("");
+ LOGGER.warn("For this reason, future Maven versions might no"
+ + " longer support building such malformed projects.");
Plugin plugin = new Plugin();
- plugin.setGroupId( reportPlugin.getGroupId() );
- plugin.setArtifactId( reportPlugin.getArtifactId() );
+ plugin.setGroupId(reportPlugin.getGroupId());
+ plugin.setArtifactId(reportPlugin.getArtifactId());
PluginVersionRequest pluginVersionRequest =
- new DefaultPluginVersionRequest( plugin, mavenReportExecutorRequest.getMavenSession() );
+ new DefaultPluginVersionRequest(plugin, mavenReportExecutorRequest.getMavenSession());
- PluginVersionResult result = pluginVersionResolver.resolve( pluginVersionRequest );
- LOGGER.debug( "Resolved {} version from repository: {}", reportPluginKey, result.getVersion() );
+ PluginVersionResult result = pluginVersionResolver.resolve(pluginVersionRequest);
+ LOGGER.debug("Resolved {} version from repository: {}", reportPluginKey, result.getVersion());
return result.getVersion();
}
@@ -659,17 +599,13 @@ public class DefaultMavenReportExecutor
* @param plugins the candidate plugins
* @return the first similar plugin
*/
- private Plugin find( ReportPlugin reportPlugin, List<Plugin> plugins )
- {
- if ( plugins == null )
- {
+ private Plugin find(ReportPlugin reportPlugin, List<Plugin> plugins) {
+ if (plugins == null) {
return null;
}
- for ( Plugin plugin : plugins )
- {
- if ( Objects.equals( plugin.getArtifactId(), reportPlugin.getArtifactId() )
- && Objects.equals( plugin.getGroupId(), reportPlugin.getGroupId() ) )
- {
+ for (Plugin plugin : plugins) {
+ if (Objects.equals(plugin.getArtifactId(), reportPlugin.getArtifactId())
+ && Objects.equals(plugin.getGroupId(), reportPlugin.getGroupId())) {
return plugin;
}
}
@@ -691,26 +627,21 @@ public class DefaultMavenReportExecutor
* @param buildPlugin
* @param reportPlugin
*/
- private void mergePluginToReportPlugin( MavenReportExecutorRequest mavenReportExecutorRequest, Plugin buildPlugin,
- ReportPlugin reportPlugin )
- {
+ private void mergePluginToReportPlugin(
+ MavenReportExecutorRequest mavenReportExecutorRequest, Plugin buildPlugin, ReportPlugin reportPlugin) {
Build build = mavenReportExecutorRequest.getProject().getBuild();
- Plugin configuredPlugin = find( reportPlugin, build.getPlugins() );
- if ( configuredPlugin == null && build.getPluginManagement() != null )
- {
- configuredPlugin = find( reportPlugin, build.getPluginManagement().getPlugins() );
+ Plugin configuredPlugin = find(reportPlugin, build.getPlugins());
+ if (configuredPlugin == null && build.getPluginManagement() != null) {
+ configuredPlugin = find(reportPlugin, build.getPluginManagement().getPlugins());
}
- if ( configuredPlugin != null )
- {
- if ( !configuredPlugin.getDependencies().isEmpty() )
- {
- buildPlugin.getDependencies().addAll( configuredPlugin.getDependencies() );
+ if (configuredPlugin != null) {
+ if (!configuredPlugin.getDependencies().isEmpty()) {
+ buildPlugin.getDependencies().addAll(configuredPlugin.getDependencies());
}
}
}
- private static class GoalWithConf
- {
+ private static class GoalWithConf {
private final String goal;
private final PlexusConfiguration configuration;
@@ -719,32 +650,30 @@ public class DefaultMavenReportExecutor
private final PluginDescriptor pluginDescriptor;
- GoalWithConf( ReportPlugin reportPlugin, PluginDescriptor pluginDescriptor, String goal,
- PlexusConfiguration configuration )
- {
+ GoalWithConf(
+ ReportPlugin reportPlugin,
+ PluginDescriptor pluginDescriptor,
+ String goal,
+ PlexusConfiguration configuration) {
this.reportPlugin = reportPlugin;
this.pluginDescriptor = pluginDescriptor;
this.goal = goal;
this.configuration = configuration;
}
- public ReportPlugin getReportPlugin()
- {
+ public ReportPlugin getReportPlugin() {
return reportPlugin;
}
- public PluginDescriptor getPluginDescriptor()
- {
+ public PluginDescriptor getPluginDescriptor() {
return pluginDescriptor;
}
- public String getGoal()
- {
+ public String getGoal() {
return goal;
}
- public PlexusConfiguration getConfiguration()
- {
+ public PlexusConfiguration getConfiguration() {
return configuration;
}
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/MavenPluginManagerHelper.java b/src/main/java/org/apache/maven/reporting/exec/MavenPluginManagerHelper.java
index bc1f8e0..7508008 100644
--- a/src/main/java/org/apache/maven/reporting/exec/MavenPluginManagerHelper.java
+++ b/src/main/java/org/apache/maven/reporting/exec/MavenPluginManagerHelper.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import java.util.List;
@@ -33,16 +32,15 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
* {@link org.apache.maven.plugin.MavenPluginManager} helper to deal with API changes between Maven 3.0.x and 3.1.x, ie
* switch from Sonatype Aether (in <code>org.sonatype.aether</code> package) to Eclipse Aether (in
* <code>org.eclipse.aether</code> package) for some parameters.
- *
+ *
* @author Hervé Boutemy
* @since 1.1
*/
-public interface MavenPluginManagerHelper
-{
+public interface MavenPluginManagerHelper {
/**
* Helper for {@link org.apache.maven.plugin.MavenPluginManager#getPluginDescriptor
* MavenPluginManager#getPluginDescriptor(Plugin, List, xxx.aether.RepositorySystemSession)}
- *
+ *
* @param plugin the plugin
* @param session the session
* @return the plugin descriptor
@@ -50,13 +48,13 @@ public interface MavenPluginManagerHelper
* @throws PluginDescriptorParsingException on descriptor parsing issue
* @throws InvalidPluginDescriptorException on invalid descriptor
*/
- PluginDescriptor getPluginDescriptor( Plugin plugin, MavenSession session )
- throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException;
+ PluginDescriptor getPluginDescriptor(Plugin plugin, MavenSession session)
+ throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException;
/**
* Helper for {@link org.apache.maven.plugin.MavenPluginManager#setupPluginRealm
* MavenPluginManager#setupPluginRealm(PluginDescriptor, ..., List, xxx.aether.graph.DependencyFilter)}
- *
+ *
* @param pluginDescriptor the plugin descriptor
* @param session the session
* @param parent the parent classloader
@@ -65,7 +63,11 @@ public interface MavenPluginManagerHelper
* @throws PluginResolutionException on resolution issue
* @throws PluginContainerException on issue with configuration
*/
- void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,
- List<String> imports, List<String> excludeArtifactIds )
- throws PluginResolutionException, PluginContainerException;
+ void setupPluginRealm(
+ PluginDescriptor pluginDescriptor,
+ MavenSession session,
+ ClassLoader parent,
+ List<String> imports,
+ List<String> excludeArtifactIds)
+ throws PluginResolutionException, PluginContainerException;
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecution.java b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecution.java
index de0205c..77a77da 100644
--- a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecution.java
+++ b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecution.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import org.apache.maven.model.Plugin;
import org.apache.maven.reporting.MavenReport;
@@ -32,7 +31,7 @@ import org.apache.maven.reporting.MavenReport;
* <li>the goal name associated to the report,</li>
* <li>the associated {@link ClassLoader} for the report generation,</li>
* <li>the {@link Plugin} associated to the {@link MavenReport}.</li>
- * </ul>
+ * </ul>
* <p>
* With this bean, a plugin wanting to generate a report (= <i>"execute"</i> the report) has to call the
* {@link MavenReport#generate(org.apache.maven.doxia.sink.Sink, java.util.Locale)}
@@ -41,11 +40,10 @@ import org.apache.maven.reporting.MavenReport;
* <p>
* This bean is instantiated by {@link MavenReportExecutor}.
* </p>
- *
+ *
* @author Olivier Lamy
*/
-public class MavenReportExecution
-{
+public class MavenReportExecution {
private MavenReport mavenReport;
private ClassLoader classLoader;
@@ -54,81 +52,65 @@ public class MavenReportExecution
private final String goal;
- public MavenReportExecution( String goal, Plugin plugin, MavenReport mavenReport, ClassLoader classLoader )
- {
+ public MavenReportExecution(String goal, Plugin plugin, MavenReport mavenReport, ClassLoader classLoader) {
this.goal = goal;
- this.setPlugin( plugin );
+ this.setPlugin(plugin);
this.mavenReport = mavenReport;
this.classLoader = classLoader;
}
- public MavenReportExecution( Plugin plugin, MavenReport mavenReport, ClassLoader classLoader )
- {
- this( null, plugin, mavenReport, classLoader );
+ public MavenReportExecution(Plugin plugin, MavenReport mavenReport, ClassLoader classLoader) {
+ this(null, plugin, mavenReport, classLoader);
}
- public MavenReportExecution( MavenReport mavenReport )
- {
- this( null, null, mavenReport, null );
+ public MavenReportExecution(MavenReport mavenReport) {
+ this(null, null, mavenReport, null);
}
/**
* execute Maven Report's <code>canGenerate()</code> with adequate classloader.
* @return Maven Report's <code>canGenerate()</code> result
*/
- public boolean canGenerateReport()
- {
+ public boolean canGenerateReport() {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- if ( classLoader != null )
- {
- Thread.currentThread().setContextClassLoader( classLoader );
+ try {
+ if (classLoader != null) {
+ Thread.currentThread().setContextClassLoader(classLoader);
}
return mavenReport.canGenerateReport();
- }
- finally
- {
- if ( classLoader != null )
- {
- Thread.currentThread().setContextClassLoader( originalClassLoader );
+ } finally {
+ if (classLoader != null) {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- }
+ }
}
- public MavenReport getMavenReport()
- {
+ public MavenReport getMavenReport() {
return mavenReport;
}
- public void setMavenReport( MavenReport mavenReport )
- {
+ public void setMavenReport(MavenReport mavenReport) {
this.mavenReport = mavenReport;
}
- public ClassLoader getClassLoader()
- {
+ public ClassLoader getClassLoader() {
return classLoader;
}
- public void setClassLoader( ClassLoader classLoader )
- {
+ public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
- public void setPlugin( Plugin plugin )
- {
+ public void setPlugin(Plugin plugin) {
this.plugin = plugin;
}
- public Plugin getPlugin()
- {
+ public Plugin getPlugin() {
return plugin;
}
- public String getGoal()
- {
+ public String getGoal() {
return goal;
}
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutor.java b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutor.java
index 36db32c..65f2572 100644
--- a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutor.java
+++ b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutor.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import java.util.List;
@@ -34,15 +33,14 @@ import org.apache.maven.plugin.MojoExecutionException;
*
* @author Olivier Lamy
*/
-public interface MavenReportExecutor
-{
+public interface MavenReportExecutor {
/**
- * Build the {@link org.apache.maven.reporting.MavenReport}s, with associated forked executions if necessary.
- *
+ * Build the {@link org.apache.maven.reporting.MavenReport}s, with associated forked executions if necessary.
+ *
* @param mavenReportExecutorRequest the request
* @return a list or prepared Maven report executions
* @throws MojoExecutionException on report execution issue
*/
- List<MavenReportExecution> buildMavenReports( MavenReportExecutorRequest mavenReportExecutorRequest )
- throws MojoExecutionException;
+ List<MavenReportExecution> buildMavenReports(MavenReportExecutorRequest mavenReportExecutorRequest)
+ throws MojoExecutionException;
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutorRequest.java b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutorRequest.java
index 7c9199c..f538330 100644
--- a/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutorRequest.java
+++ b/src/main/java/org/apache/maven/reporting/exec/MavenReportExecutorRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import java.util.ArrayList;
import java.util.List;
@@ -34,8 +33,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
*
* @author Olivier Lamy
*/
-public class MavenReportExecutorRequest
-{
+public class MavenReportExecutorRequest {
private ArtifactRepository localRepository;
private MavenSession mavenSession;
@@ -44,43 +42,35 @@ public class MavenReportExecutorRequest
private ReportPlugin[] reportPlugins;
- public ArtifactRepository getLocalRepository()
- {
+ public ArtifactRepository getLocalRepository() {
return localRepository;
}
- public void setLocalRepository( ArtifactRepository localRepository )
- {
+ public void setLocalRepository(ArtifactRepository localRepository) {
this.localRepository = localRepository;
}
- public MavenSession getMavenSession()
- {
+ public MavenSession getMavenSession() {
return mavenSession;
}
- public void setMavenSession( MavenSession mavenSession )
- {
+ public void setMavenSession(MavenSession mavenSession) {
this.mavenSession = mavenSession;
}
- public MavenProject getProject()
- {
+ public MavenProject getProject() {
return project;
}
- public void setProject( MavenProject project )
- {
+ public void setProject(MavenProject project) {
this.project = project;
}
- public ReportPlugin[] getReportPlugins()
- {
+ public ReportPlugin[] getReportPlugins() {
return reportPlugins;
}
- public void setReportPlugins( ReportPlugin[] reportPlugins )
- {
+ public void setReportPlugins(ReportPlugin[] reportPlugins) {
this.reportPlugins = reportPlugins;
}
@@ -90,35 +80,30 @@ public class MavenReportExecutorRequest
* @param reportPlugins the report plugins from <code><reporting></code> section
* @since 1.4
*/
- public void setReportPlugins( org.apache.maven.model.ReportPlugin[] reportPlugins )
- {
- setReportPlugins( new ReportPlugin[reportPlugins.length] );
+ public void setReportPlugins(org.apache.maven.model.ReportPlugin[] reportPlugins) {
+ setReportPlugins(new ReportPlugin[reportPlugins.length]);
int i = 0;
- for ( org.apache.maven.model.ReportPlugin r : reportPlugins )
- {
+ for (org.apache.maven.model.ReportPlugin r : reportPlugins) {
ReportPlugin p = new ReportPlugin();
- p.setGroupId( r.getGroupId() );
- p.setArtifactId( r.getArtifactId() );
- p.setVersion( r.getVersion() );
- if ( r.getConfiguration() != null )
- {
- p.setConfiguration( new XmlPlexusConfiguration( (Xpp3Dom) r.getConfiguration() ) );
+ p.setGroupId(r.getGroupId());
+ p.setArtifactId(r.getArtifactId());
+ p.setVersion(r.getVersion());
+ if (r.getConfiguration() != null) {
+ p.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) r.getConfiguration()));
}
List<ReportSet> prs = new ArrayList<>();
- for ( org.apache.maven.model.ReportSet rs : r.getReportSets() )
- {
+ for (org.apache.maven.model.ReportSet rs : r.getReportSets()) {
ReportSet ps = new ReportSet();
- ps.setId( rs.getId() );
- ps.setReports( rs.getReports() );
- if ( rs.getConfiguration() != null )
- {
- ps.setConfiguration( new XmlPlexusConfiguration( (Xpp3Dom) rs.getConfiguration() ) );
+ ps.setId(rs.getId());
+ ps.setReports(rs.getReports());
+ if (rs.getConfiguration() != null) {
+ ps.setConfiguration(new XmlPlexusConfiguration((Xpp3Dom) rs.getConfiguration()));
}
- prs.add( ps );
+ prs.add(ps);
}
- p.setReportSets( prs );
+ p.setReportSets(prs);
this.reportPlugins[i++] = p;
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/ReportPlugin.java b/src/main/java/org/apache/maven/reporting/exec/ReportPlugin.java
index b2eba53..77395d6 100644
--- a/src/main/java/org/apache/maven/reporting/exec/ReportPlugin.java
+++ b/src/main/java/org/apache/maven/reporting/exec/ReportPlugin.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import java.util.ArrayList;
import java.util.Collections;
@@ -31,8 +30,7 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
* some values are copied.
* @see org.apache.maven.model.ReportPlugin
*/
-class ReportPlugin
-{
+class ReportPlugin {
private String groupId = "org.apache.maven.plugins";
private String artifactId;
@@ -42,78 +40,64 @@ class ReportPlugin
private PlexusConfiguration configuration;
private List<ReportSet> reportSets;
-
+
private List<String> reports;
- public String getGroupId()
- {
+ public String getGroupId() {
return this.groupId;
}
- public void setGroupId( String groupId )
- {
+ public void setGroupId(String groupId) {
this.groupId = groupId;
}
- public String getArtifactId()
- {
+ public String getArtifactId() {
return this.artifactId;
}
- public void setArtifactId( String artifactId )
- {
+ public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
- public String getVersion()
- {
+ public String getVersion() {
return this.version;
}
- public void setVersion( String version )
- {
+ public void setVersion(String version) {
this.version = version;
}
- public PlexusConfiguration getConfiguration()
- {
+ public PlexusConfiguration getConfiguration() {
return this.configuration;
}
- public void setConfiguration( PlexusConfiguration configuration )
- {
+ public void setConfiguration(PlexusConfiguration configuration) {
this.configuration = configuration;
}
- public List<ReportSet> getReportSets()
- {
- if ( this.reportSets == null )
- {
+ public List<ReportSet> getReportSets() {
+ if (this.reportSets == null) {
this.reportSets = new ArrayList<>();
}
return this.reportSets;
}
- public void setReportSets( List<ReportSet> reportSets )
- {
+ public void setReportSets(List<ReportSet> reportSets) {
this.reportSets = reportSets;
}
- public List<String> getReports()
- {
+ public List<String> getReports() {
return reports == null ? Collections.<String>emptyList() : reports;
}
- public void setReports( List<String> reports )
- {
+ public void setReports(List<String> reports) {
this.reports = reports;
}
@Override
- public String toString()
- {
- return "ReportPlugin(" + artifactId + "){version='" + version + "', reports=" + reports
- + ", reportSets=" + reportSets + "}";
+ public String toString() {
+ return "ReportPlugin(" + artifactId + "){version='" + version + "', reports=" + reports + ", reportSets="
+ + reportSets + "}";
}
}
diff --git a/src/main/java/org/apache/maven/reporting/exec/ReportSet.java b/src/main/java/org/apache/maven/reporting/exec/ReportSet.java
index 9414a92..e346522 100644
--- a/src/main/java/org/apache/maven/reporting/exec/ReportSet.java
+++ b/src/main/java/org/apache/maven/reporting/exec/ReportSet.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
import java.util.ArrayList;
import java.util.List;
@@ -28,8 +27,7 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
* Represents a set of reports and a configuration to be used to generate them.
* @see org.apache.maven.model.ReportSet
*/
-class ReportSet
-{
+class ReportSet {
private String id = "default";
@@ -37,45 +35,36 @@ class ReportSet
private List<String> reports;
- public String getId()
- {
+ public String getId() {
return this.id;
}
- public void setId( String id )
- {
+ public void setId(String id) {
this.id = id;
}
- public PlexusConfiguration getConfiguration()
- {
+ public PlexusConfiguration getConfiguration() {
return this.configuration;
}
- public void setConfiguration( PlexusConfiguration configuration )
- {
+ public void setConfiguration(PlexusConfiguration configuration) {
this.configuration = configuration;
}
- public List<String> getReports()
- {
- if ( this.reports == null )
- {
+ public List<String> getReports() {
+ if (this.reports == null) {
this.reports = new ArrayList<>();
}
return this.reports;
}
- public void setReports( List<String> reports )
- {
+ public void setReports(List<String> reports) {
this.reports = reports;
}
@Override
- public String toString()
- {
+ public String toString() {
return "ReportSet{id='" + getId() + "', reports=" + reports + "}";
}
-
}
diff --git a/src/main/java/org/codehaus/doxia/sink/Sink.java b/src/main/java/org/codehaus/doxia/sink/Sink.java
index 0fe64cf..fe8e91c 100644
--- a/src/main/java/org/codehaus/doxia/sink/Sink.java
+++ b/src/main/java/org/codehaus/doxia/sink/Sink.java
@@ -1,5 +1,3 @@
-package org.codehaus.doxia.sink;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,14 +16,13 @@ package org.codehaus.doxia.sink;
* specific language governing permissions and limitations
* under the License.
*/
+package org.codehaus.doxia.sink;
/**
* Generic document processing interface.
*
* @deprecated use {@link org.apache.maven.doxia.sink.Sink} instead (since 1.0-alpha-6).
*/
-public interface Sink
- extends org.apache.maven.doxia.sink.Sink
-{
+public interface Sink extends org.apache.maven.doxia.sink.Sink {
// nop
}
diff --git a/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java b/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java
index ff9468c..db42def 100644
--- a/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java
+++ b/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java
@@ -1,5 +1,3 @@
-package org.apache.maven.reporting.exec;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,12 @@ package org.apache.maven.reporting.exec;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.reporting.exec;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import org.apache.maven.DefaultMaven;
import org.apache.maven.Maven;
@@ -53,320 +57,279 @@ import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.repository.WorkspaceRepository;
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
/**
* @author Olivier Lamy
*/
-public class TestDefaultMavenReportExecutor
- extends PlexusTestCase
-{
+public class TestDefaultMavenReportExecutor extends PlexusTestCase {
@Override
- protected void customizeContainerConfiguration( @SuppressWarnings( "unused" ) final ContainerConfiguration configuration )
- {
- super.customizeContainerConfiguration( configuration );
- configuration.setAutoWiring( true ).setClassPathScanning( PlexusConstants.SCANNING_CACHE );
+ protected void customizeContainerConfiguration(
+ @SuppressWarnings("unused") final ContainerConfiguration configuration) {
+ super.customizeContainerConfiguration(configuration);
+ configuration.setAutoWiring(true).setClassPathScanning(PlexusConstants.SCANNING_CACHE);
}
MavenExecutionRequest request = null;
ArtifactRepository localArtifactRepository;
- public void testSimpleLookup()
- throws Exception
- {
- MavenReportExecutor mavenReportExecutor = lookup( MavenReportExecutor.class );
- assertNotNull( mavenReportExecutor );
+ public void testSimpleLookup() throws Exception {
+ MavenReportExecutor mavenReportExecutor = lookup(MavenReportExecutor.class);
+ assertNotNull(mavenReportExecutor);
}
- public void testSimpleBuildReports()
- throws Exception
- {
+ public void testSimpleBuildReports() throws Exception {
ReportSet reportSet = new ReportSet();
- reportSet.getReports().add( "test-javadoc" );
- reportSet.getReports().add( "javadoc" );
+ reportSet.getReports().add("test-javadoc");
+ reportSet.getReports().add("javadoc");
MavenProject mavenProject = getMavenProject();
- List<MavenReportExecution> mavenReportExecutions = buildReports( mavenProject, reportSet );
-
- assertNotNull( mavenReportExecutions );
- assertEquals( 2, mavenReportExecutions.size() );
- assertEquals( "testapidocs/index", mavenReportExecutions.get( 0 ).getMavenReport().getOutputName() );
- assertEquals( "apidocs/index", mavenReportExecutions.get( 1 ).getMavenReport().getOutputName() );
+ List<MavenReportExecution> mavenReportExecutions = buildReports(mavenProject, reportSet);
+
+ assertNotNull(mavenReportExecutions);
+ assertEquals(2, mavenReportExecutions.size());
+ assertEquals(
+ "testapidocs/index",
+ mavenReportExecutions.get(0).getMavenReport().getOutputName());
+ assertEquals(
+ "apidocs/index", mavenReportExecutions.get(1).getMavenReport().getOutputName());
}
- public void testMultipleReportSets()
- throws Exception
- {
+ public void testMultipleReportSets() throws Exception {
ReportSet reportSet = new ReportSet();
- reportSet.getReports().add( "javadoc" );
+ reportSet.getReports().add("javadoc");
ReportSet reportSet2 = new ReportSet();
- reportSet2.getReports().add( "test-javadoc" );
- reportSet2.getReports().add( "javadoc" );
+ reportSet2.getReports().add("test-javadoc");
+ reportSet2.getReports().add("javadoc");
MavenProject mavenProject = getMavenProject();
- List<MavenReportExecution> mavenReportExecutions = buildReports( mavenProject, reportSet, reportSet2 );
-
- assertNotNull( mavenReportExecutions );
- assertEquals( 3, mavenReportExecutions.size() );
- assertEquals( "apidocs/index", mavenReportExecutions.get( 0 ).getMavenReport().getOutputName() );
- assertEquals( "testapidocs/index", mavenReportExecutions.get( 1 ).getMavenReport().getOutputName() );
- assertEquals( "apidocs/index", mavenReportExecutions.get( 2 ).getMavenReport().getOutputName() );
+ List<MavenReportExecution> mavenReportExecutions = buildReports(mavenProject, reportSet, reportSet2);
+
+ assertNotNull(mavenReportExecutions);
+ assertEquals(3, mavenReportExecutions.size());
+ assertEquals(
+ "apidocs/index", mavenReportExecutions.get(0).getMavenReport().getOutputName());
+ assertEquals(
+ "testapidocs/index",
+ mavenReportExecutions.get(1).getMavenReport().getOutputName());
+ assertEquals(
+ "apidocs/index", mavenReportExecutions.get(2).getMavenReport().getOutputName());
}
- public void testReportingPluginWithDependenciesInPluginManagement()
- throws Exception
- {
+ public void testReportingPluginWithDependenciesInPluginManagement() throws Exception {
ReportSet reportSet = new ReportSet();
- reportSet.getReports().add( "javadoc" );
+ reportSet.getReports().add("javadoc");
MavenProject mavenProject = getMavenProject();
Plugin plugin = new Plugin();
- plugin.setGroupId( "org.apache.maven.plugins" );
- plugin.setArtifactId( "maven-javadoc-plugin" );
- plugin.setVersion( "3.4.0" );
+ plugin.setGroupId("org.apache.maven.plugins");
+ plugin.setArtifactId("maven-javadoc-plugin");
+ plugin.setVersion("3.4.0");
Dependency dependency = new Dependency();
- dependency.setGroupId( "commons-lang" );
- dependency.setArtifactId( "commons-lang" );
- dependency.setVersion( "2.6" );
- plugin.getDependencies().add( dependency );
- mavenProject.getBuild().setPluginManagement( new PluginManagement() );
- mavenProject.getBuild().getPluginManagement().addPlugin( plugin );
- List<MavenReportExecution> mavenReportExecutions = buildReports( mavenProject, reportSet );
-
- assertNotNull( mavenReportExecutions );
- assertEquals( 1, mavenReportExecutions.size() );
- List<Dependency> dependencies = mavenReportExecutions.get( 0 ).getPlugin().getDependencies();
- assertEquals( 1, dependencies.size() );
- assertEquals( "commons-lang", dependencies.get( 0 ).getGroupId() );
- assertEquals( "2.6", dependencies.get( 0 ).getVersion() );
+ dependency.setGroupId("commons-lang");
+ dependency.setArtifactId("commons-lang");
+ dependency.setVersion("2.6");
+ plugin.getDependencies().add(dependency);
+ mavenProject.getBuild().setPluginManagement(new PluginManagement());
+ mavenProject.getBuild().getPluginManagement().addPlugin(plugin);
+ List<MavenReportExecution> mavenReportExecutions = buildReports(mavenProject, reportSet);
+
+ assertNotNull(mavenReportExecutions);
+ assertEquals(1, mavenReportExecutions.size());
+ List<Dependency> dependencies = mavenReportExecutions.get(0).getPlugin().getDependencies();
+ assertEquals(1, dependencies.size());
+ assertEquals("commons-lang", dependencies.get(0).getGroupId());
+ assertEquals("2.6", dependencies.get(0).getVersion());
}
- private List<MavenReportExecution> buildReports( MavenProject mavenProject, ReportSet... javadocReportSets )
- throws Exception
- {
+ private List<MavenReportExecution> buildReports(MavenProject mavenProject, ReportSet... javadocReportSets)
+ throws Exception {
ClassLoader orig = Thread.currentThread().getContextClassLoader();
ClassRealm realm = getContainer().getContainerRealm();
- Thread.currentThread().setContextClassLoader( realm );
- try
- {
+ Thread.currentThread().setContextClassLoader(realm);
+ try {
MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
- mavenReportExecutorRequest.setLocalRepository( getLocalArtifactRepository() );
+ mavenReportExecutorRequest.setLocalRepository(getLocalArtifactRepository());
- mavenReportExecutorRequest.setProject( mavenProject );
+ mavenReportExecutorRequest.setProject(mavenProject);
- MavenSession mavenSession = getMavenSession( getLocalArtifactRepository(), mavenProject );
- mavenSession.setCurrentProject( mavenProject );
- mavenSession.setProjects( Arrays.asList( mavenProject ) );
- mavenReportExecutorRequest.setMavenSession( mavenSession );
+ MavenSession mavenSession = getMavenSession(getLocalArtifactRepository(), mavenProject);
+ mavenSession.setCurrentProject(mavenProject);
+ mavenSession.setProjects(Arrays.asList(mavenProject));
+ mavenReportExecutorRequest.setMavenSession(mavenSession);
ReportPlugin reportPlugin = new ReportPlugin();
- reportPlugin.setGroupId( "org.apache.maven.plugins" );
- reportPlugin.setArtifactId( "maven-javadoc-plugin" );
- reportPlugin.setVersion( "3.4.0" );
+ reportPlugin.setGroupId("org.apache.maven.plugins");
+ reportPlugin.setArtifactId("maven-javadoc-plugin");
+ reportPlugin.setVersion("3.4.0");
- for ( ReportSet reportSet : javadocReportSets )
- {
- reportPlugin.getReportSets().add( reportSet );
+ for (ReportSet reportSet : javadocReportSets) {
+ reportPlugin.getReportSets().add(reportSet);
}
- List<ReportPlugin> reportPlugins = Arrays.asList( reportPlugin );
+ List<ReportPlugin> reportPlugins = Arrays.asList(reportPlugin);
- mavenReportExecutorRequest.setReportPlugins( reportPlugins.toArray( new ReportPlugin[1] ) );
+ mavenReportExecutorRequest.setReportPlugins(reportPlugins.toArray(new ReportPlugin[1]));
- MavenReportExecutor mavenReportExecutor = lookup( MavenReportExecutor.class );
+ MavenReportExecutor mavenReportExecutor = lookup(MavenReportExecutor.class);
- return mavenReportExecutor.buildMavenReports( mavenReportExecutorRequest );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( orig );
+ return mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
+ } finally {
+ Thread.currentThread().setContextClassLoader(orig);
}
}
- protected MavenSession getMavenSession( ArtifactRepository localRepository, final MavenProject mavenProject )
- throws Exception
- {
+ protected MavenSession getMavenSession(ArtifactRepository localRepository, final MavenProject mavenProject)
+ throws Exception {
request = new DefaultMavenExecutionRequest();
- request.setLocalRepository( localRepository );
+ request.setLocalRepository(localRepository);
- request.setWorkspaceReader( new WorkspaceReader()
- {
+ request.setWorkspaceReader(new WorkspaceReader() {
@Override
- public WorkspaceRepository getRepository()
- {
+ public WorkspaceRepository getRepository() {
return new WorkspaceRepository();
}
@Override
- public File findArtifact( Artifact artifact )
- {
+ public File findArtifact(Artifact artifact) {
return null;
}
@Override
- public List<String> findVersions( Artifact artifact )
- {
+ public List<String> findVersions(Artifact artifact) {
return Collections.emptyList();
}
- } );
+ });
final Settings settings = getSettings();
- getContainer().lookup( MavenExecutionRequestPopulator.class ).populateFromSettings( request, settings );
+ getContainer().lookup(MavenExecutionRequestPopulator.class).populateFromSettings(request, settings);
- getContainer().lookup( MavenExecutionRequestPopulator.class ).populateDefaults( request );
+ getContainer().lookup(MavenExecutionRequestPopulator.class).populateDefaults(request);
- request.setLocalRepository( getLocalArtifactRepository() );
- request.setLocalRepositoryPath( getLocalArtifactRepository().getBasedir() );
- request.setCacheNotFound( false );
+ request.setLocalRepository(getLocalArtifactRepository());
+ request.setLocalRepositoryPath(getLocalArtifactRepository().getBasedir());
+ request.setCacheNotFound(false);
- request.setSystemProperties( System.getProperties() );
+ request.setSystemProperties(System.getProperties());
MavenExecutionResult result = new DefaultMavenExecutionResult();
- RepositorySystemSession repositorySystemSession = buildRepositorySystemSession( request );
+ RepositorySystemSession repositorySystemSession = buildRepositorySystemSession(request);
- return new MavenSession( getContainer(), repositorySystemSession, request, result )
- {
+ return new MavenSession(getContainer(), repositorySystemSession, request, result) {
@Override
- public MavenProject getTopLevelProject()
- {
+ public MavenProject getTopLevelProject() {
return mavenProject;
}
@Override
- public Settings getSettings()
- {
+ public Settings getSettings() {
return settings;
}
@Override
- public List<MavenProject> getProjects()
- {
- return Arrays.asList( mavenProject );
+ public List<MavenProject> getProjects() {
+ return Arrays.asList(mavenProject);
}
@Override
- public MavenProject getCurrentProject()
- {
+ public MavenProject getCurrentProject() {
return mavenProject;
}
-
};
}
- private ArtifactRepository getLocalArtifactRepository()
- throws Exception
- {
- if ( localArtifactRepository != null )
- {
+ private ArtifactRepository getLocalArtifactRepository() throws Exception {
+ if (localArtifactRepository != null) {
return localArtifactRepository;
}
String localRepoPath =
- System.getProperty( "localRepository", MavenCli.userMavenConfigurationHome.getPath() + "/repository" );
+ System.getProperty("localRepository", MavenCli.userMavenConfigurationHome.getPath() + "/repository");
- localArtifactRepository = lookup( RepositorySystem.class ).createLocalRepository( new File( localRepoPath ) );
+ localArtifactRepository = lookup(RepositorySystem.class).createLocalRepository(new File(localRepoPath));
return localArtifactRepository;
}
- public Settings getSettings()
- throws ComponentLookupException, SettingsBuildingException
- {
+ public Settings getSettings() throws ComponentLookupException, SettingsBuildingException {
SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest();
- settingsBuildingRequest.setGlobalSettingsFile( MavenCli.DEFAULT_GLOBAL_SETTINGS_FILE );
+ settingsBuildingRequest.setGlobalSettingsFile(MavenCli.DEFAULT_GLOBAL_SETTINGS_FILE);
- settingsBuildingRequest.setUserSettingsFile( MavenCli.DEFAULT_USER_SETTINGS_FILE );
+ settingsBuildingRequest.setUserSettingsFile(MavenCli.DEFAULT_USER_SETTINGS_FILE);
- settingsBuildingRequest.getSystemProperties().putAll( System.getProperties() );
-
- return getContainer().lookup( SettingsBuilder.class )
- .build( settingsBuildingRequest ).getEffectiveSettings();
+ settingsBuildingRequest.getSystemProperties().putAll(System.getProperties());
+ return getContainer()
+ .lookup(SettingsBuilder.class)
+ .build(settingsBuildingRequest)
+ .getEffectiveSettings();
}
- protected MavenProject getMavenProject()
- {
- MavenProjectStub mavenProjectStub = new MavenProjectStub()
- {
+ protected MavenProject getMavenProject() {
+ MavenProjectStub mavenProjectStub = new MavenProjectStub() {
@Override
- public List<RemoteRepository> getRemotePluginRepositories()
- {
- if ( super.getRemotePluginRepositories() == null )
- {
- return RepositoryUtils.toRepos( request.getRemoteRepositories() );
+ public List<RemoteRepository> getRemotePluginRepositories() {
+ if (super.getRemotePluginRepositories() == null) {
+ return RepositoryUtils.toRepos(request.getRemoteRepositories());
}
return super.getRemotePluginRepositories();
}
@Override
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
- if ( super.getRemotePluginRepositories() == null )
- {
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
+ if (super.getRemotePluginRepositories() == null) {
return request.getRemoteRepositories();
}
return super.getRemoteArtifactRepositories();
}
@Override
- public String getName()
- {
+ public String getName() {
return "foo";
}
@Override
- public String getVersion()
- {
+ public String getVersion() {
return "1.0-SNAPSHOT";
}
@Override
- public boolean isExecutionRoot()
- {
+ public boolean isExecutionRoot() {
return true;
}
@Override
- public List<String> getCompileSourceRoots()
- {
- return Arrays.asList( "src/main/java" );
+ public List<String> getCompileSourceRoots() {
+ return Arrays.asList("src/main/java");
}
@Override
- public List<String> getTestCompileSourceRoots()
- {
- return Arrays.asList( "src/test/java" );
+ public List<String> getTestCompileSourceRoots() {
+ return Arrays.asList("src/test/java");
}
};
- mavenProjectStub.setPackaging( "jar" );
+ mavenProjectStub.setPackaging("jar");
Build build = new Build();
- build.setOutputDirectory( "target" );
+ build.setOutputDirectory("target");
- build.setSourceDirectory( "src/main/java" );
+ build.setSourceDirectory("src/main/java");
- build.setTestSourceDirectory( "src/test/java" );
+ build.setTestSourceDirectory("src/test/java");
- mavenProjectStub.setBuild( build );
+ mavenProjectStub.setBuild(build);
return mavenProjectStub;
}
- private RepositorySystemSession buildRepositorySystemSession( MavenExecutionRequest request )
- throws ComponentLookupException
- {
- DefaultMaven defaultMaven = (DefaultMaven) getContainer().lookup( Maven.class );
+ private RepositorySystemSession buildRepositorySystemSession(MavenExecutionRequest request)
+ throws ComponentLookupException {
+ DefaultMaven defaultMaven = (DefaultMaven) getContainer().lookup(Maven.class);
- return defaultMaven.newRepositorySession( request );
+ return defaultMaven.newRepositorySession(request);
}
-
}