in src/main/java/org/apache/easyant/tasks/SubModule.java [583:624]
private void copyReference(Project subproject, String oldKey, String newKey) {
Object orig = getProject().getReference(oldKey);
if (orig == null) {
log("No object referenced by " + oldKey + ". Can't copy to " + newKey, Project.MSG_WARN);
return;
}
Class<?> c = orig.getClass();
Object copy = orig;
Method cloneM;
try {
cloneM = c.getMethod("clone", new Class[0]);
if (cloneM != null) {
copy = cloneM.invoke(orig, new Object[0]);
log("Adding clone of reference " + oldKey, Project.MSG_DEBUG);
}
} catch (NoSuchMethodException e) {
// not clonable
} catch (IllegalAccessException e) {
// not clonable
} catch (InvocationTargetException e) {
// not clonable
}
if (copy instanceof ProjectComponent) {
((ProjectComponent) copy).setProject(subproject);
} else {
try {
Method setProjectM = c.getMethod("setProject", new Class[]{Project.class});
if (setProjectM != null) {
setProjectM.invoke(copy, subproject);
}
} catch (NoSuchMethodException e) {
// ignore this if the class being referenced does not have
// a set project method.
} catch (Exception e2) {
String msg = "Error setting new project instance for " + "reference with id " + oldKey;
throw new BuildException(msg, e2, getLocation());
}
}
subproject.addReference(newKey, copy);
}