private IvySettings createIvySettings()

in org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java [220:277]


    private IvySettings createIvySettings() throws IvyDEException {
        IvySettings ivySettings;
        if (isResolveInWorkspace()) {
            IvyDEMessage.verbose("Adding the workspace resolver to the settings");
            ivySettings = new WorkspaceIvySettings(getProject());
            DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
            BundleContext bundleContext = IvyPlugin.getDefault().getBundleContext();
            cacheManager.setBasedir(bundleContext.getDataFile("ivyde-workspace-resolver-cache"));
            cacheManager.setCheckmodified(true);
            cacheManager.setUseOrigin(true);
            cacheManager.setName(WorkspaceResolver.CACHE_NAME);
            ivySettings.addRepositoryCacheManager(cacheManager);
        } else {
            ivySettings = new IvySettings();
        }
        if (getProject() != null) {
            IPath location = getProject().getLocation();
            if (location != null) {
                ivySettings.setBaseDir(location.toFile());
            }
        }
        ResolvedPath ivyUserDir = getIvyUserDir();
        if (ivyUserDir.getError() != null) {
            throw new IvyDEException("Incorrect path of the Ivy user dir",
                    "The Ivy user dir '" + ivyUserDir.getInputPath() + "' is incorrect: "
                            + ivyUserDir.getError().getMessage(), ivyUserDir.getError());
        }
        if (ivyUserDir.isSet()) {
            ivySettings.setDefaultIvyUserDir(ivyUserDir.getFile());
        }
        Collection<String> propFiles = getPropertyFiles();
        if (propFiles == null || propFiles.isEmpty()) {
            IvyDEMessage.verbose("No property files to load");
        } else {
            IvyDEMessage.verbose(propFiles.size() + " property file(s) to load");
            for (String file : propFiles) {
                Path p = new Path(file);
                IvyDEMessage.debug("Loading property file " + p);
                String propFile = (getProject() != null && !p.isAbsolute())
                        ? getProject().getLocation().append(file).toString() : file;
                Properties props = new Properties();
                try (InputStream is = new FileInputStream(propFile)) {
                    props.load(is);
                } catch (FileNotFoundException e) {
                    throw new IvyDEException("Property file not found", "The property file '"
                            + propFile + "' was not found", e);
                } catch (IOException e) {
                    throw new IvyDEException("Not a property file", "The property file '"
                            + propFile + "' could not be loaded", e);
                }

                for (String key : props.stringPropertyNames()) {
                    ivySettings.setVariable(key, props.getProperty(key));
                }
            }
        }
        return ivySettings;
    }