Search in sources :

Example 6 with Dependency

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

the class PomTest method testHasDependencyExcludingVersionWhenDependencyHasDifferentGroupId.

@Test
public void testHasDependencyExcludingVersionWhenDependencyHasDifferentGroupId() {
    // Set up
    final Dependency mockExistingDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, "1.0", DependencyType.JAR);
    final Pom pom = getMinimalPom(JAR, mockExistingDependency);
    final Dependency mockOtherDependency = getMockDependency("au." + DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, "1.0", DependencyType.JAR);
    // Invoke and check
    assertFalse(pom.hasDependencyExcludingVersion(mockOtherDependency));
}
Also used : Dependency(org.springframework.roo.project.Dependency) Test(org.junit.Test)

Example 7 with Dependency

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

the class PomTest method testHasDependencyExcludingVersionWhenDependencyHasDifferentVersion.

@Test
public void testHasDependencyExcludingVersionWhenDependencyHasDifferentVersion() {
    // Set up
    final String existingVersion = "1.0";
    final Dependency mockExistingDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, existingVersion, DependencyType.JAR);
    final Pom pom = getMinimalPom(JAR, mockExistingDependency);
    final Dependency mockOtherDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, existingVersion + ".1", DependencyType.JAR);
    // Invoke and check
    assertTrue(pom.hasDependencyExcludingVersion(mockOtherDependency));
}
Also used : Dependency(org.springframework.roo.project.Dependency) Test(org.junit.Test)

Example 8 with Dependency

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

the class PomTest method getMockDependency.

private Dependency getMockDependency(final String groupId, final String artifactId, final String version, final DependencyType type) {
    final Dependency mockDependency = mock(Dependency.class);
    when(mockDependency.getGroupId()).thenReturn(groupId);
    when(mockDependency.getArtifactId()).thenReturn(artifactId);
    when(mockDependency.getVersion()).thenReturn(version);
    when(mockDependency.getType()).thenReturn(type);
    return mockDependency;
}
Also used : Dependency(org.springframework.roo.project.Dependency)

Example 9 with Dependency

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

the class JpaOperationsImpl method addTestScopedDependency.

/**
 * Gets database dependency from config file and adds it with test scope
 *
 * @param moduleName
 *            the module which dependency should be added
 * @param databaseConfigPrefix
 *            the prefix name for choosing the dependency to add
 * @param configuration
 *            the configuration file with the dependencies to copy from
 */
private void addTestScopedDependency(String moduleName, String databaseConfigPrefix, final Element configuration) {
    final List<Element> databaseDependencies = XmlUtils.findElements(databaseConfigPrefix + "/dependencies/dependency", configuration);
    for (final Element dependencyElement : databaseDependencies) {
        // Change scope from provided to test
        NodeList childNodes = dependencyElement.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            final Node node = childNodes.item(i);
            if (node != null && node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("scope")) {
                node.setTextContent("test");
            }
        }
        // Add dependency
        getProjectOperations().addDependency(moduleName, new Dependency(dependencyElement));
    }
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Dependency(org.springframework.roo.project.Dependency)

Example 10 with Dependency

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

the class JpaOperationsImpl method newEmbeddableClass.

@Override
public void newEmbeddableClass(final JavaType name, final boolean serializable) {
    Validate.notNull(name, "Embeddable name required");
    final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, getPathResolver().getFocusedPath(Path.SRC_MAIN_JAVA));
    final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(Arrays.asList(new AnnotationMetadataBuilder(ROO_JAVA_BEAN), new AnnotationMetadataBuilder(ROO_TO_STRING), new AnnotationMetadataBuilder(EMBEDDABLE)));
    if (serializable) {
        annotations.add(new AnnotationMetadataBuilder(ROO_SERIALIZABLE));
    }
    final int modifier = Modifier.PUBLIC;
    final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, modifier, name, PhysicalTypeCategory.CLASS);
    cidBuilder.setAnnotations(annotations);
    getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
    getProjectOperations().addDependency(name.getModule(), new Dependency("org.springframework.boot", "spring-boot-starter-data-jpa", null));
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetailsBuilder(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder) Dependency(org.springframework.roo.project.Dependency) AnnotationMetadataBuilder(org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)

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