use of net.sourceforge.pmd.cpd.JSPLanguage in project maven-plugins by apache.
the class CpdReport method executeCpd.
private void executeCpd() throws MavenReportException {
if (cpd != null) {
// CPD has already been run
getLog().debug("CPD has already been run - skipping redundant execution.");
return;
}
Properties p = new Properties();
if (ignoreLiterals) {
p.setProperty(JavaTokenizer.IGNORE_LITERALS, "true");
}
if (ignoreIdentifiers) {
p.setProperty(JavaTokenizer.IGNORE_IDENTIFIERS, "true");
}
try {
if (filesToProcess == null) {
filesToProcess = getFilesToProcess();
}
try {
excludeDuplicationsFromFile.loadExcludeFromFailuresData(excludeFromFailureFile);
} catch (MojoExecutionException e) {
throw new MavenReportException("Error loading exclusions", e);
}
String encoding = determineEncoding(!filesToProcess.isEmpty());
Language cpdLanguage;
if ("java".equals(language) || null == language) {
cpdLanguage = new JavaLanguage(p);
} else if ("javascript".equals(language)) {
cpdLanguage = new EcmascriptLanguage();
} else if ("jsp".equals(language)) {
cpdLanguage = new JSPLanguage();
} else {
cpdLanguage = LanguageFactory.createLanguage(language, p);
}
CPDConfiguration cpdConfiguration = new CPDConfiguration();
cpdConfiguration.setMinimumTileSize(minimumTokens);
cpdConfiguration.setLanguage(cpdLanguage);
cpdConfiguration.setSourceEncoding(encoding);
cpd = new CPD(cpdConfiguration);
for (File file : filesToProcess.keySet()) {
cpd.add(file);
}
} catch (UnsupportedEncodingException e) {
throw new MavenReportException("Encoding '" + getSourceEncoding() + "' is not supported.", e);
} catch (IOException e) {
throw new MavenReportException(e.getMessage(), e);
}
getLog().debug("Executing CPD...");
cpd.go();
getLog().debug("CPD finished.");
// so the "check" goals can check for violations
if (isXml()) {
writeNonHtml(cpd);
}
}
use of net.sourceforge.pmd.cpd.JSPLanguage in project maven-plugins by apache.
the class CpdReport method executeCpd.
private void executeCpd() throws MavenReportException {
if (cpd != null) {
// CPD has already been run
getLog().debug("CPD has already been run - skipping redundant execution.");
return;
}
Properties p = new Properties();
if (ignoreLiterals) {
p.setProperty(JavaTokenizer.IGNORE_LITERALS, "true");
}
if (ignoreIdentifiers) {
p.setProperty(JavaTokenizer.IGNORE_IDENTIFIERS, "true");
}
try {
if (filesToProcess == null) {
filesToProcess = getFilesToProcess();
}
try {
excludeDuplicationsFromFile.loadExcludeFromFailuresData(excludeFromFailureFile);
} catch (MojoExecutionException e) {
throw new MavenReportException("Error loading exclusions", e);
}
String encoding = determineEncoding(!filesToProcess.isEmpty());
Language cpdLanguage;
if ("java".equals(language) || null == language) {
cpdLanguage = new JavaLanguage(p);
} else if ("javascript".equals(language)) {
cpdLanguage = new EcmascriptLanguage();
} else if ("jsp".equals(language)) {
cpdLanguage = new JSPLanguage();
} else {
cpdLanguage = LanguageFactory.createLanguage(language, p);
}
CPDConfiguration cpdConfiguration = new CPDConfiguration();
cpdConfiguration.setMinimumTileSize(minimumTokens);
cpdConfiguration.setLanguage(cpdLanguage);
cpdConfiguration.setSourceEncoding(encoding);
cpd = new CPD(cpdConfiguration);
for (File file : filesToProcess.keySet()) {
cpd.add(file);
}
} catch (UnsupportedEncodingException e) {
throw new MavenReportException("Encoding '" + getSourceEncoding() + "' is not supported.", e);
} catch (IOException e) {
throw new MavenReportException(e.getMessage(), e);
}
getLog().debug("Executing CPD...");
cpd.go();
getLog().debug("CPD finished.");
// so the "check" goals can check for violations
if (isXml()) {
writeNonHtml(cpd);
}
}
Aggregations