/**
*
*/
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 (null == null) {
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(buildModule.getParent(), "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.toString());
try {
projectIvyInstance.setUrl(defaultUrl);
} catch (MalformedURLException e) {
throw new BuildException("Unable to parse project ivysettings from the following url : "
+ defaultUrl, e);
}
}