Search in sources :

Example 1 with Property

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

the class ThymeleafMVCViewResponseService method addWebJars.

/**
 * Configure WebJar dependencies in required pom's.
 *
 * @param module the module where Thymeleaf is going to be installed
 */
private void addWebJars(Pom module) {
    String rootModuleName = "";
    List<Dependency> dependencies = new ArrayList<Dependency>();
    // Add WebJar locator dependency
    dependencies.add(new Dependency("org.webjars", "webjars-locator", null));
    // Add Bootstrap WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("bootstrap.version", "3.3.6"));
    dependencies.add(new Dependency("org.webjars.bower", "bootstrap", "${bootstrap.version}"));
    // Add Datatables and Datatables related WebJars
    getProjectOperations().addProperty(rootModuleName, new Property("datatables.version", "1.10.12"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables", "${datatables.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-bs.version", "1.10.11"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-bs", "${datatables-bs.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-buttons.version", "1.1.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-buttons", "${datatables-buttons.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-buttons-bs.version", "1.1.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-buttons-bs", "${datatables-buttons-bs.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-responsive.version", "2.0.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-responsive", "${datatables-responsive.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-responsive-bs.version", "2.0.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-responsive-bs", "${datatables-responsive-bs.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-select.version", "1.1.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-select", "${datatables-select.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-select-bs.version", "1.1.2"));
    dependencies.add(new Dependency("org.webjars.bower", "datatables.net-select-bs", "${datatables-select-bs.version}"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-checkboxes.version", "1.1.2"));
    getProjectOperations().addProperty(rootModuleName, new Property("datatables-mark.version", "2.0.0"));
    // Add exclusions to avoid conflicts with Bower dependencies
    List<Dependency> exclusions = new ArrayList<Dependency>();
    exclusions.add(new Dependency("org.webjars.npm", "jquery", null));
    exclusions.add(new Dependency("org.webjars.npm", "datatables.net", null));
    dependencies.add(new Dependency("org.webjars.npm", "jquery-datatables-checkboxes", "${datatables-checkboxes.version}", exclusions));
    // Add Datatables mark WebJar
    dependencies.add(new Dependency("org.webjars.bower", "github-com-julmot-datatables-mark-js", "${datatables-mark.version}"));
    // Add DatetimePicker WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("datetimepicker.version", "2.5.4"));
    dependencies.add(new Dependency("org.webjars.bower", "datetimepicker", "${datetimepicker.version}"));
    // Add FontAwesome WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("fontawesome.version", "4.6.2"));
    dependencies.add(new Dependency("org.webjars.bower", "font-awesome", "${fontawesome.version}"));
    // Add jQuery WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("jquery.version", "1.12.3"));
    dependencies.add(new Dependency("org.webjars.bower", "jquery", "${jquery.version}"));
    // Add jQuery InputMask WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("jquery-inputmask.version", "3.3.1"));
    // Add exclusions to avoid conflicts with Bower dependencies
    exclusions = new ArrayList<Dependency>();
    exclusions.add(new Dependency("org.webjars", "jquery", null));
    dependencies.add(new Dependency("org.webjars", "jquery.inputmask", "${jquery-inputmask.version}", exclusions));
    // Add jQuery InputMask WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("jquery-validation.version", "1.15.0"));
    dependencies.add(new Dependency("org.webjars.bower", "jquery-validation", "${jquery-validation.version}"));
    // Add MomentJS WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("momentjs.version", "2.13.0"));
    dependencies.add(new Dependency("org.webjars.bower", "momentjs", "${momentjs.version}"));
    // Add Select2 WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("select2.version", "4.0.3"));
    dependencies.add(new Dependency("org.webjars.bower", "select2", "${select2.version}"));
    // Add Select2 Bootstrap Theme WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("select2-bootstrap-theme.version", "0.1.0-beta.7"));
    dependencies.add(new Dependency("org.webjars.bower", "select2-bootstrap-theme", "${select2-bootstrap-theme.version}"));
    // Add respond WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("respond.version", "1.4.2"));
    dependencies.add(new Dependency("org.webjars", "respond", "${respond.version}"));
    // Add html5shiv WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("html5shiv.version", "3.7.3"));
    dependencies.add(new Dependency("org.webjars", "html5shiv", "${html5shiv.version}"));
    // Add ie10-viewport-bug-workaround WebJar
    getProjectOperations().addProperty(rootModuleName, new Property("bootstrap.ie10-viewport-bug-workaround.version", "1.0.3"));
    dependencies.add(new Dependency("org.webjars.bower", "ie10-viewport-bug-workaround", "${bootstrap.ie10-viewport-bug-workaround.version}"));
    getProjectOperations().addDependencies(module.getModuleName(), dependencies);
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.springframework.roo.project.Dependency) Property(org.springframework.roo.project.Property)

Example 2 with Property

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

the class ThymeleafMVCViewResponseService method addThymeleafDependencies.

/**
 * This method adds necessary thymeleaf dependencies to
 * generated project
 *
 * @param module
 */
private void addThymeleafDependencies(Pom module) {
    // Add Thymeleaf starter
    getProjectOperations().addDependency(module.getModuleName(), STARTER_THYMELEAF_DEPENDENCY);
    // Add Thymeleaf layout dialect
    getProjectOperations().addDependency(module.getModuleName(), LAYOUT_THYMELEAF_DEPENDENCY);
    // Add Thymeleaf data dialect
    getProjectOperations().addDependency(module.getModuleName(), DATA_THYMELEAF_DEPENDENCY);
    // ROO-3813: Use Thymeleaf 3.0 instead of the provided version by Spring IO
    // More info about Thymelead 3.0 using Spring Boot here
    // http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-thymeleaf-3
    getProjectOperations().addProperty("", new Property("thymeleaf.version", "3.0.0.RELEASE"));
    getProjectOperations().addProperty("", new Property("thymeleaf-layout-dialect.version", "2.0.0"));
    getProjectOperations().addProperty("", new Property("thymeleaf-data-dialect.version", "2.0.1"));
}
Also used : Property(org.springframework.roo.project.Property)

Example 3 with Property

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

the class JpaOperationsImpl method updateDependencies.

/**
 * Updates the POM with the dependencies required for the given database and
 * ORM provider, removing any other persistence-related dependencies
 *
 * @param configuration
 * @param ormProvider
 * @param jdbcDatabase
 * @param startersXPath
 * @param profile
 */
private void updateDependencies(final Pom module, final Element configuration, final OrmProvider ormProvider, final JdbcDatabase jdbcDatabase, final String startersXPath, final String providersXPath, final String databaseXPath, String profile) {
    final List<Dependency> requiredDependencies = new ArrayList<Dependency>();
    final List<Element> starterDependencies = XmlUtils.findElements("/configuration/starter/provider[@id = '" + ormProvider.name() + "']/dependencies/dependency", configuration);
    for (final Element dependencyElement : starterDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    // Add database dependencies
    final List<Element> databaseDependencies = XmlUtils.findElements(jdbcDatabase.getConfigPrefix() + "/dependencies/dependency", configuration);
    for (final Element dependencyElement : databaseDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    if (jdbcDatabase.toString().equals(JdbcDatabase.ORACLE.toString())) {
        LOGGER.warning("Oracle drivers aren't in Maven public repositories!! You should include them manually in your local Maven repository.");
    }
    final List<Element> ormDependencies = XmlUtils.findElements(ormProvider.getConfigPrefix() + "/dependencies/dependency", configuration);
    for (final Element dependencyElement : ormDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    // Hard coded to JPA & Hibernate Validator for now
    final List<Element> jpaDependencies = XmlUtils.findElements("/configuration/persistence/provider[@id = 'JPA']/dependencies/dependency", configuration);
    for (final Element dependencyElement : jpaDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    final List<Element> springDependencies = XmlUtils.findElements("/configuration/spring/dependencies/dependency", configuration);
    for (final Element dependencyElement : springDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    final List<Element> commonDependencies = XmlUtils.findElements("/configuration/common/dependencies/dependency", configuration);
    for (final Element dependencyElement : commonDependencies) {
        requiredDependencies.add(new Dependency(dependencyElement));
    }
    // Add properties
    List<Element> properties = XmlUtils.findElements("/configuration/properties/*", configuration);
    for (Element property : properties) {
        getProjectOperations().addProperty("", new Property(property));
    }
    // Add dependencies used by other profiles, excluding the current profile
    List<String> profiles = getApplicationConfigService().getApplicationProfiles(module.getModuleName());
    profiles.remove(profile);
    for (String applicationProfile : profiles) {
        // Extract database
        final String driver = getApplicationConfigService().getProperty(module.getModuleName(), DATASOURCE_PREFIX, DATABASE_DRIVER, applicationProfile);
        for (JdbcDatabase database : JdbcDatabase.values()) {
            if (database.getDriverClassName().equals(driver)) {
                for (final Element dependencyElement : XmlUtils.findElements(database.getConfigPrefix() + "/dependencies/dependency", configuration)) {
                    requiredDependencies.add(new Dependency(dependencyElement));
                }
                break;
            }
        }
    }
    // Remove redundant dependencies
    final List<Dependency> redundantDependencies = new ArrayList<Dependency>();
    redundantDependencies.addAll(getDependencies(databaseXPath, configuration));
    redundantDependencies.addAll(getDependencies(startersXPath, configuration));
    redundantDependencies.addAll(getDependencies(providersXPath, configuration));
    // Don't remove any we actually need
    redundantDependencies.removeAll(requiredDependencies);
    // Update the POM
    getProjectOperations().removeDependencies(module.getModuleName(), redundantDependencies);
    getProjectOperations().addDependencies(module.getModuleName(), requiredDependencies);
    // and some repository has been already added
    if (getProjectOperations().isMultimoduleProject()) {
        Set<JavaType> repositoryTypes = getTypeLocationService().findTypesWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA);
        if (!repositoryTypes.isEmpty()) {
            Iterator<JavaType> repositoryIterator = repositoryTypes.iterator();
            while (repositoryIterator.hasNext()) {
                JavaType repositoryType = repositoryIterator.next();
                String moduleName = repositoryType.getModule();
                // Remove redundant dependencies from modules with repository classes
                getProjectOperations().removeDependencies(moduleName, redundantDependencies);
                // Add new database dependencies
                addDatabaseDependencyWithTestScope(moduleName, profile, jdbcDatabase.getConfigPrefix());
            }
        }
    }
    // Include Springlets Starter project dependencies and properties
    getProjectOperations().addProperty("", SPRINGLETS_VERSION_PROPERTY);
    // If current project is a multimodule project, include dependencies
    // first
    // on dependencyManagement and then on current module
    getProjectOperations().addDependency(module.getModuleName(), SPRINGLETS_DATA_JPA_STARTER);
    getProjectOperations().addDependency(module.getModuleName(), SPRINGLETS_DATA_COMMONS_STARTER);
}
Also used : JdkJavaType(org.springframework.roo.model.JdkJavaType) RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Dependency(org.springframework.roo.project.Dependency) Property(org.springframework.roo.project.Property)

Example 4 with Property

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

the class Pom method getPropertiesExcludingValue.

/**
 * Locates any properties which match the presented property, excluding the
 * value. This is useful for upgrade use cases, where it is necessary to
 * locate any properties with the name so that they can be removed.
 *
 * @param property to locate (required; note the value is ignored in
 *            comparisons)
 * @return any matching properties (never returns null, but may return an
 *         empty {@link Set})
 */
public Set<Property> getPropertiesExcludingValue(final Property property) {
    Validate.notNull(property, "Property to locate is required");
    final Set<Property> result = new HashSet<Property>();
    for (final Property p : pomProperties) {
        if (property.getName().equals(p.getName())) {
            result.add(p);
        }
    }
    return result;
}
Also used : Property(org.springframework.roo.project.Property) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 5 with Property

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

the class JspOperationsImpl method installMavenPlugins.

private void installMavenPlugins(String moduleName) {
    final Element configuration = XmlUtils.getConfiguration(getClass());
    // Add properties
    List<Element> properties = XmlUtils.findElements("/configuration/properties/*", configuration);
    for (Element property : properties) {
        getProjectOperations().addProperty(moduleName, new Property(property));
    }
    // Add Plugins
    List<Element> elements = XmlUtils.findElements("/configuration/plugins/plugin", configuration);
    for (Element element : elements) {
        Plugin plugin = new Plugin(element);
        getProjectOperations().addBuildPlugin(moduleName, plugin);
    }
}
Also used : Element(org.w3c.dom.Element) Property(org.springframework.roo.project.Property) Plugin(org.springframework.roo.project.Plugin)

Aggregations

Property (org.springframework.roo.project.Property)5 ArrayList (java.util.ArrayList)2 Dependency (org.springframework.roo.project.Dependency)2 Element (org.w3c.dom.Element)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 JavaType (org.springframework.roo.model.JavaType)1 JdkJavaType (org.springframework.roo.model.JdkJavaType)1 RooJavaType (org.springframework.roo.model.RooJavaType)1 Plugin (org.springframework.roo.project.Plugin)1