Search in sources :

Example 11 with Dependency

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

the class JpaOperationsImpl method isInstalledInModule.

/**
 * FEATURE Methods
 */
public boolean isInstalledInModule(final String moduleName) {
    Pom pom = getProjectOperations().getPomFromModuleName(moduleName);
    if (pom == null) {
        return false;
    }
    // Check if spring-boot-starter-data-jpa has been included
    Set<Dependency> dependencies = pom.getDependencies();
    Dependency starter = new Dependency("org.springframework.boot", "spring-boot-starter-data-jpa", "");
    boolean hasStarter = dependencies.contains(starter);
    // Check existing application profiles
    boolean existsSpringConfigProfileInModule = false;
    List<String> applicationProfiles = getApplicationConfigService().getApplicationProfiles(moduleName);
    for (String profile : applicationProfiles) {
        if (getApplicationConfigService().existsSpringConfigFile(moduleName, profile)) {
            existsSpringConfigProfileInModule = true;
            break;
        }
    }
    return existsSpringConfigProfileInModule && hasStarter;
}
Also used : Dependency(org.springframework.roo.project.Dependency) Pom(org.springframework.roo.project.maven.Pom)

Example 12 with Dependency

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

the class JpaOperationsImpl method getDependencies.

private List<Dependency> getDependencies(final String xPathExpression, final Element configuration) {
    final List<Dependency> dependencies = new ArrayList<Dependency>();
    for (final Element dependencyElement : XmlUtils.findElements(xPathExpression + "/dependencies/dependency", configuration)) {
        final Dependency dependency = new Dependency(dependencyElement);
        dependencies.add(dependency);
    }
    return dependencies;
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Dependency(org.springframework.roo.project.Dependency)

Example 13 with Dependency

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

the class TypeManagementServiceImpl method addField.

public void addField(final FieldMetadata field, boolean evict) {
    Validate.notNull(field, "Field metadata not provided");
    // Obtain the physical type and ITD mutable details
    PhysicalTypeMetadata ptm = null;
    if (evict) {
        ptm = (PhysicalTypeMetadata) metadataService.evictAndGet(field.getDeclaredByMetadataId());
    } else {
        ptm = (PhysicalTypeMetadata) metadataService.get(field.getDeclaredByMetadataId());
    }
    Validate.notNull(ptm, "Java source code unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId()));
    final PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails();
    Validate.notNull(ptd, "Java source code details unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId()));
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder((ClassOrInterfaceTypeDetails) ptd);
    // Automatically add JSR 303 (Bean Validation API) support if there is
    // no current JSR 303 support but a JSR 303 annotation is present
    boolean jsr303Required = false;
    for (final AnnotationMetadata annotation : field.getAnnotations()) {
        if (annotation.getAnnotationType().getFullyQualifiedTypeName().startsWith("javax.validation")) {
            jsr303Required = true;
            break;
        }
    }
    final LogicalPath path = PhysicalTypeIdentifier.getPath(cidBuilder.getDeclaredByMetadataId());
    if (jsr303Required) {
        // It's more likely the version below represents a later version
        // than any specified in the user's own dependency list
        projectOperations.addDependency(path.getModule(), new Dependency("javax.validation", "validation-api", null));
    }
    cidBuilder.addField(field);
    createOrUpdateTypeOnDisk(cidBuilder.build());
}
Also used : LogicalPath(org.springframework.roo.project.LogicalPath) ClassOrInterfaceTypeDetailsBuilder(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder) Dependency(org.springframework.roo.project.Dependency) AnnotationMetadata(org.springframework.roo.classpath.details.annotations.AnnotationMetadata)

Example 14 with Dependency

use of org.springframework.roo.project.Dependency 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 15 with Dependency

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

Dependency (org.springframework.roo.project.Dependency)34 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)10 JavaType (org.springframework.roo.model.JavaType)10 RooJavaType (org.springframework.roo.model.RooJavaType)10 ArrayList (java.util.ArrayList)9 Pom (org.springframework.roo.project.maven.Pom)9 Test (org.junit.Test)8 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)8 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)7 Element (org.w3c.dom.Element)6 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)4 DataOnDemandCreatorProvider (org.springframework.roo.addon.test.providers.DataOnDemandCreatorProvider)3 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)3 JdkJavaType (org.springframework.roo.model.JdkJavaType)3 JpaJavaType (org.springframework.roo.model.JpaJavaType)3 SpringJavaType (org.springframework.roo.model.SpringJavaType)3 ControllerAnnotationValues (org.springframework.roo.addon.web.mvc.controller.addon.ControllerAnnotationValues)2 ClassAttributeValue (org.springframework.roo.classpath.details.annotations.ClassAttributeValue)2 Property (org.springframework.roo.project.Property)2 Node (org.w3c.dom.Node)2