View Javadoc
1   package org.apache.maven.plugin.changes;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.execution.MavenSession;
23  import org.apache.maven.plugin.AbstractMojo;
24  import org.apache.maven.plugins.annotations.Parameter;
25  
26  /**
27   * Abstract superclass for announcement mojos.
28   *
29   * @version $Id: AbstractChangesMojo.java 1685894 2015-06-16 19:29:09Z khmarbaise $
30   * @since 2.9
31   */
32  public abstract class AbstractChangesMojo
33      extends AbstractMojo
34  {
35      /**
36       * The current project base directory.
37       *
38       * @since 2.1
39       */
40      @Parameter( property = "basedir", required = true )
41      protected String basedir;
42  
43      /**
44       * The Maven Session.
45       *
46       * @since 2.3
47       */
48      @Parameter( defaultValue = "${session}", readonly = true, required = true )
49      protected MavenSession mavenSession;
50  
51      /**
52       * This will cause the execution to be run only at the top of a given module tree. That is, run in the project
53       * contained in the same folder where the mvn execution was launched.
54       *
55       * @since 2.9
56       */
57      @Parameter( property = "changes.runOnlyAtExecutionRoot", defaultValue = "false" )
58      protected boolean runOnlyAtExecutionRoot;
59  
60      /**
61       * Returns <code>true</code> if the current project is located at the Execution Root Directory (where mvn was
62       * launched).
63       *
64       * @return <code>true</code> if the current project is at the Execution Root
65       */
66      protected boolean isThisTheExecutionRoot()
67      {
68          getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
69          getLog().debug( "Current Folder:" + basedir );
70          boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir );
71          if ( result )
72          {
73              getLog().debug( "This is the execution root." );
74          }
75          else
76          {
77              getLog().debug( "This is NOT the execution root." );
78          }
79          return result;
80      }
81  }