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.project.MavenProject; 23 24 /** 25 * A utility class for working with Project objects. 26 * 27 * @author Dennis Lundberg 28 * @version $Id: ProjectUtils.java 1765156 2016-10-16 13:54:35Z gboue $ 29 * @since 2.4 30 */ 31 public final class ProjectUtils 32 { 33 34 private ProjectUtils() 35 { 36 } 37 38 /** 39 * Check if the issue management system has been properly configured in the Maven project. 40 * 41 * @param project The Maven project 42 * @param issueManagementSystem The name of the issue management system that is required 43 * @param mojoResult What the calling mojo produces, used in the error messages 44 * @return <code>null</code> if the <issueManagement> element of the POM is complete, otherwise a String 45 * containing the reason of the failed validation. 46 */ 47 public static String validateIssueManagement( MavenProject project, String issueManagementSystem, 48 String mojoResult ) 49 { 50 if ( project.getIssueManagement() == null ) 51 { 52 return "No Issue Management set. No " + mojoResult + " will be generated."; 53 } 54 else if ( ( project.getIssueManagement().getUrl() == null ) 55 || ( project.getIssueManagement().getUrl().trim().equals( "" ) ) ) 56 { 57 return "No URL set in Issue Management. No " + mojoResult + " will be generated."; 58 } 59 else if ( ( project.getIssueManagement().getSystem() != null ) 60 && !( project.getIssueManagement().getSystem().equalsIgnoreCase( issueManagementSystem ) ) ) 61 { 62 return "The " + mojoResult + " only supports " + issueManagementSystem + ". No " + mojoResult 63 + " will be generated."; 64 } 65 return null; 66 } 67 }