Search in sources :

Example 1 with Dependency

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

the class DefaultSecurityProvider method isInstalledInModule.

@Override
public boolean isInstalledInModule(String moduleName) {
    boolean isInstalledInModule = false;
    Pom module = getProjectOperations().getPomFromModuleName(moduleName);
    Set<Dependency> starter = module.getDependenciesExcludingVersion(SPRING_SECURITY_STARTER);
    if (!starter.isEmpty()) {
        isInstalledInModule = true;
    }
    return isInstalledInModule;
}
Also used : Dependency(org.springframework.roo.project.Dependency) Pom(org.springframework.roo.project.maven.Pom)

Example 2 with Dependency

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

the class SpringletsJpaSecurityProvider method isInstalledInModule.

@Override
public boolean isInstalledInModule(String moduleName) {
    boolean isInstalledInModule = false;
    Pom module = getProjectOperations().getPomFromModuleName(moduleName);
    Set<Dependency> starter = module.getDependenciesExcludingVersion(SPRINGLETS_SECURITY_AUTHENTICATION_STARTER);
    if (!starter.isEmpty()) {
        isInstalledInModule = true;
    }
    return isInstalledInModule;
}
Also used : Dependency(org.springframework.roo.project.Dependency) Pom(org.springframework.roo.project.maven.Pom)

Example 3 with Dependency

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

the class JsonControllerTestCreator method createIntegrationTest.

@Override
public void createIntegrationTest(JavaType type, Pom module) {
    Validate.notNull(type, "Class to produce an integration test class for is required");
    // Check if provided JavaType is a JSON Controller
    ClassOrInterfaceTypeDetails cid = typeLocationService.getTypeDetails(type);
    Validate.notNull(cid.getAnnotation(RooJavaType.ROO_CONTROLLER), "Type must be a Roo controller.");
    Validate.notNull(cid.getAnnotation(RooJavaType.ROO_JSON), "Type must be a Roo JSON controller.");
    // Add springlets-boot-starter-test dependency
    projectOperations.addProperty("", SPRINGLETS_VERSION_PROPERTY);
    projectOperations.addDependency(module.getModuleName(), SPRINGLETS_BOOT_STARTER_TEST_DEPENDENCY);
    // Get the controller managed entity
    ControllerAnnotationValues controllerAnnotationValues = new ControllerAnnotationValues(cid);
    JavaType managedEntity = controllerAnnotationValues.getEntity();
    // Workaround to get a JavaType with not null module when recovering it
    // from a ClassAttributeValue
    managedEntity = new JavaType(managedEntity.getFullyQualifiedTypeName(), managedEntity.getArray(), managedEntity.getDataType(), managedEntity.getArgName(), managedEntity.getParameters(), typeLocationService.getTypeDetails(managedEntity).getType().getModule());
    // Create Data On Demand artifacts for managed entity
    List<DataOnDemandCreatorProvider> dodCreators = getValidDataOnDemandCreatorsForType(managedEntity);
    Validate.isTrue(!dodCreators.isEmpty(), "Couldn't find any 'DataOnDemandCreatorProvider' for JSON controllers.");
    Validate.isTrue(dodCreators.size() == 1, "More than 1 valid 'DataOnDemandCreatorProvider' found for JSON controllers. %s can't decide which one to use.", this.getClass().getName());
    DataOnDemandCreatorProvider creator = dodCreators.get(0);
    creator.createDataOnDemand(managedEntity);
    // Add module dependency with test-jar dependency
    if (projectOperations.isMultimoduleProject()) {
        String managedEntityModuleName = managedEntity.getModule();
        Pom managedEntityModule = projectOperations.getPomFromModuleName(managedEntityModuleName);
        projectOperations.addDependency(module.getModuleName(), new Dependency(managedEntityModule.getGroupId(), managedEntityModule.getArtifactId(), "${project.version}", DependencyType.valueOfTypeCode("test-jar"), DependencyScope.TEST), true, true);
    }
    // Create integration test class
    final JavaType name = new JavaType(type + "IT", module.getModuleName());
    final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, Path.SRC_TEST_JAVA.getModulePathId(module.getModuleName()));
    if (metadataService.get(declaredByMetadataId) != null) {
        // The file already exists
        return;
    }
    // Add @RooJsonControllerIntegrationTest to source file
    AnnotationMetadataBuilder rooIntegrationTestAnnotation = new AnnotationMetadataBuilder(RooJavaType.ROO_JSON_CONTROLLER_INTEGRATION_TEST);
    rooIntegrationTestAnnotation.addClassAttribute("targetClass", type);
    // Create integration test class
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, name, PhysicalTypeCategory.CLASS);
    cidBuilder.addAnnotation(rooIntegrationTestAnnotation);
    // Write changes to disk
    typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) ControllerAnnotationValues(org.springframework.roo.addon.web.mvc.controller.addon.ControllerAnnotationValues) ClassOrInterfaceTypeDetailsBuilder(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) Dependency(org.springframework.roo.project.Dependency) DataOnDemandCreatorProvider(org.springframework.roo.addon.test.providers.DataOnDemandCreatorProvider) AnnotationMetadataBuilder(org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder) Pom(org.springframework.roo.project.maven.Pom)

Example 4 with Dependency

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

the class PomTest method testCanAddNewDependencyOfLowerType.

@Test
public void testCanAddNewDependencyOfLowerType() {
    // Set up
    final Dependency mockNewDependency = mock(Dependency.class);
    when(mockNewDependency.getType()).thenReturn(DependencyType.JAR);
    final Pom pom = getMinimalPom(WAR);
    // Invoke and check
    assertTrue(pom.canAddDependency(mockNewDependency, true));
}
Also used : Dependency(org.springframework.roo.project.Dependency) Test(org.junit.Test)

Example 5 with Dependency

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

the class PomTest method testCannotAddAlreadyRegisteredDependency.

@Test
public void testCannotAddAlreadyRegisteredDependency() {
    // Set up
    final Dependency mockExistingDependency = mock(Dependency.class);
    when(mockExistingDependency.getType()).thenReturn(DependencyType.JAR);
    when(mockExistingDependency.getGroupId()).thenReturn(DEPENDENCY_ARTIFACT_ID);
    when(mockExistingDependency.getArtifactId()).thenReturn(DEPENDENCY_GROUP_ID);
    final Pom pom = getMinimalPom(POM, mockExistingDependency);
    // Invoke and check
    assertFalse(pom.canAddDependency(mockExistingDependency, true));
}
Also used : Dependency(org.springframework.roo.project.Dependency) Test(org.junit.Test)

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