This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch doxia-2.0.0 in repository https://gitbox.apache.org/repos/asf/maven-reporting-exec.git
commit 1d0ae53ac517cee23aeae8759510c4e58e2b9b85 Author: Michael Osipov <[email protected]> AuthorDate: Sun Apr 17 23:05:45 2022 +0200 Rest --- pom.xml | 27 ++--- src/it/forked-lifecycle/pom.xml | 2 +- src/it/reportConfig/pom.xml | 2 +- .../reporting/exec/DefaultMavenReportExecutor.java | 125 +++++++++++---------- src/main/java/org/codehaus/doxia/sink/Sink.java | 31 +++++ .../exec/TestDefaultMavenReportExecutor.java | 8 +- 6 files changed, 112 insertions(+), 83 deletions(-) diff --git a/pom.xml b/pom.xml index f3916b3..2bf212d 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-exec</artifactId> - <version>1.6.1-SNAPSHOT</version> + <version>2.0.0-M1-SNAPSHOT</version> <name>Apache Maven Reporting Executor</name> <description>Classes to manage report plugin executions with Maven 3.</description> @@ -56,19 +56,20 @@ </distributionManagement> <properties> + <javaVersion>8</javaVersion> <mavenVersion>3.2.5</mavenVersion> <aetherVersion>1.0.0.v20140518</aetherVersion> - <javaVersion>7</javaVersion> + <slf4jVersion>1.7.36</slf4jVersion> <project.build.outputTimestamp>2022-02-10T08:20:39Z</project.build.outputTimestamp> - <sitePluginVersion>3.10.0</sitePluginVersion> - <projectInfoReportsPluginVersion>3.2.1</projectInfoReportsPluginVersion> + <sitePluginVersion>3.11.0</sitePluginVersion> + <projectInfoReportsPluginVersion>3.2.2</projectInfoReportsPluginVersion> </properties> <dependencies> <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-api</artifactId> - <version>3.1.0</version> + <version>4.0.0-M1-SNAPSHOT</version> </dependency> <!-- Maven --> @@ -118,6 +119,12 @@ <version>3.1.0</version><!-- do not upgrade to 3.2.0+ because it adds Xpp3Dom.getInputLocation(): see MSHARED-921 --> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4jVersion}</version> + </dependency> + <!-- Eclipse Aether for Maven 3.1+ --> <dependency> <groupId>org.eclipse.aether</groupId> @@ -153,7 +160,7 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> - <version>1.7.32</version> + <version>${slf4jVersion}</version> <scope>test</scope> </dependency> <dependency> @@ -191,13 +198,9 @@ <dependency> <groupId>org.apache.maven.doxia</groupId> <artifactId>doxia-site-renderer</artifactId> - <version>1.11.1</version> + <version>2.0.0-M2</version> <scope>test</scope> <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> <exclusion> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> @@ -329,8 +332,6 @@ <properties> <maven.compiler.source>${maven.compiler.source}</maven.compiler.source> <maven.compiler.target>${maven.compiler.target}</maven.compiler.target> - <!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central --> - <https.protocols>${https.protocols}</https.protocols> </properties> </configuration> <executions> diff --git a/src/it/forked-lifecycle/pom.xml b/src/it/forked-lifecycle/pom.xml index 1e14926..d739dad 100644 --- a/src/it/forked-lifecycle/pom.xml +++ b/src/it/forked-lifecycle/pom.xml @@ -65,7 +65,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.3.1</version> + <version>3.4.0</version> </plugin> </plugins> </reporting> diff --git a/src/it/reportConfig/pom.xml b/src/it/reportConfig/pom.xml index ee04529..ff43213 100644 --- a/src/it/reportConfig/pom.xml +++ b/src/it/reportConfig/pom.xml @@ -42,7 +42,7 @@ under the License. <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-impl</artifactId> - <version>3.1.0</version> + <version>4.0.0-M1-SNAPSHOT</version> </dependency> </dependencies> 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 1d53bc5..3f57bc1 100644 --- a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java +++ b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java @@ -50,9 +50,10 @@ import org.apache.maven.shared.utils.StringUtils; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * <p> @@ -98,8 +99,7 @@ import org.codehaus.plexus.util.xml.Xpp3DomUtils; public class DefaultMavenReportExecutor implements MavenReportExecutor { - @Requirement - private Logger logger; + private static final Logger LOGGER = LoggerFactory.getLogger( DefaultMavenReportExecutor.class ); @Requirement protected MavenPluginManager mavenPluginManager; @@ -137,7 +137,6 @@ public class DefaultMavenReportExecutor { return Collections.emptyList(); } - getLog().debug( "DefaultMavenReportExecutor.buildMavenReports()" ); Set<String> reportPluginKeys = new HashSet<>(); List<MavenReportExecution> reportExecutions = new ArrayList<>(); @@ -151,7 +150,7 @@ public class DefaultMavenReportExecutor if ( !reportPluginKeys.add( pluginKey ) ) { - logger.info( "plugin " + pluginKey + " will be executed more than one time" ); + LOGGER.info( "Plugin {} will be executed more than one time", pluginKey ); } reportExecutions.addAll( buildReportPlugin( mavenReportExecutorRequest, reportPlugin ) ); @@ -159,7 +158,7 @@ public class DefaultMavenReportExecutor } catch ( Exception e ) { - throw new MojoExecutionException( "failed to get report for " + pluginKey, e ); + throw new MojoExecutionException( "Failed to get report for " + pluginKey, e ); } return reportExecutions; @@ -174,7 +173,7 @@ public class DefaultMavenReportExecutor plugin.setGroupId( reportPlugin.getGroupId() ); plugin.setArtifactId( reportPlugin.getArtifactId() ); plugin.setVersion( resolvePluginVersion( reportPlugin, mavenReportExecutorRequest ) ); - logger.info( "configuring report plugin " + plugin.getId() ); + LOGGER.info( "Configuring report plugin {}", plugin.getId() ); mergePluginToReportPlugin( mavenReportExecutorRequest, plugin, reportPlugin ); @@ -211,9 +210,9 @@ public class DefaultMavenReportExecutor } buff.append( mre.getGoal() ); } - logger.info( reports.size() + " report" + ( reports.size() > 1 ? "s" : "" ) + " " - + ( hasUserDefinedReports ? "configured" : "detected" ) + " for " + 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; @@ -245,7 +244,7 @@ public class DefaultMavenReportExecutor } else { - logger.warn( report + " report is declared twice in default reports" ); + LOGGER.warn( "{} report is declared twice in default reports", report ); } } @@ -261,7 +260,7 @@ public class DefaultMavenReportExecutor } else { - logger.warn( report + " report is declared twice in " + reportSet.getId() + " reportSet" ); + LOGGER.warn( "{} report is declared twice in {} reportSet", report, reportSet.getId() ); } } } @@ -302,8 +301,9 @@ public class DefaultMavenReportExecutor if ( hasUserDefinedReports ) { // reports were explicitly written in the POM - logger.warn( "ignoring " + mojoExecution.getPlugin().getId() + ':' + report.getGoal() - + " goal since it is not a report: should be removed from reporting configuration in POM" ); + 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; } @@ -354,12 +354,12 @@ public class DefaultMavenReportExecutor execution = "'" + mojoDescriptor.getExecuteGoal() + "' forked goal execution"; } - logger.info( "preparing " + reportDescription + " requires " + execution ); + LOGGER.info( "Preparing {} requires {}", reportDescription, execution ); lifecycleExecutor.executeForkedExecutions( mojoExecution, mavenReportExecutorRequest.getMavenSession() ); - logger.info( execution + " for " + reportDescription + " preparation done" ); + LOGGER.info( "{} for {} preparation done", execution, reportDescription ); } return mavenReportExecution; @@ -385,7 +385,14 @@ public class DefaultMavenReportExecutor } catch ( ClassCastException e ) { - getLog().warn( "skip ClassCastException " + e.getMessage() ); + if ( LOGGER.isDebugEnabled() ) + { + LOGGER.warn( "Skipping ClassCastException", e ); + } + else + { + LOGGER.warn( "Skipping ClassCastException" ); + } return null; } catch ( PluginContainerException e ) @@ -397,11 +404,13 @@ public class DefaultMavenReportExecutor if ( e.getCause() != null && e.getCause() instanceof NoClassDefFoundError && e.getMessage().contains( "PluginRegistry" ) ) { - getLog().warn( "skip NoClassDefFoundError with PluginRegistry " ); - // too noisy, only in debug mode + e.getMessage() ); - if ( getLog().isDebugEnabled() ) + if ( LOGGER.isDebugEnabled() ) + { + LOGGER.warn( "Skipping NoClassDefFoundError with PluginRegistry", e ); + } + else { - getLog().debug( e.getMessage(), e ); + LOGGER.warn( "Skipping NoClassDefFoundError with PluginRegistry" ); } return null; } @@ -424,8 +433,14 @@ public class DefaultMavenReportExecutor } catch ( ClassNotFoundException e ) { - getLog().warn( "skip ClassNotFoundException mojoExecution.goal '" + mojoExecution.getGoal() + "': " - + e.getMessage(), 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 @@ -441,17 +456,17 @@ public class DefaultMavenReportExecutor boolean isMavenReport = MavenReport.class.isAssignableFrom( mojoClass ); - if ( getLog().isDebugEnabled() ) + if ( LOGGER.isDebugEnabled() ) { if ( mojoDescriptor != null && mojoDescriptor.getImplementationClass() != null ) { - getLog().debug( "class " + mojoDescriptor.getImplementationClass().getName() + " isMavenReport: " - + isMavenReport ); + LOGGER.debug( "Class {} is MavenReport: ", + mojoDescriptor.getImplementationClass().getName(), isMavenReport ); } if ( !isMavenReport ) { - getLog().debug( "skip non MavenReport " + mojoExecution.getMojoDescriptor().getId() ); + LOGGER.debug( "Skipping non MavenReport {}", mojoExecution.getMojoDescriptor().getId() ); } } @@ -459,8 +474,14 @@ public class DefaultMavenReportExecutor } catch ( LinkageError e ) { - getLog().warn( "skip LinkageError mojoExecution.goal '" + mojoExecution.getGoal() + "': " + e.getMessage(), - 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 @@ -539,11 +560,6 @@ public class DefaultMavenReportExecutor return dom; } - private Logger getLog() - { - return logger; - } - /** * Resolve report plugin version. Steps to find a plugin version stop after each step if a non <code>null</code> * value has been found: @@ -565,19 +581,13 @@ public class DefaultMavenReportExecutor throws PluginVersionResolutionException { String reportPluginKey = reportPlugin.getGroupId() + ':' + reportPlugin.getArtifactId(); - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "resolving version for " + reportPluginKey ); - } + LOGGER.debug( "Resolving version for {}", reportPluginKey ); // look for version defined in the reportPlugin configuration if ( reportPlugin.getVersion() != null ) { - if ( getLog().isDebugEnabled() ) - { - logger.debug( "resolved " + reportPluginKey + " version from the reporting.plugins section: " - + reportPlugin.getVersion() ); - } + LOGGER.debug( "Resolved {} version from the reporting.plugins section: {}", + reportPluginKey, reportPlugin.getVersion() ); return reportPlugin.getVersion(); } @@ -590,11 +600,8 @@ public class DefaultMavenReportExecutor if ( plugin != null && plugin.getVersion() != null ) { - if ( getLog().isDebugEnabled() ) - { - logger.debug( "resolved " + reportPluginKey + " version from the build.plugins section: " - + plugin.getVersion() ); - } + LOGGER.debug( "Resolved {} version from the build.plugins section: {}", + reportPluginKey, plugin.getVersion() ); return plugin.getVersion(); } } @@ -606,21 +613,18 @@ public class DefaultMavenReportExecutor if ( plugin != null && plugin.getVersion() != null ) { - if ( getLog().isDebugEnabled() ) - { - logger.debug( "resolved " + reportPluginKey - + " version from the build.pluginManagement.plugins section: " + plugin.getVersion() ); - } + LOGGER.debug( "Resolved {} version from the build.pluginManagement.plugins section: {}", + reportPluginKey, plugin.getVersion() ); return plugin.getVersion(); } } - logger.warn( "Report plugin " + reportPluginKey + " has an empty version." ); - logger.warn( "" ); - logger.warn( "It is highly recommended to fix these problems" + 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" + LOGGER.warn( "" ); + LOGGER.warn( "For this reason, future Maven versions might no" + " longer support building such malformed projects." ); Plugin plugin = new Plugin(); @@ -631,10 +635,7 @@ public class DefaultMavenReportExecutor new DefaultPluginVersionRequest( plugin, mavenReportExecutorRequest.getMavenSession() ); PluginVersionResult result = pluginVersionResolver.resolve( pluginVersionRequest ); - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "resolved " + reportPluginKey + " version from repository: " + result.getVersion() ); - } + LOGGER.debug( "Resolved {} version from repository: {}", reportPluginKey, result.getVersion() ); return result.getVersion(); } diff --git a/src/main/java/org/codehaus/doxia/sink/Sink.java b/src/main/java/org/codehaus/doxia/sink/Sink.java new file mode 100644 index 0000000..0fe64cf --- /dev/null +++ b/src/main/java/org/codehaus/doxia/sink/Sink.java @@ -0,0 +1,31 @@ +package org.codehaus.doxia.sink; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * 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 +{ + // 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 1be5f53..8a2142a 100644 --- a/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java +++ b/src/test/java/org/apache/maven/reporting/exec/TestDefaultMavenReportExecutor.java @@ -48,7 +48,6 @@ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.repository.RemoteRepository; @@ -129,7 +128,7 @@ public class TestDefaultMavenReportExecutor Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( "maven-javadoc-plugin" ); - plugin.setVersion( "3.0.0-M1" ); + plugin.setVersion( "3.4.0" ); Dependency dependency = new Dependency(); dependency.setGroupId( "commons-lang" ); dependency.setArtifactId( "commons-lang" ); @@ -170,7 +169,7 @@ public class TestDefaultMavenReportExecutor ReportPlugin reportPlugin = new ReportPlugin(); reportPlugin.setGroupId( "org.apache.maven.plugins" ); reportPlugin.setArtifactId( "maven-javadoc-plugin" ); - reportPlugin.setVersion( "3.0.0-M1" ); + reportPlugin.setVersion( "3.4.0" ); for ( ReportSet reportSet : javadocReportSets ) { @@ -227,9 +226,6 @@ public class TestDefaultMavenReportExecutor request.setLocalRepositoryPath( getLocalArtifactRepository().getBasedir() ); request.setCacheNotFound( false ); - request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO ); - getContainer().lookup( Logger.class ).setThreshold( 1 ); - request.setSystemProperties( System.getProperties() ); MavenExecutionResult result = new DefaultMavenExecutionResult();
