1 package org.apache.maven.plugin.announcement;
2
3 import org.apache.maven.plugin.AbstractMojo;
4 import org.apache.maven.execution.MavenSession;
5
6 /**
7 * Abstract superclass for announcement mojos.
8 *
9 * @version $Id: AbstractAnnouncementMojo.html 816595 2012-05-08 12:43:00Z hboutemy $
10 * @since 2.3
11 */
12 public abstract class AbstractAnnouncementMojo extends AbstractMojo {
13 /**
14 * The current project base directory.
15 *
16 * @parameter expression="${basedir}"
17 * @required
18 * @since 2.1
19 */
20 protected String basedir;
21
22 /**
23 * The Maven Session.
24 *
25 * @parameter expression="${session}"
26 * @readonly
27 * @required
28 * @since 2.3
29 */
30 protected MavenSession mavenSession;
31
32 /**
33 * This will cause the execution to be run only at the top of a given module
34 * tree. That is, run in the project contained in the same folder where the
35 * mvn execution was launched.
36 *
37 * @parameter expression="${announcement.runOnlyAtExecutionRoot}" default-value="false"
38 * @since 2.3
39 */
40 protected boolean runOnlyAtExecutionRoot;
41
42 /**
43 * Returns <code>true</code> if the current project is located at the
44 * Execution Root Directory (where mvn was launched).
45 *
46 * @return <code>true</code> if the current project is at the Execution Root
47 */
48 protected boolean isThisTheExecutionRoot()
49 {
50 getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
51 getLog().debug( "Current Folder:" + basedir );
52 boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir.toString() );
53 if ( result )
54 {
55 getLog().debug( "This is the execution root." );
56 }
57 else
58 {
59 getLog().debug( "This is NOT the execution root." );
60 }
61 return result;
62 }
63 }