com.lewisd.maven.lint.rules.opensource.MissingInceptionYearRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lint-maven-plugin Show documentation
Show all versions of lint-maven-plugin Show documentation
Generates a report of suspicious/inconsistent POM elements, and optionally fails the build if violations are found.
The newest version!
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.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.project.MavenProject;
import java.util.Map;
public class MissingInceptionYearRule extends AbstractRule {
@Override
public String getIdentifier() {
return "OSSInceptionYearRule";
}
@Override
public String getDescription() {
return "For better understanding the project the inception year of your project is required.";
}
@Override
public void invoke(MavenProject mavenProject, Map models, ResultCollector resultCollector) {
final String inceptionYear = mavenProject.getInceptionYear();
if (StringUtils.isEmpty(inceptionYear)) {
resultCollector.addViolation(mavenProject, this, "missing information", getEmptyLocation(mavenProject));
}else if (!inceptionYear.matches("\\d{4}")){
InputLocation location = mavenProject.getOriginalModel().getLocation("inceptionYear");
resultCollector.addViolation(mavenProject, this, "format of information is wrong, only 4 digits allowed", location);
}
}
private InputLocation getEmptyLocation(MavenProject mavenProject) {
final InputSource source = new InputSource();
source.setLocation(mavenProject.getOriginalModel().getPomFile() + "");
return new InputLocation(0, 0, source);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy