use of org.springframework.roo.project.packaging.PackagingProvider in project spring-roo by spring-projects.
the class MavenOperationsImpl method createProject.
public void createProject(final JavaPackage topLevelPackage, final String projectName, final Integer majorJavaVersion, final PackagingProvider selectedPackagingProvider) {
Validate.isTrue(isCreateProjectAvailable(), "Project creation is unavailable at this time");
final PackagingProvider packagingProvider = getPackagingProvider(selectedPackagingProvider);
packagingProvider.createArtifacts(topLevelPackage, projectName, getJavaProductVersion(majorJavaVersion), null, "", this);
// Add java.version property if specified
if (majorJavaVersion != null) {
getProjectOperations().addProperty("", new Property("java.version", getJavaVersion(majorJavaVersion)));
}
// ROO-3687: Generates necessary Spring Boot artifacts
createSpringBootApplicationClass(topLevelPackage, projectName);
// createApplicationTestsClass(topLevelPackage, projectName);
// ROO-3741: Including banner.txt
addBannerFile(getPomFromModuleName(""));
// add application-dev.properties
addApplicationDevPropertiesFile(getPomFromModuleName(""), topLevelPackage);
}
use of org.springframework.roo.project.packaging.PackagingProvider in project spring-roo by spring-projects.
the class MavenOperationsImpl method createModule.
private void createModule(final String moduleName, final PackagingProvider selectedPackagingProvider, final String artifactId, final String folder) {
Validate.isTrue(isCreateModuleAvailable(), "Cannot create modules at this time");
if (getProjectOperations().getPomFromModuleName(moduleName) != null) {
throw new IllegalArgumentException(String.format("Module %s already exists", moduleName));
}
// Get parent pom
Pom parentPom = getProjectOperations().getPomFromModuleName("");
setModule(parentPom);
// Validate parent has POM packaging
if (!parentPom.getPackaging().equals("pom")) {
throw new IllegalArgumentException("ERROR: Parent module packaging is not POM");
}
final PackagingProvider packagingProvider = getPackagingProvider(selectedPackagingProvider);
final String pathToNewPom = packagingProvider.createArtifacts(getProjectOperations().getTopLevelPackage(parentPom.getModuleName()), artifactId, "", new GAV(parentPom.getGroupId(), parentPom.getArtifactId(), parentPom.getVersion()), moduleName, this);
updateParentModulePom(moduleName);
setModule(pomManagementService.getPomFromPath(pathToNewPom));
if (folder == null) {
createFolder(getProjectOperations().getTopLevelPackage(moduleName), null);
} else {
createFolder(getProjectOperations().getTopLevelPackage(parentPom.getModuleName()), folder);
}
}
use of org.springframework.roo.project.packaging.PackagingProvider in project spring-roo by spring-projects.
the class PackagingProviderConverterTest method testGetAllPossibleValues.
@Test
public void testGetAllPossibleValues() {
// Set up
final PackagingProvider[] providers = { mockCoreJarPackaging, mockCustomJarPackaging, mockWarPackaging };
when(mockPackagingProviderRegistry.getAllPackagingProviders()).thenReturn(Arrays.asList(providers));
final List<Completion> expectedCompletions = new ArrayList<Completion>();
for (final PackagingProvider provider : providers) {
expectedCompletions.add(new Completion(provider.getId().toUpperCase()));
}
final List<Completion> completions = new ArrayList<Completion>();
// Invoke
final boolean addSpace = converter.getAllPossibleValues(completions, PackagingProvider.class, "ignored", null, null);
// Check
assertTrue(addSpace);
assertEquals(expectedCompletions.size(), completions.size());
assertTrue("Expected " + expectedCompletions + " but was " + completions, completions.containsAll(expectedCompletions));
}
use of org.springframework.roo.project.packaging.PackagingProvider in project spring-roo by spring-projects.
the class PomFactoryImpl method getPaths.
private Collection<Path> getPaths(final Element root, final String packaging) {
final String packagingProviderId = XmlUtils.getTextContent(PACKAGING_PROVIDER_PROPERTY_XPATH, root, packaging);
final PackagingProvider packagingProvider = packagingProviderRegistry.getPackagingProvider(packagingProviderId);
Validate.notNull(packagingProvider, "No PackagingProvider found with the ID '%s'", packagingProviderId);
return packagingProvider.getPaths();
}
use of org.springframework.roo.project.packaging.PackagingProvider in project spring-roo by spring-projects.
the class MavenCommands method returnPomModules.
@CliOptionAutocompleteIndicator(command = MODULE_CREATE_COMMAND, param = "packaging", help = "--packaging select one of the available Maven packaging values")
public List<String> returnPomModules(ShellContext shellContext) {
List<String> allPossibleValues = new ArrayList<String>();
Collection<PackagingProvider> allPackagingProviders = packagingProviderRegistry.getAllPackagingProviders();
for (final PackagingProvider packagingProvider : allPackagingProviders) {
// ROO-3801 Can't create POM children
if (!"pom".equals(packagingProvider.getId())) {
allPossibleValues.add(packagingProvider.getId().toUpperCase());
}
}
return allPossibleValues;
}
Aggregations