Search in sources :

Example 26 with Pom

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

the class MavenPathResolvingStrategyTest method setUpModulePaths.

private void setUpModulePaths() {
    final PhysicalPath mockModuleSourcePath = getMockModulePath(true, mockSourcePath);
    final PhysicalPath mockModuleNonSourcePath = getMockModulePath(false, mockNonSourcePath);
    final Pom mockPom = mock(Pom.class);
    when(mockPom.getPhysicalPaths()).thenReturn(Arrays.asList(mockModuleSourcePath, mockModuleNonSourcePath));
    when(mockPomManagementService.getPoms()).thenReturn(Arrays.asList(mockPom));
}
Also used : Pom(org.springframework.roo.project.maven.Pom)

Example 27 with Pom

use of org.springframework.roo.project.maven.Pom 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 28 with Pom

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

the class JpaDataOnDemandCreator method createDataOnDemandConfiguration.

@Override
public JavaType createDataOnDemandConfiguration(String moduleName) {
    // Check if alreafy exists
    JavaType dodConfig = getDataOnDemandConfiguration();
    if (dodConfig != null) {
        return dodConfig;
    }
    // Add spring-boot-test dependency with test scope
    projectOperations.addDependency(moduleName, SPRING_BOOT_TEST_DEPENDENCY);
    // Get Pom
    final Pom module = projectOperations.getPomFromModuleName(moduleName);
    // Get test Path for module
    final LogicalPath path = LogicalPath.getInstance(Path.SRC_TEST_JAVA, moduleName);
    // Create the JavaType for the configuration class
    JavaType dodConfigurationClass = new JavaType(String.format("%s.dod.DataOnDemandConfiguration", typeLocationService.getTopLevelPackageForModule(module), moduleName));
    final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(dodConfigurationClass, path);
    if (metadataService.get(declaredByMetadataId) != null) {
        // The file already exists
        return new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId).getName();
    }
    // Create the CID builder
    ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, dodConfigurationClass, PhysicalTypeCategory.CLASS);
    cidBuilder.addAnnotation(new AnnotationMetadataBuilder(RooJavaType.ROO_JPA_DATA_ON_DEMAND_CONFIGURATION));
    // Write changes to disk
    final ClassOrInterfaceTypeDetails configDodCid = cidBuilder.build();
    typeManagementService.createOrUpdateTypeOnDisk(configDodCid);
    return configDodCid.getName();
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) LogicalPath(org.springframework.roo.project.LogicalPath) ClassOrInterfaceTypeDetailsBuilder(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) AnnotationMetadataBuilder(org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder) Pom(org.springframework.roo.project.maven.Pom)

Example 29 with Pom

use of org.springframework.roo.project.maven.Pom 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 30 with Pom

use of org.springframework.roo.project.maven.Pom 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)

Aggregations

Pom (org.springframework.roo.project.maven.Pom)86 Element (org.w3c.dom.Element)19 JavaType (org.springframework.roo.model.JavaType)16 Document (org.w3c.dom.Document)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)9 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)9 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)9 Dependency (org.springframework.roo.project.Dependency)9 RooJavaType (org.springframework.roo.model.RooJavaType)7 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 ServiceReference (org.osgi.framework.ServiceReference)5 ControllerMVCResponseService (org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService)5 JavaPackage (org.springframework.roo.model.JavaPackage)5 List (java.util.List)4 Plugin (org.springframework.roo.project.Plugin)4 Completion (org.springframework.roo.shell.Completion)4 HashMap (java.util.HashMap)3 DataOnDemandCreatorProvider (org.springframework.roo.addon.test.providers.DataOnDemandCreatorProvider)3