![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.maven.plugins.pmd.ExcludeViolationsFromFile Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package org.apache.maven.plugins.pmd;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import net.sourceforge.pmd.reporting.RuleViolation;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.pmd.model.Violation;
/**
* This class contains utility for loading property files, which define which PMD violations
* from which classes should be ignored and not cause a failure.
* See property pmd.excludeFromFailureFile
.
*
* @author Andreas Dangel
*/
public class ExcludeViolationsFromFile implements ExcludeFromFile {
private Map> excludeFromFailureClasses = new HashMap<>();
@Override
public void loadExcludeFromFailuresData(final String excludeFromFailureFile) throws MojoExecutionException {
if (excludeFromFailureFile == null || excludeFromFailureFile.isEmpty()) {
return;
}
File file = new File(excludeFromFailureFile);
if (!file.exists()) {
return;
}
final Properties props = new Properties();
try (FileInputStream fileInputStream = new FileInputStream(new File(excludeFromFailureFile))) {
props.load(fileInputStream);
} catch (final IOException e) {
throw new MojoExecutionException("Cannot load properties file " + excludeFromFailureFile, e);
}
for (final Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy