*/
private ICheckConfiguration createOrGetCheckstyleConfig(
final ProjectConfigurationWorkingCopy pcWorkingCopy,
final URL ruleset, String executionId) throws CheckstylePluginException {
final ICheckConfigurationWorkingSet workingSet =
pcWorkingCopy.getLocalCheckConfigWorkingSet();
CheckConfigurationWorkingCopy workingCopy = null;
// Try to retrieve an existing checkstyle configuration to be updated
CheckConfigurationWorkingCopy[] workingCopies =
workingSet.getWorkingCopies();
final String configName = ECLIPSE_CS_PREFS_CONFIG_NAME + " " + executionId;
if (workingCopies != null) {
for (CheckConfigurationWorkingCopy copy : workingCopies) {
if (configName.equals(copy.getName())) {
if (this.remoteConfigurationType.equals(copy.getType())) {
workingCopy = copy;
break;
}
throw new CheckstylePluginException(String.format(
"A local Checkstyle configuration allready exists with name "
+ " [%s] with incompatible type [%s]",
configName, copy.getType()));
}
}
}
// Nothing exist create a brand new one.
if (workingCopy == null) {
// Create a fresh check config
workingCopy =
workingSet.newWorkingCopy(this.remoteConfigurationType);
workingCopy.setName(configName);
workingSet.addCheckConfiguration(workingCopy);
}
workingCopy.setDescription("maven-checkstyle-plugin configuration " + executionId);
workingCopy.setLocation(ruleset.toExternalForm());
return workingCopy;