in src/main/java/org/apache/easyant/tasks/LoadModule.java [184:254]
private void configureProjectIvyinstance(String projectIvyInstanceName) {
IvyConfigure projectIvyInstance = new IvyConfigure();
projectIvyInstance.setSettingsId(projectIvyInstanceName);
boolean ivysettingsConfigured = false;
// project ivy settings can be specified by properties
if (getProject().getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_FILE) != null) {
File projectIvyFile = new File(getProject().getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_FILE));
if (projectIvyFile.exists()) {
projectIvyInstance.setFile(projectIvyFile);
ivysettingsConfigured = true;
}
}
if (getProject().getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_URL) != null) {
String url = getProject().getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_URL);
try {
projectIvyInstance.setUrl(url);
ivysettingsConfigured = true;
} catch (MalformedURLException malformedUrl) {
throw new BuildException("Unable to parse project ivysettings from the following url : " + url,
malformedUrl);
}
}
// if no property is set check the default user location
if (!ivysettingsConfigured) {
File userProjectIvyFile = new File(getProject().replaceProperties(
EasyAntConstants.DEFAULT_USER_PROJECT_IVYSETTINGS));
if (userProjectIvyFile.exists()) {
projectIvyInstance.setFile(userProjectIvyFile);
ivysettingsConfigured = true;
}
}
// set default project ivy settings location accessible through properties,
// then users can import it if they don't want to use it directly
String defaultUrl = this.getClass().getResource("/org/apache/easyant/core/default-project-ivysettings.xml")
.toExternalForm();
getProject().setNewProperty(EasyAntMagicNames.PROJECT_DEFAULT_IVYSETTINGS, defaultUrl);
if (!ivysettingsConfigured) {
File localSettings = new File(getProject().getBaseDir(), "ivysettings.xml");
if (localSettings.exists()) {
getProject().log("loading local project settings file...", Project.MSG_VERBOSE);
projectIvyInstance.setFile(localSettings);
getProject()
.setNewProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_FILE, localSettings.getAbsolutePath());
} else {
getProject().log("no settings file found, using default...", Project.MSG_VERBOSE);
getProject().setNewProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_URL, defaultUrl);
try {
projectIvyInstance.setUrl(defaultUrl);
} catch (MalformedURLException e) {
throw new BuildException("Unable to parse project ivysettings from the following url : "
+ defaultUrl, e);
}
}
}
initTask(projectIvyInstance).perform();
// FIXME: hack as ResolutionCacheManager use XmlModuleDescriptorParser under the hood
EasyAntRepositoryCacheManager cacheManager = new EasyAntRepositoryCacheManager("default-project-cache",
getProjectIvyInstance().getSettings(), getProjectIvyInstance().getSettings().getDefaultCache());
getProjectIvyInstance().getSettings().setDefaultRepositoryCacheManager(cacheManager);
EasyantResolutionCacheManager resolutionCacheManager = new EasyantResolutionCacheManager();
resolutionCacheManager.setBasedir(getProjectIvyInstance().getSettings().getDefaultResolutionCacheBasedir());
resolutionCacheManager.setSettings(getProjectIvyInstance().getSettings());
getProjectIvyInstance().getSettings().setResolutionCacheManager(resolutionCacheManager);
}