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));
}
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);
}
}
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();
}
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;
}
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;
}
Aggregations