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.plugin.logging.Log;
23 import org.apache.maven.project.MavenProject;
24
25 /**
26 * A utility class for working with Project objects.
27 *
28 * @author Dennis Lundberg
29 * @version $Id: ProjectUtils.html 816601 2012-05-08 12:50:18Z hboutemy $
30 * @since 2.4
31 */
32 public class ProjectUtils
33 {
34 /**
35 * Check if the issue management system has been properly configured in the Maven project.
36 *
37 * @param project The Maven project
38 * @param issueManagementSystem The name of the issue management system that is required
39 * @param mojoResult What the calling mojo produces, used in the error messages
40 * @param log A log
41 * @return <code>true</code> if the <issueManagement> element of the POM is complete,
42 * otherwise <code>false</code>
43 */
44 public static boolean validateIfIssueManagementComplete( MavenProject project, String issueManagementSystem,
45 String mojoResult, Log log )
46 {
47 if ( project.getIssueManagement() == null )
48 {
49 log.error( "No Issue Management set. No " + mojoResult + " will be generated." );
50
51 return false;
52 }
53 else if ( ( project.getIssueManagement().getUrl() == null )
54 || ( project.getIssueManagement().getUrl().trim().equals( "" ) ) )
55 {
56 log.error( "No URL set in Issue Management. No " + mojoResult + " will be generated." );
57
58 return false;
59 }
60 else if ( ( project.getIssueManagement().getSystem() != null )
61 && !( project.getIssueManagement().getSystem().equalsIgnoreCase( issueManagementSystem ) ) )
62 {
63 log.error( "The " + mojoResult + " only supports " + issueManagementSystem + ". No " + mojoResult
64 + " will be generated." );
65
66 return false;
67 }
68 return true;
69 }
70 }