*/
private void resolveProjectDependencies() {
// Create a set of old and new artifacts.
Set<ClassPathSupport.Item> oldArtifacts = new HashSet<ClassPathSupport.Item>();
EditableProperties projectProperties = updateHelper.getProperties( AntProjectHelper.PROJECT_PROPERTIES_PATH );
oldArtifacts.addAll( cs.itemsList( projectProperties.get( ProjectProperties.JAVAC_CLASSPATH ) ) );
oldArtifacts.addAll( cs.itemsList( projectProperties.get( ProjectProperties.JAVAC_TEST_CLASSPATH ) ) );
oldArtifacts.addAll( cs.itemsList( projectProperties.get( ProjectProperties.RUN_CLASSPATH ) ) );
oldArtifacts.addAll( cs.itemsList( projectProperties.get( ProjectProperties.RUN_TEST_CLASSPATH ) ) );
Set<ClassPathSupport.Item> newArtifacts = new HashSet<ClassPathSupport.Item>();
newArtifacts.addAll( ClassPathUiSupport.getList( JAVAC_CLASSPATH_MODEL ) );
newArtifacts.addAll( ClassPathUiSupport.getList( JAVAC_TEST_CLASSPATH_MODEL ) );
newArtifacts.addAll( ClassPathUiSupport.getList( RUN_CLASSPATH_MODEL ) );
newArtifacts.addAll( ClassPathUiSupport.getList( RUN_TEST_CLASSPATH_MODEL ) );
// Create set of removed artifacts and remove them
Set<ClassPathSupport.Item> removed = new HashSet<ClassPathSupport.Item>(oldArtifacts);
removed.removeAll( newArtifacts );
Set<ClassPathSupport.Item> added = new HashSet<ClassPathSupport.Item>(newArtifacts);
added.removeAll(oldArtifacts);
// 1. first remove all project references. The method will modify
// project property files, so it must be done separately
for (ClassPathSupport.Item item : removed) {
if ( item.getType() == ClassPathSupport.Item.TYPE_ARTIFACT ||
item.getType() == ClassPathSupport.Item.TYPE_JAR ) {
refHelper.destroyReference(item.getReference());
if (item.getType() == ClassPathSupport.Item.TYPE_JAR) {
item.removeSourceAndJavadoc(updateHelper);
}
}
}
boolean changed = false;
// 2. now read project.properties and modify rest
EditableProperties ep = updateHelper.getProperties( AntProjectHelper.PROJECT_PROPERTIES_PATH );
for (ClassPathSupport.Item item : removed) {
if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) {
// remove helper property pointing to library jar if there is any
String prop = item.getReference();
prop = CommonProjectUtils.getAntPropertyName(prop);
ep.remove(prop);
changed = true;
}
}
if (changed) {
updateHelper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);