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