Search in sources :

Example 6 with PackagingProvider

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

the class MavenOperationsImpl method createMultimoduleProject.

public void createMultimoduleProject(final JavaPackage topLevelPackage, final String projectName, final Integer majorJavaVersion, final Multimodule multimodule) {
    Validate.isTrue(isCreateProjectAvailable(), "Project creation is unavailable at this time");
    Validate.notNull(multimodule, "Multimodule must not be null");
    final PackagingProvider parentPackagingProvider = getPackagingProvider(getPackagingProviderRegistry().getPackagingProvider("pom"));
    final PackagingProvider warPackagingProvider = getPackagingProvider(getPackagingProviderRegistry().getPackagingProvider("war"));
    final PackagingProvider jarPackagingProvider = getPackagingProvider(getPackagingProviderRegistry().getPackagingProvider("jar"));
    // Create parent pom
    parentPackagingProvider.createArtifacts(topLevelPackage, projectName, getJavaProductVersion(majorJavaVersion), null, "", this);
    // Add java.version property if specified
    if (majorJavaVersion != null) {
        getProjectOperations().addProperty("", new Property("java.version", getJavaVersion(majorJavaVersion)));
    }
    Pom pom = getProjectOperations().getPomFromModuleName("");
    // service-impl
    if (multimodule == Multimodule.STANDARD) {
        createModule("model", jarPackagingProvider, "model");
        createModule("repository", jarPackagingProvider, "repository");
        // ROO-3762: Generate integration module by default
        createModule("integration", jarPackagingProvider, "integration");
        createModule("service-api", jarPackagingProvider, "service.api");
        createModule("service-impl", jarPackagingProvider, "service.impl");
        // Add dependencies between modules
        getProjectOperations().addDependency("repository", pom.getGroupId(), "model", "${project.version}");
        getProjectOperations().addDependency("integration", pom.getGroupId(), "model", "${project.version}");
        getProjectOperations().addDependency("service-api", pom.getGroupId(), "model", "${project.version}");
        getProjectOperations().addDependency("service-impl", pom.getGroupId(), "repository", "${project.version}");
        getProjectOperations().addDependency("service-impl", pom.getGroupId(), "service.api", "${project.version}");
        getProjectOperations().addDependency("service-impl", pom.getGroupId(), "model", "${project.version}");
        getProjectOperations().addDependency("service-impl", pom.getGroupId(), "integration", "${project.version}");
    }
    // In all cases, multimodule architectures have an application module
    // where Spring Boot artifacts are created
    createModule("application", warPackagingProvider, "application", "");
    installApplicationConfiguration("application");
    // ROO-3687: Generates necessary Spring Boot artifacts into application
    // module.
    createSpringBootApplicationClass(topLevelPackage, projectName);
    // createApplicationTestsClass(topLevelPackage, projectName);
    // ROO-3741: Including banner.txt on application module
    addBannerFile(getPomFromModuleName("application"));
    // add application-dev.properties on application module
    addApplicationDevPropertiesFile(getPomFromModuleName("application"), topLevelPackage);
    // application module and the generated modules above
    if (multimodule == Multimodule.STANDARD) {
        getProjectOperations().addDependency("application", pom.getGroupId(), "service.impl", "${project.version}");
        getProjectOperations().addDependency("application", pom.getGroupId(), "service.api", "${project.version}");
        getProjectOperations().addDependency("application", pom.getGroupId(), "repository", "${project.version}");
        getProjectOperations().addDependency("application", pom.getGroupId(), "model", "${project.version}");
    }
}
Also used : PackagingProvider(org.springframework.roo.project.packaging.PackagingProvider) Pom(org.springframework.roo.project.maven.Pom)

Example 7 with PackagingProvider

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

the class PackagingProviderConverter method convertFromText.

public PackagingProvider convertFromText(final String value, final Class<?> targetType, final String optionContext) {
    final PackagingProvider packagingProvider = packagingProviderRegistry.getPackagingProvider(value);
    Validate.notNull(packagingProvider, "Unsupported packaging id '%s'", value);
    return packagingProvider;
}
Also used : PackagingProvider(org.springframework.roo.project.packaging.PackagingProvider)

Example 8 with PackagingProvider

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

the class PackagingProviderConverterTest method testConvertValidString.

@Test
public void testConvertValidString() {
    // Set up
    final String id = "some-id";
    when(mockPackagingProviderRegistry.getPackagingProvider(id)).thenReturn(mockCoreJarPackaging);
    // Invoke
    final PackagingProvider packagingProvider = converter.convertFromText(id, PackagingProvider.class, null);
    // Check
    assertEquals(mockCoreJarPackaging, packagingProvider);
}
Also used : CorePackagingProvider(org.springframework.roo.project.packaging.CorePackagingProvider) PackagingProvider(org.springframework.roo.project.packaging.PackagingProvider) Test(org.junit.Test)

Aggregations

PackagingProvider (org.springframework.roo.project.packaging.PackagingProvider)8 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Pom (org.springframework.roo.project.maven.Pom)2 CorePackagingProvider (org.springframework.roo.project.packaging.CorePackagingProvider)2 CliOptionAutocompleteIndicator (org.springframework.roo.shell.CliOptionAutocompleteIndicator)1 Completion (org.springframework.roo.shell.Completion)1