Search in sources :

Example 1 with Configuration

use of org.springframework.roo.project.Configuration in project spring-roo by spring-projects.

the class CloudFoundryProvider method updatePlugins.

/**
 * This method update plugins with the added to configuration.xml file
 *
 * @param configuration
 * @param moduleName
 * @param projectOperations
 */
public static void updatePlugins(String pluginConfiguration, ProjectOperations projectOperations) {
    Configuration conf = null;
    // Generating configuration if necessary
    if (StringUtils.isNotBlank(pluginConfiguration)) {
        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            Document doc = docBuilder.newDocument();
            Element configElement = doc.createElement("configuration");
            // Getting all configurations
            String[] configurationTags = pluginConfiguration.split(",");
            for (String configurationTag : configurationTags) {
                String[] keyValue = configurationTag.split("=");
                if (keyValue.length == 2) {
                    Element element = doc.createElement(keyValue[0]);
                    element.setTextContent(keyValue[1]);
                    configElement.appendChild(element);
                }
            }
            conf = new Configuration(configElement);
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "[ERROR] " + e);
        }
    }
    // Generate Plugin
    Plugin cloudFoundryMvnPlugin = new Plugin("org.cloudfoundry", "cf-maven-plugin", "1.0.4", conf, null, null);
    // Adding plugin
    projectOperations.addBuildPlugin(projectOperations.getFocusedModuleName(), cloudFoundryMvnPlugin);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Configuration(org.springframework.roo.project.Configuration) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Plugin(org.springframework.roo.project.Plugin)

Aggregations

DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Configuration (org.springframework.roo.project.Configuration)1 Plugin (org.springframework.roo.project.Plugin)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1