Package org.apache.ivyde.eclipse

Examples of org.apache.ivyde.eclipse.IvyDEException


    }

    private Ivy doGetIvy() throws IvyDEException {
        ResolvedPath settingsPath = getIvySettingsPath();
        if (settingsPath.getError() != null) {
            throw new IvyDEException("Incorrect path of the Ivy settings",
                    "The Ivy settings path '" + settingsPath.getInputPath() + "' is incorrect: "
                            + settingsPath.getError().getMessage(), settingsPath.getError());
        }
        if (!settingsPath.isSet()) {
            IvyDEMessage.debug("No settings specified, so take the default one");
            if (ivy == null) {
                IvySettings ivySettings = createIvySettings();
                ivy = Ivy.newInstance(ivySettings);
                try {
                    ivy.configureDefault();
                } catch (ParseException e) {
                    ivy = null;
                    IvyDEException ex = new IvyDEException(
                            "Parsing error of the default Ivy settings",
                            "The default Ivy settings file could not be parsed: " + e.getMessage(),
                            e);
                    throw ex;
                } catch (IOException e) {
                    ivy = null;
                    throw new IvyDEException("Read error of the default Ivy settings",
                            "The default Ivy settings file could not be read: " + e.getMessage(), e);
                }
            }
            return ivy;
        }

        // before returning the found ivy, try to refresh it if the settings changed
        if (settingsPath.getFile() != null) {
            return getIvyFromFile(settingsPath);
        } else {
            // an URL but not a file
            if (ivy == null || ivySettingsLastModified == -1) {
                IvySettings ivySettings = createIvySettings();
                ivy = Ivy.newInstance(ivySettings);
                try {
                    ivy.configure(settingsPath.getUrl());
                    ivySettingsLastModified = 0;
                } catch (ParseException e) {
                    ivy = null;
                    throw new IvyDEException("Parsing error of the Ivy settings",
                            "The ivy settings file '" + settingsPath.getResolvedPath()
                                    + "' could not be parsed: " + e.getMessage(), e);
                } catch (IOException e) {
                    ivy = null;
                    throw new IvyDEException("Read error of the Ivy settings",
                            "The ivy settings file '" + settingsPath.getResolvedPath()
                                    + "' could not be read: " + e.getMessage(), e);
                }
            }
        }
View Full Code Here


    private Ivy getIvyFromFile(ResolvedPath ivySettingsPath) throws IvyDEException {
        File file = ivySettingsPath.getFile();
        IvyDEMessage.debug("Loading settings from local file " + file);
        if (!file.exists()) {
            throw new IvyDEException("Ivy settings file not found", "The Ivy settings file '"
                    + ivySettingsPath.getResolvedPath() + "' cannot be found", null);
        }

        if (file.lastModified() != ivySettingsLastModified || !isLoadSettingsOnDemandPath()) {
            if (ivySettingsLastModified != -1) {
                IvyDEMessage.info("Settings has changed, configuring Ivy again");
            }
            IvySettings ivySettings = createIvySettings();
            ivy = Ivy.newInstance(ivySettings);
            try {
                ivy.configure(file);
            } catch (ParseException e) {
                ivy = null;
                throw new IvyDEException("Parsing error of the Ivy settings",
                        "The ivy settings file '" + ivySettingsPath.getResolvedPath()
                                + "' could not be parsed: " + e.getMessage(), e);
            } catch (IOException e) {
                ivy = null;
                throw new IvyDEException("Read error of the Ivy settings",
                        "The ivy settings file '" + ivySettingsPath.getResolvedPath()
                                + "' could not be read: " + e.getMessage(), e);
            }
            ivySettingsLastModified = file.lastModified();
        } else {
View Full Code Here

                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 propFiles = getPropertyFiles();
        if (propFiles == null || propFiles.isEmpty()) {
            IvyDEMessage.verbose("No property files to load");
        } else {
            IvyDEMessage.verbose(propFiles.size() + " property file(s) to load");
            Iterator iter = propFiles.iterator();
            while (iter.hasNext()) {
                String file = (String) iter.next();
                InputStream is;
                Path p = new Path(file);
                IvyDEMessage.debug("Loading property file " + p);
                if (getProject() != null && !p.isAbsolute()) {
                    try {
                        is = new FileInputStream(getProject().getLocation().append(file).toFile());
                    } catch (FileNotFoundException e) {
                        throw new IvyDEException("Property file not found", "The property file '"
                                + file + "' could not be found", e);
                    }
                } else {
                    try {
                        is = new FileInputStream(file);
                    } catch (FileNotFoundException e) {
                        throw new IvyDEException("Property file not found", "The property file '"
                                + file + "' was not found", e);
                    }
                }
                Properties props = new Properties();
                try {
                    props.load(is);
                } catch (IOException e) {
                    throw new IvyDEException("Not a property file", "The property file '" + file
                            + "' could not be loaded", e);
                }
                try {
                    is.close();
                } catch (IOException e) {
View Full Code Here

    }

    public File getIvyFile() throws IvyDEException {
        ResolvedPath ivyPath = new ResolvedPath(getIvyXmlPath(), getProject());
        if (ivyPath.getError() != null) {
            throw new IvyDEException("Incorrect path of the ivy.xml",
                    "The ivy.xml path '" + ivyPath.getInputPath() + "' is incorrect: "
                            + ivyPath.getError().getMessage(), ivyPath.getError());
        }
        if (!ivyPath.isSet()) {
            throw new IvyDEException("Empty path of the ivy.xml",
                    "The ivy.xml path is resolved to be empty: '" + ivyPath.getInputPath() + "'",
                    null);
        }
        if (ivyPath.getFile() == null) {
            throw new IvyDEException("The path of the ivy.xml is not a local file",
                    "The ivy.xml path is resolved to be a file: '" + ivyPath.getResolvedPath()
                            + "'", null);
        }
        return ivyPath.getFile();
    }
View Full Code Here

    }

    public ModuleDescriptor getModuleDescriptor(Ivy i) throws IvyDEException {
        File file = getIvyFile();
        if (!file.exists()) {
            throw new IvyDEException("Ivy file not found", "The ivy.xml file '"
                    + file.getAbsolutePath() + "' was not found", null);
        }
        try {
            md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
                file.toURI().toURL(), false);
            return md;
        } catch (MalformedURLException e) {
            throw new IvyDEException("Incorrect URL of the Ivy file",
                    "The URL to the ivy.xml file is incorrect: '" + file.getAbsolutePath() + "'", e);
        } catch (ParseException e) {
            throw new IvyDEException("Parsing error of the Ivy file", "The ivy file '"
                    + file.getAbsolutePath() + "' could not be parsed: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new IvyDEException("Read error of the Ivy file", "The ivy file '"
                    + file.getAbsolutePath() + "' could not be read: " + e.getMessage(), e);
        }
    }
View Full Code Here

                String propFile = (String) it.next();
                String resolvedProp = manager.performStringSubstitution(propFile, false);
                resolvedProps.add(resolvedProp);
            }
        } catch (CoreException e) {
            throw new IvyDEException("Unrecognized variables",
                    "Unrecognized variables in the Ivy settings file " + ivySettingsPath, e);
        }
        return resolvedProps;
    }
View Full Code Here

                    ivySettings.setBaseDir(javaProject.getProject().getLocation().toFile());
                }
                try {
                    ivySettings.loadDefault();
                } catch (ParseException e) {
                    IvyDEException ex = new IvyDEException(
                            "Parsing error of the default Ivy settings",
                            "The default Ivy settings file could not be parsed (" + this.toString()
                                    + ")", e);
                    setConfStatus(ex);
                    throw ex;
                } catch (IOException e) {
                    IvyDEException ex = new IvyDEException(
                            "Read error of the default Ivy settings",
                            "The default Ivy settings file could not be read (" + this.toString()
                                    + ")", e);
                    setConfStatus(ex);
                    throw ex;
                }
                ivy = Ivy.newInstance(ivySettings);
            }
            setConfStatus(null);
            return ivy;
        }

        if (settingsPath.startsWith(PROJECT_SCHEME_PREFIX)) {
            int pathIndex = settingsPath.indexOf("/", PROJECT_SCHEME_PREFIX_LENGTH);
            String projectName = settingsPath.substring(PROJECT_SCHEME_PREFIX_LENGTH, pathIndex);
            String path = settingsPath.substring(pathIndex + 1);
            if (projectName.equals("")) {
                IFile f = javaProject.getProject().getFile(path);
                File file = f.getLocation().toFile();
                return getIvy(file);
            } else {
                try {
                    IJavaProject[] javaProjects = JavaCore.create(
                        ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
                    int i;
                    for (i = 0; i < javaProjects.length; i++) {
                        if (javaProjects[i].getProject().getName().equals(projectName)) {
                            break;
                        }
                    }
                    if (i == javaProjects.length) {
                        IvyDEException ex = new IvyDEException("Project '" + projectName
                                + "' not found", "The project name '" + projectName + "' from '"
                                + settingsPath + "' was not found (" + this.toString() + ")", null);
                        setConfStatus(ex);
                        throw ex;
                    }
                    IFile f = javaProjects[i].getProject().getFile(path);
                    File file = new File(f.getLocation().toOSString());
                    return getIvy(file);
                } catch (JavaModelException e) {
                    IvyDEException ex = new IvyDEException("The workspace is broken",
                            "The projects in the workspace could not be listed when resolving the settings ("
                                    + this.toString() + ")", null);
                    setConfStatus(ex);
                    throw ex;
                }
            }
        }
        // before returning the found ivy, try to refresh it if the settings changed
        URL url;
        try {
            url = new URL(settingsPath);
        } catch (MalformedURLException e) {
            IvyDEException ex = new IvyDEException("Incorrect url of the Ivy settings",
                    "The Ivy settings url '" + settingsPath + "' is incorrect (" + this.toString()
                            + ")", e);
            setConfStatus(ex);
            throw ex;
        }
        if (url.getProtocol().startsWith("file")) {
            File file = new File(url.getPath());
            return getIvy(file);
        } else {
            // an URL but not a file
            if (ivy == null || ivySettingsLastModified == -1) {
                IvySettings ivySettings = new IvySettings();
                if (javaProject != null) {
                    ivySettings.setBaseDir(javaProject.getProject().getLocation().toFile());
                }
                try {
                    ivySettings.load(url);
                    ivySettingsLastModified = 0;
                } catch (ParseException e) {
                    IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
                            "The ivy settings file '" + settingsPath + "' could not be parsed ("
                                    + this.toString() + ")", e);
                    setConfStatus(ex);
                    throw ex;
                } catch (IOException e) {
                    IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
                            "The ivy settings file '" + settingsPath + "' could not be read ("
                                    + this.toString() + ")", e);
                    setConfStatus(ex);
                    throw ex;
                }
View Full Code Here

        return ivy;
    }

    private Ivy getIvy(File file) throws IvyDEException {
        if (!file.exists()) {
            IvyDEException ex = new IvyDEException("Ivy settings file not found",
                    "The Ivy settings file '" + ivySettingsPath + "' cannot be found ("
                            + this.toString() + ")", null);
            setConfStatus(ex);
            throw ex;
        }

        if (file.lastModified() != ivySettingsLastModified) {
            IvySettings ivySettings = new IvySettings();
            if (javaProject != null) {
                ivySettings.setBaseDir(javaProject.getProject().getLocation().toFile());
            }
            if (ivySettingsLastModified == -1) {
                Message.info("\n\n");
            } else {
                Message.info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
            }
            try {
                ivySettings.load(file);
            } catch (ParseException e) {
                IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
                        "The ivy settings file '" + ivySettingsPath + "' could not be parsed ("
                                + this.toString() + ")", e);
                setConfStatus(ex);
                throw ex;
            } catch (IOException e) {
                IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
                        "The ivy settings file '" + ivySettingsPath + "' could not be read ("
                                + this.toString() + ")", e);
                setConfStatus(ex);
                throw ex;
            }
View Full Code Here

    }

    public ModuleDescriptor getModuleDescriptor() throws IvyDEException {
        File file = getIvyFile();
        if (!file.exists()) {
            IvyDEException ex = new IvyDEException("Ivy file not found", "The ivy.xml file '"
                    + file.getAbsolutePath() + "' was not found (" + this.toString() + ")", null);
            setConfStatus(ex);
            throw ex;
        }
        try {
            Ivy i = getIvy();
            ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
                i.getSettings(), file.toURL(), false);
            setConfStatus(null);
            return md;
        } catch (MalformedURLException e) {
            IvyDEException ex = new IvyDEException("Incorrect URL of the Ivy file",
                    "The URL to the ivy.xml file is incorrect: '" + file.getAbsolutePath() + "' ("
                            + this.toString() + ")", e);
            setConfStatus(ex);
            throw ex;
        } catch (ParseException e) {
            IvyDEException ex = new IvyDEException("Parsing error of the Ivy file",
                    "The ivy file '" + file.getAbsolutePath() + "' could not be parsed ("
                            + this.toString() + ")", e);
            setConfStatus(ex);
            throw ex;
        } catch (IOException e) {
            IvyDEException ex = new IvyDEException("Read error of the Ivy file", "The ivy file '"
                    + file.getAbsolutePath() + "' could not be read (" + this.toString() + ")", e);
            setConfStatus(ex);
            throw ex;
        }
    }
View Full Code Here

            if (ivy == null) {
                IvySettings ivySettings = createIvySettings();
                try {
                    ivySettings.loadDefault();
                } catch (ParseException e) {
                    IvyDEException ex = new IvyDEException(
                            "Parsing error of the default Ivy settings",
                            "The default Ivy settings file could not be parsed: " + e.getMessage(),
                            e);
                    setConfStatus(ex);
                    throw ex;
                } catch (IOException e) {
                    IvyDEException ex = new IvyDEException(
                            "Read error of the default Ivy settings",
                            "The default Ivy settings file could not be read: "
                            + e.getMessage(), e);
                    setConfStatus(ex);
                    throw ex;
                }
                ivy = Ivy.newInstance(ivySettings);
            }
            setConfStatus(null);
            return ivy;
        }

        // before returning the found ivy, try to refresh it if the settings changed
        URL url;
        try {
            url = new URL(settingsPath);
        } catch (MalformedURLException e) {
            IvyDEException ex = new IvyDEException("Incorrect url of the Ivy settings",
                    "The Ivy settings url '" + settingsPath + "' is incorrect: " + e.getMessage(),
                    e);
            setConfStatus(ex);
            throw ex;
        }
        if (url.getProtocol().startsWith("file")) {
            File file = new File(url.getPath());
            return getIvy(file);
        } else {
            // an URL but not a file
            if (ivy == null || ivySettingsLastModified == -1) {
                IvySettings ivySettings = createIvySettings();
                try {
                    ivySettings.load(url);
                    ivySettingsLastModified = 0;
                } catch (ParseException e) {
                    IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
                            "The ivy settings file '" + settingsPath + "' could not be parsed: "
                                    + e.getMessage(), e);
                    setConfStatus(ex);
                    throw ex;
                } catch (IOException e) {
                    IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
                            "The ivy settings file '" + settingsPath + "' could not be read: "
                                    + e.getMessage(), e);
                    setConfStatus(ex);
                    throw ex;
                }
View Full Code Here

TOP

Related Classes of org.apache.ivyde.eclipse.IvyDEException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.