You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2014/03/17 23:05:52 UTC

svn commit: r1578624 - in /maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin: changes/AbstractChangesReport.java changes/ChangesMojo.java github/GitHubMojo.java jira/JiraMojo.java trac/TracMojo.java

Author: dennisl
Date: Mon Mar 17 22:05:52 2014
New Revision: 1578624

URL: http://svn.apache.org/r1578624
Log:
[MCHANGES-266] It is not possible to disable the reports in submodules

Modified:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/AbstractChangesReport.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/github/GitHubMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/AbstractChangesReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/AbstractChangesReport.java?rev=1578624&r1=1578623&r2=1578624&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/AbstractChangesReport.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/AbstractChangesReport.java Mon Mar 17 22:05:52 2014
@@ -36,6 +36,7 @@ import org.apache.maven.doxia.siterender
 import org.apache.maven.doxia.siterenderer.RendererException;
 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -67,6 +68,14 @@ public abstract class AbstractChangesRep
     extends AbstractMavenReport
 {
     /**
+     * The current project base directory.
+     *
+     * @since 2.10
+     */
+    @Parameter( property = "basedir", required = true )
+    protected String basedir;
+
+    /**
      * Report output directory. Note that this parameter is only relevant if the goal is run from the command line or
      * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output
      * directory configured in the Maven Site Plugin is used instead.
@@ -85,6 +94,24 @@ public abstract class AbstractChangesRep
     private String outputEncoding;
 
     /**
+     * This will cause the execution to be run only at the top of a given module
+     * tree. That is, run in the project contained in the same folder where the
+     * mvn execution was launched.
+     *
+     * @since 2.10
+     */
+    @Parameter( property = "changes.runOnlyAtExecutionRoot", defaultValue = "false" )
+    protected boolean runOnlyAtExecutionRoot;
+
+    /**
+     * The Maven Session.
+     *
+     * @since 2.10
+     */
+    @Component
+    protected MavenSession mavenSession;
+
+    /**
      * Doxia Site Renderer.
      */
     @Component
@@ -244,4 +271,26 @@ public abstract class AbstractChangesRep
     {
         return siteRenderer;
     }
+
+    /**
+     * Returns <code>true</code> if the current project is located at the
+     * Execution Root Directory (where mvn was launched).
+     *
+     * @return <code>true</code> if the current project is at the Execution Root
+     */
+    protected boolean isThisTheExecutionRoot()
+    {
+        getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
+        getLog().debug( "Current Folder:" + basedir );
+        boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir );
+        if ( result )
+        {
+            getLog().debug( "This is the execution root." );
+        }
+        else
+        {
+            getLog().debug( "This is NOT the execution root." );
+        }
+        return result;
+    }
 }

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java?rev=1578624&r1=1578623&r2=1578624&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesMojo.java Mon Mar 17 22:05:52 2014
@@ -238,6 +238,12 @@ public class ChangesMojo
 
     public boolean canGenerateReport()
     {
+        // Run only at the execution root
+        if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
+        {
+            getLog().info( "Skipping the Changes Report in this project because it's not the Execution Root" );
+            return false;
+        }
         return xmlPath.isFile();
     }
 

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/github/GitHubMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/github/GitHubMojo.java?rev=1578624&r1=1578623&r2=1578624&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/github/GitHubMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/github/GitHubMojo.java Mon Mar 17 22:05:52 2014
@@ -136,6 +136,12 @@ public class GitHubMojo
      */
     public boolean canGenerateReport()
     {
+        // Run only at the execution root
+        if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
+        {
+            getLog().info( "Skipping the GitHub Report in this project because it's not the Execution Root" );
+            return false;
+        }
         return ProjectUtils.validateIfIssueManagementComplete( project, "GitHub", "GitHub Report", getLog() );
     }
 

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java?rev=1578624&r1=1578623&r2=1578624&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java Mon Mar 17 22:05:52 2014
@@ -326,6 +326,12 @@ public class JiraMojo
      */
     public boolean canGenerateReport()
     {
+        // Run only at the execution root
+        if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
+        {
+            getLog().info( "Skipping the JIRA Report in this project because it's not the Execution Root" );
+            return false;
+        }
         if ( skip )
         {
             return false;

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java?rev=1578624&r1=1578623&r2=1578624&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java Mon Mar 17 22:05:52 2014
@@ -132,6 +132,12 @@ public class TracMojo
      */
     public boolean canGenerateReport()
     {
+        // Run only at the execution root
+        if ( runOnlyAtExecutionRoot && !isThisTheExecutionRoot() )
+        {
+            getLog().info( "Skipping the Trac Report in this project because it's not the Execution Root" );
+            return false;
+        }
         return ProjectUtils.validateIfIssueManagementComplete( project, "Trac", "Trac Report", getLog() );
     }