-cpus command line option added

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4872 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch
2006-12-13 22:04:26 +00:00
parent 62d1e9ee73
commit fe18d61b70
2 changed files with 22 additions and 9 deletions

View File

@ -23,6 +23,7 @@ public class CommandLineOptions {
private boolean debugEnabled;
private String targetJDK = "1.4";
private boolean shortNamesEnabled;
private int cpus = Runtime.getRuntime().availableProcessors();
private String excludeMarker = PMD.EXCLUDE_MARKER;
private String inputPath;
@ -57,26 +58,34 @@ public class CommandLineOptions {
} else if (args[i].equals("-shortnames")) {
shortNamesEnabled = true;
} else if (args[i].equals("-encoding")) {
encoding = args[i + 1];
encoding = args[++i];
} else if (args[i].equals("-cpus")) {
try {
cpus = Integer.parseInt(args[++i]);
} catch (NumberFormatException e) {
throw new RuntimeException(MessageFormat.format(
"cpus parameter must be a whole number, {0} received",
new String[] { args[i] }));
}
} else if (args[i].equals("-targetjdk")) {
targetJDK = args[i + 1];
targetJDK = args[++i];
} else if (args[i].equals("-excludemarker")) {
excludeMarker = args[i + 1];
excludeMarker = args[++i];
} else if (args[i].equals("-jsp")) {
checkJspFiles = true;
} else if (args[i].equals("-nojava")) {
checkJavaFiles = false;
} else if (args[i].equals("-lineprefix")) {
linePrefix = args[i + 1];
linePrefix = args[++i];
} else if (args[i].equals("-linkprefix")) {
linkPrefix = args[i + 1];
linkPrefix = args[++i];
} else if (args[i].equals("-minimumpriority")) {
try {
minPriority = Integer.parseInt(args[i + 1]);
minPriority = Integer.parseInt(args[++i]);
} catch (NumberFormatException e) {
throw new RuntimeException(MessageFormat.format(
"minimumpriority parameter must be a whole number, {0} received",
new String[] { args[i + 1] }));
new String[] { args[i] }));
}
}
}
@ -144,6 +153,10 @@ public class CommandLineOptions {
return debugEnabled;
}
public int getCpus() {
return cpus;
}
public String getTargetJDK() {
return targetJDK;
}
@ -169,6 +182,7 @@ public class CommandLineOptions {
"Optional arguments that may be put after the mandatory arguments are: " + PMD.EOL +
"-debug: prints debugging information " + PMD.EOL +
"-targetjdk: specifies a language version to target - 1.3, 1.4, 1.5 or 1.6" + PMD.EOL +
"-cpus: specifies the number of threads to create" + PMD.EOL +
"-encoding: specifies the character set encoding of the source code files PMD is reading (i.e., UTF-8)" + PMD.EOL +
"-excludemarker: specifies the String that marks the a line which PMD should ignore; default is NOPMD" + PMD.EOL +
"-shortnames: prints shortened filenames in the report" + PMD.EOL +

View File

@ -263,8 +263,7 @@ public class PMD {
RuleSets rulesets = ruleSetFactory.createRuleSets(opts.getRulesets());
printRuleNamesInDebug(opts.debugEnabled(), rulesets);
int threadCount = Runtime.getRuntime().availableProcessors();
processFiles(threadCount, ruleSetFactory, sourceType, files, ctx,
processFiles(opts.getCpus(), ruleSetFactory, sourceType, files, ctx,
opts.getRulesets(), opts.debugEnabled(), opts.shortNamesEnabled(),
opts.getInputPath(), opts.getEncoding(), opts.getExcludeMarker());
} catch (RuleSetNotFoundException rsnfe) {