You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2014/06/09 18:49:14 UTC
svn commit: r1601438 - in /maven/shared/trunk/maven-reporting-exec/src:
it/reportConfig/ it/reportConfig/src/ it/reportConfig/src/main/
it/reportConfig/src/main/java/ it/reportConfig/src/main/java/org/
it/reportConfig/src/main/java/org/apache/ it/repor...
Author: hboutemy
Date: Mon Jun 9 16:49:13 2014
New Revision: 1601438
URL: http://svn.apache.org/r1601438
Log:
[MSHARED-338] made reportPlugins inherit configuration from pluginManagement
Added:
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties (with props)
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml (with props)
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java (with props)
maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy (with props)
Modified:
maven/shared/trunk/maven-reporting-exec/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
Added: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties?rev=1601438&view=auto
==============================================================================
--- maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties (added)
+++ maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties Mon Jun 9 16:49:13 2014
@@ -0,0 +1,22 @@
+# 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.
+
+invoker.goals.1 = clean install
+invoker.debug.1 = false
+invoker.goals.2 = -Preporting site
+invoker.debug.2 = true
+invoker.maven.version = 3.0+
\ No newline at end of file
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/invoker.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml?rev=1601438&view=auto
==============================================================================
--- maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml (added)
+++ maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml Mon Jun 9 16:49:13 2014
@@ -0,0 +1,142 @@
+<?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
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.shared.maren-reporting-exec.its</groupId>
+ <artifactId>report-config</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Report Configuration IT</name>
+ <description>
+ Checks that report configuration is inherited from build.pluginManagement.
+ </description>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.3</version>
+ <dependencies>
+ <dependency>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.7</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>index</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>reporting</id>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <pluginManagement>pluginManagement</pluginManagement>
+ <buildAndManagement>pluginManagement</buildAndManagement>
+ <reportingPlugin>pluginManagement</reportingPlugin>
+ <reportSet>pluginManagement</reportSet>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin><!-- build.plugins configuration should not impact reports -->
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <configuration>
+ <buildPlugin>build.plugin</buildPlugin>
+ <buildAndManagement>build.plugin</buildAndManagement>
+ <reportingPlugin>build.plugin</reportingPlugin>
+ <reportSet>build.plugin</reportSet>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <configuration>
+ <reportingPlugin>reporting.plugin</reportingPlugin>
+ <reportSet>reporting.plugin</reportSet>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <id>reportSet</id>
+ <reports>
+ <report>test</report>
+ </reports>
+ <configuration>
+ <reportingPluginReportSet>reporting.plugin.reportSet</reportingPluginReportSet>
+ </configuration>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+ </profile>
+ </profiles>
+</project>
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java?rev=1601438&view=auto
==============================================================================
--- maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java (added)
+++ maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java Mon Jun 9 16:49:13 2014
@@ -0,0 +1,123 @@
+package org.apache.maven.shared.it;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkAdapter;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+
+import java.util.Locale;
+
+/**
+ * Report that displays effective parameter values: will be used to check how report values
+ * are inherited/overridden from build.pluginManagement and not build.plugins.
+ *
+ * @goal test
+ * @phase site
+ */
+public class ConfigurationReport
+ extends AbstractMavenReport
+{
+ /**
+ * Parameter with value defined in pluginManagement
+ *
+ * @parameter default-value="default"
+ */
+ private String pluginManagement;
+
+ /**
+ * Parameter with value defined in build.plugins
+ *
+ * @parameter default-value="default"
+ */
+ private String buildPlugin;
+
+ /**
+ * Parameter with value defined both in build.plugins and pluginManagement
+ *
+ * @parameter default-value="default"
+ */
+ private String buildAndManagement;
+
+ /**
+ * Parameter with value defined both in build.plugins, pluginManagement and reporting.plugin.
+ *
+ * @parameter default-value="default"
+ */
+ private String reportingPlugin;
+
+ /**
+ * Parameter with value defined both in build.plugins, pluginManagement, reporting.plugin and
+ * reporting.plugin.reportSet.
+ *
+ * @parameter default-value="default"
+ */
+ private String reportingPluginReportSet;
+
+ public String getOutputName()
+ {
+ return "configuration";
+ }
+
+ public String getName( Locale locale )
+ {
+ return "Configuration";
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "Report Configuration";
+ }
+
+ @Override
+ protected Renderer getSiteRenderer()
+ {
+ return null;
+ }
+
+ @Override
+ protected String getOutputDirectory()
+ {
+ return null;
+ }
+
+ @Override
+ protected MavenProject getProject()
+ {
+ return null;
+ }
+
+ @Override
+ protected void executeReport( Locale locale )
+ throws MavenReportException
+ {
+ final Sink s = getSink();
+ s.verbatim( null );
+ s.text( "pluginManagement = " + pluginManagement + "\n" );
+ s.text( "buildPlugin = " + buildPlugin + "\n" );
+ s.text( "buildAndManagement = " + buildAndManagement + "\n" );
+ s.text( "reportingPlugin = " + reportingPlugin + "\n" );
+ s.text( "reportingPluginReportSet = " + reportingPluginReportSet );
+ s.verbatim_();
+ }
+}
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/src/main/java/org/apache/maven/shared/it/ConfigurationReport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy?rev=1601438&view=auto
==============================================================================
--- maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy (added)
+++ maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy Mon Jun 9 16:49:13 2014
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+ File f = new File( basedir, 'target/site/configuration.html' );
+assert f.exists();
+content = f.text;
+
+// parameter merged from pluginManagement
+assert content.contains( 'pluginManagement = pluginManagement' );
+// parameter from build.plugin is not merged
+assert content.contains( 'buildPlugin = default' );
+// parameter from build.plugin is not merged but pluginManagement
+assert content.contains( 'buildAndManagement = pluginManagement' );
+// parameter from reporting.plugin wins over pluginManagement
+assert content.contains( 'reportingPlugin = reporting.plugin' );
+// parameter from reporting.plugin.reportSet wins over reporting.plugin and pluginManagement
+assert content.contains( 'reportingPluginReportSet = reporting.plugin.reportSet' );
+
+return true;
\ No newline at end of file
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/trunk/maven-reporting-exec/src/it/reportConfig/verify.groovy
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/shared/trunk/maven-reporting-exec/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-exec/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java?rev=1601438&r1=1601437&r2=1601438&view=diff
==============================================================================
--- maven/shared/trunk/maven-reporting-exec/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java (original)
+++ maven/shared/trunk/maven-reporting-exec/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java Mon Jun 9 16:49:13 2014
@@ -262,7 +262,19 @@ public class DefaultMavenReportExecutor
continue;
}
+ Xpp3Dom pluginMgmtConfiguration = null;
+ if ( project.getBuild() != null && project.getBuild().getPluginManagement() != null )
+ {
+ Plugin pluginMgmt = find( reportPlugin, project.getBuild().getPluginManagement().getPlugins() );
+
+ if ( pluginMgmt != null && plugin.getVersion() != null )
+ {
+ pluginMgmtConfiguration = (Xpp3Dom) pluginMgmt.getConfiguration();
+ }
+ }
+
mojoExecution.setConfiguration( mergeConfiguration( mojoDescriptor.getMojoConfiguration(),
+ pluginMgmtConfiguration,
reportPlugin.getConfiguration(),
report.getConfiguration(),
mojoDescriptor.getParameterMap().keySet() ) );
@@ -413,41 +425,44 @@ public class DefaultMavenReportExecutor
* Merge plugin configuration and reportset configuration to mojo configuration to get effective
* mojo configuration.
*
- * @param mojoConf configuration done at mojo level
- * @param pluginConf configuration done at build plugin level
- * @param reportSetConf configuration done at reportset level
+ * @param mojoConf configuration done at mojo descriptor level
+ * @param pluginMgmtConfig configuration done at build.pluginManagement level
+ * @param pluginConf configuration done at reporting plugin level
+ * @param reportSetConf configuration done at reportSet level
* @param parameters set of supported parameters: any other parameter will be removed
* @return the effective configuration to be used
*/
- private Xpp3Dom mergeConfiguration( PlexusConfiguration mojoConf, PlexusConfiguration pluginConf,
- PlexusConfiguration reportSetConf, Set<String> parameters )
+ private Xpp3Dom mergeConfiguration( PlexusConfiguration mojoConf, Xpp3Dom pluginMgmtConfig,
+ PlexusConfiguration pluginConf, PlexusConfiguration reportSetConf,
+ Set<String> parameters )
{
Xpp3Dom mojoConfig = ( mojoConf != null ) ? convert( mojoConf ) : new Xpp3Dom( "configuration" );
- if ( pluginConf != null || reportSetConf != null )
+ if ( pluginMgmtConfig != null || pluginConf != null || reportSetConf != null )
{
- Xpp3Dom pluginConfiguration = pluginConf == null ? new Xpp3Dom( "fake" ) : convert( pluginConf );
-
- // MSITE-512 configuration from ReportSet must win
- Xpp3Dom mergedConfigurationWithReportSet =
- Xpp3DomUtils.mergeXpp3Dom( convert( reportSetConf ), pluginConfiguration );
+ Xpp3Dom pluginConfig = ( pluginConf == null ) ? new Xpp3Dom( "fake" ) : convert( pluginConf );
- Xpp3Dom mergedConfiguration = Xpp3DomUtils.mergeXpp3Dom( mergedConfigurationWithReportSet, mojoConfig );
+ // merge pluginConf into reportSetConf
+ Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom( convert( reportSetConf ), pluginConfig );
+ // then merge pluginMgmtConfig
+ mergedConfig = Xpp3DomUtils.mergeXpp3Dom( mergedConfig, pluginMgmtConfig );
+ // then merge mojoConf
+ mergedConfig = Xpp3DomUtils.mergeXpp3Dom( mergedConfig, mojoConfig );
// clean result
- Xpp3Dom cleanedConfiguration = new Xpp3Dom( "configuration" );
- if ( mergedConfiguration.getChildren() != null )
+ Xpp3Dom cleanedConfig = new Xpp3Dom( "configuration" );
+ if ( mergedConfig.getChildren() != null )
{
- for ( Xpp3Dom parameter : mergedConfiguration.getChildren() )
+ for ( Xpp3Dom parameter : mergedConfig.getChildren() )
{
if ( parameters.contains( parameter.getName() ) )
{
- cleanedConfiguration.addChild( parameter );
+ cleanedConfig.addChild( parameter );
}
}
}
- mojoConfig = cleanedConfiguration;
+ mojoConfig = cleanedConfig;
}
return mojoConfig;