* @param project
* TODO add text.
* @return An IvySetting instance.
*/
public static IvyAntSettings getDefaultInstance(ProjectComponent task) {
Project project = task.getProject();
Object defaultInstanceObj = project.getReference("ivy.instance");
if (defaultInstanceObj != null
&& defaultInstanceObj.getClass().getClassLoader() != IvyAntSettings.class
.getClassLoader()) {
task.log("ivy.instance reference an ivy:settings defined in an other classloader. "
+ "An new default one will be used in this project.", Project.MSG_WARN);
defaultInstanceObj = null;
}
if (defaultInstanceObj != null && !(defaultInstanceObj instanceof IvyAntSettings)) {
throw new BuildException("ivy.instance reference a "
+ defaultInstanceObj.getClass().getName()
+ " an not an IvyAntSettings. Please don't use this reference id ()");
}
if (defaultInstanceObj == null) {
task.log("No ivy:settings found for the default reference 'ivy.instance'. "
+ "A default instance will be used", Project.MSG_VERBOSE);
IvyAntSettings settings = new IvyAntSettings();
settings.setProject(project);
project.addReference("ivy.instance", settings);
settings.createIvyEngine(task);
return settings;
} else {
return (IvyAntSettings) defaultInstanceObj;
}