Package org.mevenide.idea.project.goals

Examples of org.mevenide.idea.project.goals.DefaultPluginGoalContainer


     * @param pPluginDir the plugin directory
     *
     * @return plugin descriptor
     */
    private PluginGoalContainer parsePlugin(final VirtualFile pPluginDir) {
        final DefaultPluginGoalContainer plugin = new DefaultPluginGoalContainer();

        //
        //parse plugin POM
        //
        final VirtualFile pluginPom = pPluginDir.findChild("project.xml");
        if (pluginPom != null && pluginPom.isValid() && FileUtils.exists(pluginPom))
            plugin.setPomFile(pluginPom);
        else
            return null;

        final XmlFile pomPsi = PsiUtils.findXmlFile(project, pluginPom);
        if (pomPsi == null)
            return null;

        plugin.setId(new XmlTagPath(pomPsi, POM_ID_XPATH).getStringValue());
        plugin.setGroupId(new XmlTagPath(pomPsi, POM_GROUP_ID_XPATH).getStringValue());
        plugin.setArtifactId(new XmlTagPath(pomPsi, POM_ARTIFACT_ID_XPATH).getStringValue());
        plugin.setVersion(new XmlTagPath(pomPsi, POM_VERSION_XPATH).getStringValue());
        plugin.setName(new XmlTagPath(pomPsi, POM_NAME_XPATH).getStringValue());
        plugin.setDescription(new XmlTagPath(pomPsi, POM_DESC_XPATH).getStringValue());

        //
        //parse plugin Jelly script
        //
        final VirtualFile jellyFile = pPluginDir.findChild("plugin.jelly");
        if (jellyFile != null && jellyFile.isValid() && FileUtils.exists(jellyFile))
            plugin.setScriptFile(jellyFile);
        else
            return null;

        final XmlFile jellyPsi = PsiUtils.findXmlFile(project, jellyFile);
        final XmlTagPath goalsPath = new XmlTagPath(jellyPsi, "project/goal");
        final XmlTag[] goalTags = goalsPath.getAllTags();
        final PluginGoal[] goals = new PluginGoal[goalTags.length];
        for (int i = 0; i < goalTags.length; i++) {
            XmlTag tag = goalTags[i];
            final String name = tag.getAttributeValue("name");
            final String lcName = name.toLowerCase();
            if (lcName.equalsIgnoreCase("register") || lcName.equalsIgnoreCase("deregister"))
                continue;

            final String desc = tag.getAttributeValue("description");
            final String preReqsValue = tag.getAttributeValue("prereqs");
            final String[] preReqs = preReqsValue == null ? EMPTY_STRING_ARRAY : preReqsValue.split(
                    ",");

            final DefaultPluginGoal goal = new DefaultPluginGoal();
            goal.setName(name);
            goal.setDescription(desc);
            goal.setContainer(plugin);
            goal.setPrereqs(preReqs);
            goals[i] = goal;
        }
        plugin.setGoals(goals);

        return plugin;
    }
View Full Code Here

TOP

Related Classes of org.mevenide.idea.project.goals.DefaultPluginGoalContainer

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.