Search in sources :

Example 6 with Plugin

use of org.springframework.roo.project.Plugin 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)

Example 7 with Plugin

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

the class DatabaseDotComOperationsImpl method isInstalledInModule.

public boolean isInstalledInModule(final String moduleName) {
    if (projectOperations == null) {
        projectOperations = getProjectOperations();
    }
    Validate.notNull(projectOperations, "ProjectOperations is required");
    final Pom pom = projectOperations.getPomFromModuleName(moduleName);
    if (pom == null) {
        return false;
    }
    for (final Plugin buildPlugin : pom.getBuildPlugins()) {
        if ("com.force.sdk".equals(buildPlugin.getArtifactId())) {
            return true;
        }
    }
    return false;
}
Also used : Pom(org.springframework.roo.project.maven.Pom) Plugin(org.springframework.roo.project.Plugin)

Example 8 with Plugin

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

the class SeleniumOperationsImpl method installMavenPlugin.

private void installMavenPlugin() {
    // Stop if the plugin is already installed
    for (final Plugin plugin : projectOperations.getFocusedModule().getBuildPlugins()) {
        if (plugin.getArtifactId().equals("selenium-maven-plugin")) {
            return;
        }
    }
    final Element configuration = XmlUtils.getConfiguration(getClass());
    final Element plugin = XmlUtils.findFirstElement("/configuration/selenium/plugin", configuration);
    // Now install the plugin itself
    if (plugin != null) {
        projectOperations.addBuildPlugin(projectOperations.getFocusedModuleName(), new Plugin(plugin));
    }
}
Also used : Element(org.w3c.dom.Element) Plugin(org.springframework.roo.project.Plugin)

Example 9 with Plugin

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

the class Pom method isPluginRegisteredInPluginManagement.

/**
 * Indicates whether the given plugin is registered in pluginManagement without checking plugin version
 * , by checking the result of {@link Plugin#equals(Object)}.
 *
 * @param plugin
 *            the plugin to check (can be <code>null</code>)
 * @return <code>false</code> if a <code>null</code> dependency is given
 */
public boolean isPluginRegisteredInPluginManagement(final Plugin plugin, boolean checkVersion) {
    if (checkVersion) {
        return plugin != null && pluginsInPluginManagement.contains(plugin);
    }
    boolean registered = false;
    Iterator<Plugin> it = pluginsInPluginManagement.iterator();
    while (it.hasNext()) {
        Plugin dp = it.next();
        if (plugin.getGroupId().equals(dp.getGroupId()) && plugin.getArtifactId().equals(dp.getArtifactId())) {
            registered = true;
            break;
        }
    }
    return plugin != null && registered;
}
Also used : Plugin(org.springframework.roo.project.Plugin)

Example 10 with Plugin

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

the class Pom method getBuildPluginsExcludingVersion.

/**
 * Returns any build plugins with the same groupId and artifactId as the
 * given plugin. This is useful for upgrade cases.
 *
 * @param plugin to locate (required; note the version number is ignored in
 *            comparisons)
 * @return any matching plugins (never returns null, but may return an empty
 *         {@link Set})
 */
public Set<Plugin> getBuildPluginsExcludingVersion(final Plugin plugin) {
    Validate.notNull(plugin, "Plugin to locate is required");
    final Set<Plugin> result = new HashSet<Plugin>();
    for (final Plugin p : buildPlugins) {
        if (plugin.getArtifactId().equals(p.getArtifactId()) && plugin.getGroupId().equals(p.getGroupId())) {
            result.add(p);
        }
    }
    return result;
}
Also used : Plugin(org.springframework.roo.project.Plugin) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Plugin (org.springframework.roo.project.Plugin)11 Element (org.w3c.dom.Element)7 Pom (org.springframework.roo.project.maven.Pom)4 HashSet (java.util.HashSet)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)1 JavaType (org.springframework.roo.model.JavaType)1 RooJavaType (org.springframework.roo.model.RooJavaType)1 SpringJavaType (org.springframework.roo.model.SpringJavaType)1 Configuration (org.springframework.roo.project.Configuration)1 Dependency (org.springframework.roo.project.Dependency)1 Property (org.springframework.roo.project.Property)1 Repository (org.springframework.roo.project.Repository)1 Document (org.w3c.dom.Document)1