1 /* 2 * Copyright 2012 smartics, Kronseder & Reiner GmbH 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 de.smartics.maven.bugzilla; 17 18 import org.apache.commons.lang.StringUtils; 19 import org.apache.maven.plugin.MojoExecutionException; 20 import org.apache.maven.plugin.MojoFailureException; 21 import org.apache.maven.project.MavenProject; 22 23 import de.smartics.maven.bugzilla.AbstractMojoHelperProduct.ProductInfo; 24 25 /** 26 * Adds this project as new product on the issue management server. 27 * 28 * @goal addProduct 29 * @requiresProject 30 * @threadSafe 31 * @since 1.0 32 * @description Adds this project as a new product on the issue management 33 * server. 34 */ 35 public class AddProductMojo extends AbstractProductMojo 36 { 37 // ********************************* Fields ********************************* 38 39 // --- constants ------------------------------------------------------------ 40 41 // --- members -------------------------------------------------------------- 42 43 /** 44 * The optional classification for the product. 45 * 46 * @parameter expression="${classification}" 47 * default-value="${project.groupId}" 48 * @since 1.0 49 */ 50 protected String classification; 51 52 // ****************************** Initializer ******************************* 53 54 // ****************************** Constructors ****************************** 55 56 // ****************************** Inner Classes ***************************** 57 58 // ********************************* Methods ******************************** 59 60 // --- init ----------------------------------------------------------------- 61 62 // --- get&set -------------------------------------------------------------- 63 64 // --- business ------------------------------------------------------------- 65 66 // CHECKSTYLE:OFF 67 /** 68 * {@inheritDoc} 69 */ 70 public void run() throws MojoExecutionException, MojoFailureException 71 { 72 // CHECKSTYLE:ON 73 final String classification = getClassification(); 74 final String initialVersion = getInitialVersion(); 75 final ProductInfo productInfo = createProductInfo(); 76 final MavenProject project = getProject(); 77 78 final MojoHelperProductAdd helper = 79 new MojoHelperProductAdd(project, commandFactory, console, 80 classification, productInfo, initialVersion); 81 helper.execute(); 82 } 83 84 /** 85 * Returns the classification the product is to be added to. 86 * 87 * @return the classification the product is to be added to. 88 */ 89 protected final String getClassification() 90 { 91 if (StringUtils.isNotBlank(classification)) 92 { 93 return classification; 94 } 95 final MavenProject project = getProject(); 96 return project.getGroupId(); 97 } 98 99 // --- object basics -------------------------------------------------------- 100 101 }