return (Artifact) existingArtifacts.last();
}
private Artifact searchParents(Collection parentConfigurations, Artifact working) {
for (Iterator iterator = parentConfigurations.iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
// check if this parent matches the groupId, artifactId, and type
if (matches(configuration.getId(), working)) {
return configuration.getId();
}
Environment environment = configuration.getEnvironment();
if (environment.isInverseClassLoading()) {
// Search dependencies of the configuration before searching the parents
Artifact artifact = getArtifactVersion(configuration.getDependencies(), working);
if (artifact != null) {
return artifact;
}
// wasn't declared in the dependencies, so search the parents of the configuration
artifact = searchParents(configuration.getClassParents(), working);
if (artifact != null) {
return artifact;
}
} else {
// Search the parents before the dependencies of the configuration
Artifact artifact = searchParents(configuration.getClassParents(), working);
if (artifact != null) {
return artifact;
}
// wasn't declared in a parent check the dependencies of the configuration
artifact = getArtifactVersion(configuration.getDependencies(), working);
if (artifact != null) {
return artifact;
}
}
}