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 2018/02/27 21:04:04 UTC

[maven-site-plugin] branch master updated: [MSITE-806] fixed regression: honour reporting.excludeDefaults

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 0190d0d  [MSITE-806] fixed regression: honour reporting.excludeDefaults
0190d0d is described below

commit 0190d0d20f44e654da1777ff68067add0c71c97d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Tue Feb 27 21:52:35 2018 +0100

    [MSITE-806] fixed regression: honour reporting.excludeDefaults
---
 src/it/default-reports-excluded/pom.xml            | 56 ++++++++++++++++++++++
 src/it/default-reports-excluded/verify.groovy      | 24 ++++++++++
 src/it/default-reports/pom.xml                     | 52 ++++++++++++++++++++
 src/it/default-reports/verify.groovy               | 25 ++++++++++
 .../site/render/AbstractSiteRenderingMojo.java     | 42 ++++++++++++++--
 5 files changed, 195 insertions(+), 4 deletions(-)

diff --git a/src/it/default-reports-excluded/pom.xml b/src/it/default-reports-excluded/pom.xml
new file mode 100644
index 0000000..5ae3123
--- /dev/null
+++ b/src/it/default-reports-excluded/pom.xml
@@ -0,0 +1,56 @@
+<?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.plugins.site.its</groupId>
+  <artifactId>default-reports</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>maven-site-plugin IT: default reports</name>
+  <description>check that MPIR is enabled by default even if not configured</description>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <projectInfoReportsPluginVersion>@projectInfoReportsPluginVersion@</projectInfoReportsPluginVersion>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <version>@projectInfoReportsPluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <excludeDefaults>true</excludeDefaults>
+  </reporting>
+</project>
diff --git a/src/it/default-reports-excluded/verify.groovy b/src/it/default-reports-excluded/verify.groovy
new file mode 100644
index 0000000..ecf93c3
--- /dev/null
+++ b/src/it/default-reports-excluded/verify.groovy
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+sitedir = new File( basedir, 'target/site' );
+
+assert new File( sitedir, 'css' ).exists();
+assert !new File( sitedir, 'index.html' ).exists();
diff --git a/src/it/default-reports/pom.xml b/src/it/default-reports/pom.xml
new file mode 100644
index 0000000..46aa9bd
--- /dev/null
+++ b/src/it/default-reports/pom.xml
@@ -0,0 +1,52 @@
+<?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.plugins.site.its</groupId>
+  <artifactId>default-reports</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>maven-site-plugin IT: default reports</name>
+  <description>check that MPIR is enabled by default even if not configured</description>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <projectInfoReportsPluginVersion>@projectInfoReportsPluginVersion@</projectInfoReportsPluginVersion>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <version>@projectInfoReportsPluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/default-reports/verify.groovy b/src/it/default-reports/verify.groovy
new file mode 100644
index 0000000..3c4041d
--- /dev/null
+++ b/src/it/default-reports/verify.groovy
@@ -0,0 +1,25 @@
+
+/*
+ * 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.
+ */
+
+sitedir = new File( basedir, 'target/site' );
+
+assert new File( sitedir, 'index.html' ).exists();
+assert new File( sitedir, 'team-list.html' ).exists();
+assert new File( sitedir, 'dependencies.html' ).exists();
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 884e5e3..605dc09 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -42,6 +42,7 @@ import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
 import org.apache.maven.doxia.tools.SiteToolException;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -147,10 +148,11 @@ public abstract class AbstractSiteRenderingMojo
     /**
      * replaces previous reportPlugins parameter, that was injected by Maven core from
      * reporting section: but this new configuration format has been abandoned.
-     * @since 3.7
+     *
+     * @since 3.7.1
      */
-    @Parameter( defaultValue = "${project.reporting.plugins}", readonly = true )
-    private ReportPlugin[] reportingPlugins;
+    @Parameter( defaultValue = "${project.reporting}", readonly = true )
+    private Reporting reporting;
 
     private PlexusContainer container;
 
@@ -235,7 +237,7 @@ public abstract class AbstractSiteRenderingMojo
             mavenReportExecutorRequest.setLocalRepository( localRepository );
             mavenReportExecutorRequest.setMavenSession( mavenSession );
             mavenReportExecutorRequest.setProject( project );
-            mavenReportExecutorRequest.setReportPlugins( reportingPlugins );
+            mavenReportExecutorRequest.setReportPlugins( getReportingPlugins() );
 
             MavenReportExecutor mavenReportExecutor;
             try
@@ -272,6 +274,38 @@ public abstract class AbstractSiteRenderingMojo
         return reportExecutions;
     }
 
+    /**
+     * Get the report plugins from reporting section, adding if necessary (ni.e. not excluded)
+     * default reports (i.e. maven-project-info-reports)
+     *
+     * @return the effective list of reports
+     * @since 3.7.1
+     */
+    private ReportPlugin[] getReportingPlugins()
+    {
+        List<ReportPlugin> reportingPlugins = reporting.getPlugins();
+
+        // MSITE-806: add default report plugin like done in maven-model-builder DefaultReportingConverter
+        boolean hasMavenProjectInfoReportsPlugin = false;
+        for ( ReportPlugin plugin : reportingPlugins )
+        {
+            if ( "org.apache.maven.plugins".equals( plugin.getGroupId() )
+                && "maven-project-info-reports-plugin".equals( plugin.getArtifactId() ) )
+            {
+                hasMavenProjectInfoReportsPlugin = true;
+                break;
+            }
+        }
+
+        if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin )
+        {
+            ReportPlugin mpir = new ReportPlugin();
+            mpir.setArtifactId( "maven-project-info-reports-plugin" );
+            reportingPlugins.add( mpir );
+        }
+        return reportingPlugins.toArray( new ReportPlugin[reportingPlugins.size()] );
+    }
+
     protected SiteRenderingContext createSiteRenderingContext( Locale locale )
         throws MojoExecutionException, IOException, MojoFailureException
     {

-- 
To stop receiving notification emails like this one, please contact
hboutemy@apache.org.