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 1620206 2014-08-24 22:03:05Z hboutemy $ 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 53 * tree. That is, run in the project contained in the same folder where the 54 * mvn execution was launched. 55 * 56 * @since 2.9 57 */ 58 @Parameter( property = "changes.runOnlyAtExecutionRoot", defaultValue = "false" ) 59 protected boolean runOnlyAtExecutionRoot; 60 61 /** 62 * Returns <code>true</code> if the current project is located at the 63 * Execution Root Directory (where mvn was launched). 64 * 65 * @return <code>true</code> if the current project is at the Execution Root 66 */ 67 protected boolean isThisTheExecutionRoot() 68 { 69 getLog().debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() ); 70 getLog().debug( "Current Folder:" + basedir ); 71 boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir ); 72 if ( result ) 73 { 74 getLog().debug( "This is the execution root." ); 75 } 76 else 77 { 78 getLog().debug( "This is NOT the execution root." ); 79 } 80 return result; 81 } 82 }