public void addVersion(ConfigLocation newVersion) throws ResultException {
if (name == null)
name = newVersion.getConfigName();
else if (!name.equals(newVersion.getConfigName())){
ResultException ex = new ResultException("Name mismatch for ConfigVersion.");
ex.result.lastResult().moreMessages(DebugInfo.getCurrentStack());
throw(ex);
}
ConfigLocation existing = versions.get(newVersion.getVersion());
if (existing == null){
versions.put(newVersion.getVersion(),newVersion);
}
else{
if ( (existing.getJarFilename() != null) && (newVersion.getJarFilename() != null)){
// Some trickiness here. If we're grabbing stuff from jars, we might have jars
// where one jar prefix is a substring of another jar e.g. dark-matter-mvw and
// dark-matter-mvwgxt. We'll wind up parsing dark-matter-mvwgxt twice, so we
// what to be able to ignore cases where the jar names are equal
if (existing.getJarFilename().equals(newVersion.getJarFilename()))
return;
// We may include the same jar from two different paths, so if the jar file names
// match, we ignore the new one.
if (existing.getJustJarFilename().equals(newVersion.getJustJarFilename()))
return;
}
// We have a clashing version
ResultException ex = new ResultException("Clashing versions for the " + name + " configuration file.");
ex.result.lastResult().moreMessages("Originally from: " + existing.getFileName());
if (existing.getJarFilename() != null)
ex.result.lastResult().moreMessages(" in .jar: " + existing.getJarFilename());
ex.result.lastResult().moreMessages("Clashing version from: " + newVersion.getFileName());
if (newVersion.getJarFilename() != null)