Search in sources :

Example 1 with Plugin

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

the class TestOperationsImpl method addIntegrationTestDependencies.

/**
 * Add needed dependencies and plugins to run created integration tests.
 *
 * @param module {@link String} the module name where add dependencies.
 */
private void addIntegrationTestDependencies(String moduleName) {
    // Add dependencies if needed
    projectOperations.addDependency(moduleName, JUNIT_DEPENDENCY);
    projectOperations.addDependency(moduleName, ASSERTJ_CORE_DEPENDENCY);
    projectOperations.addDependency(moduleName, SPRING_TEST_DEPENDENCY);
    projectOperations.addDependency(moduleName, SPRING_BOOT_TEST_DEPENDENCY);
    // Add plugin maven-failsafe-plugin
    Pom module = projectOperations.getPomFromModuleName(moduleName);
    // Stop if the plugin is already installed
    for (final Plugin plugin : module.getBuildPlugins()) {
        if (plugin.getArtifactId().equals("maven-failsafe-plugin")) {
            return;
        }
    }
    final Element configuration = XmlUtils.getConfiguration(getClass());
    final Element plugin = XmlUtils.findFirstElement("/configuration/plugin", configuration);
    // Now install the plugin itself
    if (plugin != null) {
        projectOperations.addBuildPlugin(moduleName, new Plugin(plugin));
    }
}
Also used : Element(org.w3c.dom.Element) Pom(org.springframework.roo.project.maven.Pom) Plugin(org.springframework.roo.project.Plugin)

Example 2 with Plugin

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

the class JpaDataOnDemandCreator method addMavenJarPlugin.

/**
 * Add maven-jar-plugin to provided module.
 *
 * @param moduleName the name of the module.
 */
private void addMavenJarPlugin(String moduleName) {
    // Add plugin maven-jar-plugin
    Pom module = projectOperations.getPomFromModuleName(moduleName);
    // Stop if the plugin is already installed
    for (final Plugin plugin : module.getBuildPlugins()) {
        if (plugin.getArtifactId().equals(MAVEN_JAR_PLUGIN)) {
            return;
        }
    }
    final Element configuration = XmlUtils.getConfiguration(getClass());
    final Element plugin = XmlUtils.findFirstElement("/configuration/plugin", configuration);
    // Now install the plugin itself
    if (plugin != null) {
        projectOperations.addBuildPlugin(moduleName, new Plugin(plugin), false);
    }
}
Also used : Element(org.w3c.dom.Element) Pom(org.springframework.roo.project.maven.Pom) Plugin(org.springframework.roo.project.Plugin)

Example 3 with Plugin

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

the class GaeOperationsImpl 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 ("appengine-maven-plugin".equals(buildPlugin.getArtifactId())) {
            return true;
        }
    }
    return false;
}
Also used : Pom(org.springframework.roo.project.maven.Pom) Plugin(org.springframework.roo.project.Plugin)

Example 4 with Plugin

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

the class WsOperationsImpl method includeDependenciesAndPluginsForWsClient.

/**
 * This method includes the TracEE and CXF dependencies and includes the CXF
 * CodeGen Plugin with the necessary configuration for the new WsClient.
 *
 * @param wsdlName
 *            the wsdl name
 * @param wsdlModuleName
 *            the module where the wsdl is located
 */
private void includeDependenciesAndPluginsForWsClient(String wsdlName, String wsdlModuleName) {
    // Include CXF property if not exists
    getProjectOperations().addProperty("", CXF_PROPERTY);
    getProjectOperations().addDependency(wsdlModuleName, CXF_RT_FRONTEND_JAXWS_DEPENDENCY);
    getProjectOperations().addDependency(wsdlModuleName, CXF_RT_TRANSPORTS_HTTP_DEPENDENCY);
    // Include TracEE dependencies if not exists
    getProjectOperations().addProperty("", TRACEE_PROPERTY);
    getProjectOperations().addDependency(wsdlModuleName, TRACEE_CXF_DEPENDENCY);
    // Include CXF plugin if not exists
    final Element configuration = XmlUtils.getConfiguration(getClass());
    final List<Element> plugins = XmlUtils.findElements("/configuration/plugins/plugin", configuration);
    Plugin cxfPlugin = null;
    for (final Element pluginElement : plugins) {
        cxfPlugin = new Plugin(pluginElement);
        getProjectOperations().addBuildPlugin(wsdlModuleName, cxfPlugin);
        break;
    }
    // Update cxf plugin with the new wsdl
    Map<String, String> wsdlLocationProperties = new HashMap<String, String>();
    wsdlLocationProperties.put("wsdl", "${project.basedir}/src/main/resources/" + wsdlName);
    wsdlLocationProperties.put("wsdlLocation", "classpath:" + wsdlName);
    getProjectOperations().addElementToPluginExecution(wsdlModuleName, cxfPlugin, "generate-sources", "wsdlOptions", "wsdlOption", wsdlLocationProperties);
}
Also used : HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Plugin(org.springframework.roo.project.Plugin)

Example 5 with Plugin

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

the class RepositoryJpaOperationsImpl method generateConfiguration.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void generateConfiguration(JavaType interfaceType, JavaType domainType) {
    final Element configuration = XmlUtils.getConfiguration(getClass());
    // Add querydsl dependency
    final List<Element> dependencies;
    final List<Element> plugins;
    if (getProjectOperations().isMultimoduleProject()) {
        dependencies = XmlUtils.findElements("/configuration/multimodule/dependencies/dependency", configuration);
        plugins = XmlUtils.findElements("/configuration/multimodule/plugins/plugin", configuration);
        // Add database test dependency
        getJpaOperations().addDatabaseDependencyWithTestScope(interfaceType.getModule(), null, null);
    } else {
        dependencies = XmlUtils.findElements("/configuration/monomodule/dependencies/dependency", configuration);
        plugins = XmlUtils.findElements("/configuration/monomodule/plugins/plugin", configuration);
    }
    for (final Element dependencyElement : dependencies) {
        getProjectOperations().addDependency(interfaceType.getModule(), new Dependency(dependencyElement));
    }
    // Add querydsl plugin
    Plugin queryDslPlugin = null;
    for (final Element pluginElement : plugins) {
        Plugin plugin = new Plugin(pluginElement);
        if (plugin.getArtifactId().equals("querydsl-maven-plugin")) {
            queryDslPlugin = plugin;
        }
        getProjectOperations().addBuildPlugin(interfaceType.getModule(), plugin);
    }
    if (getProjectOperations().isMultimoduleProject()) {
        if (queryDslPlugin == null) {
            throw new RuntimeException("Error: Missing QueryDSL plugin");
        }
        // Add entity package to find Q classes.
        Set<String> packages = new HashSet();
        for (ClassOrInterfaceTypeDetails cid : getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA)) {
            if (cid.getType().getModule().equals(interfaceType.getModule())) {
                JavaType relatedEntity = (JavaType) cid.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA).getAttribute("entity").getValue();
                String module = getTypeLocationService().getTypeDetails(relatedEntity).getType().getModule();
                if (!packages.contains(module)) {
                    packages.add(module);
                    getProjectOperations().addPackageToPluginExecution(interfaceType.getModule(), queryDslPlugin, "generate-qtypes", getProjectOperations().getTopLevelPackage(module).getFullyQualifiedPackageName());
                }
            }
        }
        getProjectOperations().addPackageToPluginExecution(interfaceType.getModule(), queryDslPlugin, "generate-qtypes", getProjectOperations().getTopLevelPackage(domainType.getModule()).getFullyQualifiedPackageName());
    } else {
        // Add querydsl processor repository
        List<Element> repositories = XmlUtils.findElements("/configuration/monomodule/repositories/repository", configuration);
        for (final Element repositoryElement : repositories) {
            getProjectOperations().addRepository(interfaceType.getModule(), new Repository(repositoryElement));
        }
    }
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) SpringJavaType(org.springframework.roo.model.SpringJavaType) JavaType(org.springframework.roo.model.JavaType) Repository(org.springframework.roo.project.Repository) Element(org.w3c.dom.Element) Dependency(org.springframework.roo.project.Dependency) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) Plugin(org.springframework.roo.project.Plugin) HashSet(java.util.HashSet)

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