@Override public Pom getModuleFromWsdlLocation(String wsdlLocation) { // Separate the wsdlLocation and the module String[] wsdlLocationParts = wsdlLocation.split(":"); if (wsdlLocationParts.length > 1) { return getProjectOperations().getPomFromModuleName(wsdlLocationParts[0]); } else { return getProjectOperations().getPomFromModuleName(""); } }
@Override public boolean isInstalledInModule(String moduleName) { Pom currentPom = getProjectOperations().getPomFromModuleName(moduleName); List<Dependency> dependencies = new ArrayList<Dependency>(); dependencies.add(DEPENDENCY_SPRING_BOOT_STARTER_MAIL); dependencies.add(DEPENDENCY_SPRINGLETS_STARTER_MAIL); return currentPom.isAllDependenciesRegistered(dependencies); }
@Override public List<Pom> getModules() { List<Pom> modules = new ArrayList<Pom>(); Pom module; for (String moduleName : getModuleNames()) { module = getProjectOperations().getPomFromModuleName(moduleName); if (module == null) { throw new NullPointerException(String.format("ERROR: Pom not found for module %s", moduleName)); } modules.add(module); } return modules; }
@Override public boolean isInstalledInModule(String moduleName) { boolean isInstalledInModule = false; Pom module = getProjectOperations().getPomFromModuleName(moduleName); Set<Dependency> starter = module.getDependenciesExcludingVersion(SPRING_SECURITY_STARTER); if (!starter.isEmpty()) { isInstalledInModule = true; } return isInstalledInModule; }
@Override public boolean isInstalledInModule(String moduleName) { boolean isInstalledInModule = false; Pom module = getProjectOperations().getPomFromModuleName(moduleName); Set<Dependency> starter = module.getDependenciesExcludingVersion(SPRINGLETS_DATA_JPA_STARTER); if (!starter.isEmpty()) { isInstalledInModule = true; } return isInstalledInModule; } }
@Override public boolean isInstalledInModule(String moduleName) { boolean isInstalledInModule = false; Pom module = getProjectOperations().getPomFromModuleName(moduleName); Set<Dependency> starter = module.getDependenciesExcludingVersion(SPRINGLETS_SECURITY_AUTHENTICATION_STARTER); if (!starter.isEmpty()) { isInstalledInModule = true; } return isInstalledInModule; }
/** * This method checks if THYMELEAF dependencies has been installed before * * @param module * @return */ private boolean hasThymeleafDependencies(String moduleName) { if (!getProjectOperations().getPomFromModuleName(moduleName) .getDependenciesExcludingVersion(STARTER_THYMELEAF_DEPENDENCY).isEmpty() && !getProjectOperations().getPomFromModuleName(moduleName) .getDependenciesExcludingVersion(LAYOUT_THYMELEAF_DEPENDENCY).isEmpty()) { return true; } return false; }
public List<JavaPackage> getPackagesForModule(String moduleName) { return this.getPackagesForModule(getProjectOperations().getPomFromModuleName(moduleName)); }
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; }
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 ("com.force.sdk".equals(buildPlugin.getArtifactId())) { return true; } } return false; }
public JavaPackage convertFromText(String value, final Class<?> requiredType, final String optionContext) { if (StringUtils.isBlank(value)) { return null; } Pom module = projectOperations.getFocusedModule(); if (value.contains(MODULE_PATH_SEPARATOR)) { final String moduleName = value.substring(0, value.indexOf(MODULE_PATH_SEPARATOR)); module = projectOperations.getPomFromModuleName(moduleName); value = value.substring(value.indexOf(MODULE_PATH_SEPARATOR) + 1, value.length()).trim(); if (StringUtils.contains(optionContext, UPDATE)) { projectOperations.setModule(module); } } String moduleName = module == null ? null : module.getModuleName(); JavaPackage result = new JavaPackage(convertToFullyQualifiedPackageName(module, value), moduleName); if (optionContext != null && (optionContext.contains(UPDATE) || optionContext.contains(UPDATELAST))) { lastUsed.setPackage(result, module); } return result; }
/** * Checks if module provided in package is an application module. If not, find an * application module and use it with default package. * * @param controllerPackage the provided JavaPackage to check * @return */ private JavaPackage checkAndUseApplicationModule(JavaPackage controllerPackage) { if (!typeLocationService.hasModuleFeature( projectOperations.getPomFromModuleName(controllerPackage.getModule()), ModuleFeatureName.APPLICATION)) { LOGGER .log( Level.WARNING, "Focused or specified module isn't an application module (containing a class " + "annotated with @SpringBootApplication). Looking for an application module and default package..."); // Validate that project has at least one application module Validate.notEmpty(typeLocationService.getModuleNames(ModuleFeatureName.APPLICATION), "The project must have at least one application module to publish web finders."); // Get the first application module String moduleName = typeLocationService.getModuleNames(ModuleFeatureName.APPLICATION).iterator().next(); Pom module = projectOperations.getPomFromModuleName(moduleName); controllerPackage = new JavaPackage(typeLocationService.getTopLevelPackageForModule(module).concat(".web"), moduleName); } return controllerPackage; }
@Override public boolean isInstalledInModule(String moduleName) { Pom module = getProjectOperations().getPomFromModuleName(moduleName); for (JavaType javaType : getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_WEB_MVC_CONFIGURATION)) { if (javaType.getModule().equals(moduleName) && module.hasDependencyExcludingVersion(new Dependency("org.springframework.boot", "spring-boot-starter-web", null))) { return true; } } return false; }
/** * 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); } }
/** * 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; }
/** * Add needed dependencies and plugins to run created integration tests. * * @param module {@link String} the module name where add dependencies. */ private void addIntegrationTestDependencies(String moduleName) { // Add dependencies if needed projectOperations.addDependency(moduleName, JUNIT_DEPENDENCY); projectOperations.addDependency(moduleName, ASSERTJ_CORE_DEPENDENCY); projectOperations.addDependency(moduleName, SPRING_TEST_DEPENDENCY); projectOperations.addDependency(moduleName, SPRING_BOOT_TEST_DEPENDENCY); // Add plugin maven-failsafe-plugin Pom module = projectOperations.getPomFromModuleName(moduleName); // Stop if the plugin is already installed for (final Plugin plugin : module.getBuildPlugins()) { if (plugin.getArtifactId().equals("maven-failsafe-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)); } }
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); } }
public String getPhysicalTypeCanonicalPath(final String physicalTypeId) { final LogicalPath logicalPath = PhysicalTypeIdentifier.getPath(physicalTypeId); final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalTypeId); final Pom pom = getProjectOperations().getPomFromModuleName(logicalPath.getModule()); final String canonicalFilePath = pom.getPathLocation(logicalPath.getPath()) + javaType.getRelativeFileName(); if (getFileManager().exists(canonicalFilePath)) { getTypeCache().cacheTypeAgainstModule(pom, javaType); getTypeCache().cacheFilePathAgainstTypeIdentifier(canonicalFilePath, physicalTypeId); } return canonicalFilePath; }
final Pom module = projectOperations.getPomFromModuleName(moduleName);
@Override public ViewContext<T> createViewContext(final ControllerMetadata controllerMetadata, final JavaType entity, final JpaEntityMetadata entityMetadata, T viewMetadata) { ViewContext<T> ctx = new ViewContext<T>(); ctx.setControllerPath(controllerMetadata.getPath()); ctx.setProjectName(getProjectOperations().getProjectName("")); ctx.setVersion(getProjectOperations().getPomFromModuleName("").getVersion()); ctx.setEntityName(entity.getSimpleTypeName()); ctx.setModelAttribute(StringUtils.uncapitalize(entity.getSimpleTypeName())); ctx.setModelAttributeName(StringUtils.uncapitalize(entity.getSimpleTypeName())); ctx.setIdentifierField(entityMetadata.getCurrentIndentifierField().getFieldName() .getSymbolName()); ctx.setViewMetadata(viewMetadata); ctx.setControllerMetadata(controllerMetadata); return ctx; }