1 /** 2 * Copyright 1&1 Internet AG, https://github.com/1and1/ 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package net.oneandone.maven.plugins.billofmaterials; 17 18 import java.io.File; 19 import org.apache.maven.plugin.AbstractMojo; 20 import org.apache.maven.plugins.annotations.Parameter; 21 import org.apache.maven.project.MavenProject; 22 23 /** 24 * Abstract class implementing the calculation of the bill of materials file. 25 * 26 * @author Mirko Friedenhagen <mirko.friedenhagen@1und1.de> 27 */ 28 public abstract class AbstractBillOfMaterialsMojo extends AbstractMojo { 29 30 /** 31 * Absolute path to the output-file. 32 */ 33 @Parameter( 34 defaultValue = "${session.executionRootDirectory}/target/tickets/bill-of-materials.txt", 35 required = true, property = "bill-of-materials.bomPath") 36 private File bomPath; 37 38 /** 39 * The Maven project. 40 */ 41 @Parameter(defaultValue = "${project}", readonly = true) 42 private MavenProject project; 43 44 /** 45 * Default constructor for maven. 46 */ 47 AbstractBillOfMaterialsMojo() { 48 super(); 49 } 50 51 /** 52 * Just for tests. 53 * @param billOfMaterialsPath relative path to bom. 54 * @param project current project 55 */ 56 AbstractBillOfMaterialsMojo(File billOfMaterialsPath, MavenProject project) { 57 this.bomPath = billOfMaterialsPath; 58 this.project = project; 59 } 60 61 62 /** 63 * Returns the {@link File} pointing to the bill of materials. 64 * 65 * @return {@link File} pointing to the bill of materials. 66 */ 67 File calculateBillOfMaterialsFile() { 68 return bomPath; 69 } 70 71 /** 72 * @return the project 73 */ 74 MavenProject getProject() { 75 return project; 76 } 77 }