git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114783 13f79535-47bb-0310-9956-ffa450edef68
121 lines
2.7 KiB
Java
121 lines
2.7 KiB
Java
package org.apache.maven;
|
|
|
|
/* ====================================================================
|
|
* Copyright 2001-2004 The Apache Software Foundation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* ====================================================================
|
|
*/
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.apache.maven.project.Project;
|
|
|
|
/**
|
|
* @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
|
|
* @version $Id: ContentValidator.java,v 1.3 2004/03/02 15:35:14 evenisse Exp $
|
|
*/
|
|
public class ContentValidator
|
|
{
|
|
private List notices;
|
|
private Project project;
|
|
|
|
public ContentValidator()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @return Project
|
|
*/
|
|
public Project getProject()
|
|
{
|
|
return project;
|
|
}
|
|
|
|
/**
|
|
* Sets the project.
|
|
* @param project The project to set
|
|
*/
|
|
public void setProject(Project project)
|
|
{
|
|
this.project = project;
|
|
}
|
|
|
|
/**
|
|
* Adds a single notice to the list
|
|
* @param notice the notice to add
|
|
*/
|
|
protected void addNotice(ContentNotice notice)
|
|
{
|
|
notices.add(notice);
|
|
}
|
|
|
|
/**
|
|
* Adds a single notice to the list
|
|
* @param level
|
|
* @param section
|
|
* @param message
|
|
*/
|
|
protected void addNotice(String level, String section, String message)
|
|
{
|
|
addNotice(new ContentNotice(level, section, message));
|
|
}
|
|
|
|
/**
|
|
* Runs the validation routine and returns any notices
|
|
* @return List
|
|
*/
|
|
public List execute()
|
|
{
|
|
notices = new ArrayList();
|
|
validateProject();
|
|
return notices;
|
|
}
|
|
|
|
/**
|
|
* Validates the top level project item
|
|
*/
|
|
protected void validateProject()
|
|
{
|
|
if (project.getLogo() == null || project.getLogo().trim().length() == 0)
|
|
{
|
|
addNotice(ContentNotice.INFO, "/project/logo", "Element is null or empty. No logo will be displayed.");
|
|
}
|
|
|
|
validateLicenses();
|
|
}
|
|
|
|
/**
|
|
* Validates the licenses element
|
|
*/
|
|
protected void validateLicenses()
|
|
{
|
|
if (project.getLicenses().size() == 0)
|
|
{
|
|
addNotice(
|
|
ContentNotice.WARN,
|
|
"/project/licenses",
|
|
"No licenses defined. Your project has a license and it should be entered into the licenses section.");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Validates the developers element
|
|
*/
|
|
protected void validateDevelopers()
|
|
{
|
|
}
|
|
|
|
}
|