Package com.lewisd.maven.lint.rules.opensource

Source Code of com.lewisd.maven.lint.rules.opensource.MissingCIManagementInformationRule

package com.lewisd.maven.lint.rules.opensource;

import com.lewisd.maven.lint.ResultCollector;
import com.lewisd.maven.lint.rules.AbstractRule;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.model.CiManagement;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.project.MavenProject;

import java.util.Map;

public class MissingCIManagementInformationRule extends AbstractRule {
    @Override
    public String getIdentifier() {
        return "OSSContinuousIntegrationManagementSectionRule";
    }

    @Override
    public String getDescription() {
        return "For better understanding the project a link to the used integration system helps users to trust.";
    }

    @Override
    public void invoke(MavenProject mavenProject, Map<String, Object> models, ResultCollector resultCollector) {
        CiManagement management = mavenProject.getCiManagement();

        if (null == management) {
            final InputSource source = new InputSource();
            source.setLocation(mavenProject.getOriginalModel().getPomFile() + "");
            InputLocation location = new InputLocation(0, 0, source);
            resultCollector.addViolation(mavenProject, this, "missing <ciManagement/> section", location);
        } else {
            if (StringUtils.isEmpty(management.getSystem())) {
                resultCollector.addViolation(mavenProject, this, "missing <system/> entry in <ciManagement/> section", management.getLocation(""));
            }
            if (StringUtils.isEmpty(management.getUrl())) {
                resultCollector.addViolation(mavenProject, this, "missing <url/> entry in <ciManagement/> section", management.getLocation(""));
            }
        }
    }
}
TOP

Related Classes of com.lewisd.maven.lint.rules.opensource.MissingCIManagementInformationRule

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.