/** * Constructor * * @param pom the POM for this module of the project (required) */ public ProjectMetadata(final Pom pom) { super(getProjectIdentifier(pom.getModuleName())); Validate.notNull(pom, "POM is required"); this.pom = pom; }
public final ProjectMetadata getProjectMetadata(final String moduleName) { return (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier(moduleName)); }
@CliCommand(value = METADATA_FOR_MODULE_COMMAND, help = "Shows the ProjectMetadata for the indicated project module.") public String metadataForModule(@CliOption(key = {"", "module"}, mandatory = false, optionContext = INCLUDE_CURRENT_MODULE, help = "The module for which to retrieve the metadata. " + "Default if option not present: the Roo Shell focused module.") final Pom pom) { final Pom targetPom = ObjectUtils.defaultIfNull(pom, projectOperations.getFocusedModule()); if (targetPom == null) { return "This project has no modules"; } final String projectMID = ProjectMetadata.getProjectIdentifier(targetPom.getModuleName()); return metadataService.get(projectMID).toString(); }
private void updateProjectMetadataForModules(final Iterable<Pom> newPoms) { for (final Pom pom : newPoms) { final String projectMetadataId = ProjectMetadata.getProjectIdentifier(pom.getModuleName()); getMetadataService().evictAndGet(projectMetadataId); getMetadataDependencyRegistry().notifyDownstream(projectMetadataId); } }
ProjectMetadata.getProjectIdentifier(moduleName), metadataIdentificationString);
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); final IdentifierAnnotationValues annotationValues = new IdentifierAnnotationValues(governorPhysicalTypeMetadata); if (!annotationValues.isAnnotationFound()) { return null; } // We know governor type details are non-null and can be safely cast final JavaType javaType = IdentifierMetadata.getJavaType(metadataIdentificationString); final List<Identifier> identifierServiceResult = getIdentifiersForType(javaType); final LogicalPath path = PhysicalTypeIdentifierNamingUtils.getPath(metadataIdentificationString); if (projectOperations.isProjectAvailable(path.getModule())) { // If the project itself changes, we want a chance to refresh this // item getMetadataDependencyRegistry().registerDependency( ProjectMetadata.getProjectIdentifier(path.getModule()), metadataIdentificationString); } return new IdentifierMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, identifierServiceResult); }
public boolean isInstallBundlorAvailable() { ProjectMetadata project = (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier()); if (project == null) { return false; } // only permit installation if they don't already have some version of Bundlor installed return project.getBuildPluginDependenciesExcludingVersion(PLUGIN_DEPENDENCY).isEmpty(); }
private void writeTemplateFile(String destination,String bundleName,Set<Dependency> dependencies) { try { ProjectMetadata project = (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier()); String mfFile = FileCopyUtils.copyToString(new InputStreamReader(TemplateUtils.getTemplate(getClass(), "template.mf"))); mfFile = mfFile.replaceAll("#topLevelPackage#", project.getTopLevelPackage().toString()); String bundleNameReplacement = project.getProjectName(); if (null != bundleName) { bundleNameReplacement = bundleName; } mfFile = mfFile.replaceAll("#bundleName#",bundleNameReplacement); for (Dependency d : dependencies) { String bundleImport = bundleImportFor(d); if (null != bundleImport) { mfFile += (bundleImport + "\n"); } } FileCopyUtils.copy(mfFile,new OutputStreamWriter(fileManager.createFile(destination).getOutputStream())); } catch (IOException ioe) { throw new IllegalStateException(ioe); } }
@CliCommand(value = METADATA_FOR_MODULE_COMMAND, help = "Shows the ProjectMetadata for the indicated project module.") public String metadataForModule(@CliOption(key = {"", "module"}, mandatory = false, optionContext = INCLUDE_CURRENT_MODULE, help = "The module for which to retrieve the metadata. " + "Default if option not present: the Roo Shell focused module.") final Pom pom) { final Pom targetPom = ObjectUtils.defaultIfNull(pom, projectOperations.getFocusedModule()); if (targetPom == null) { return "This project has no modules"; } final String projectMID = ProjectMetadata.getProjectIdentifier(targetPom.getModuleName()); return metadataService.get(projectMID).toString(); }
.get(ProjectMetadata.getProjectIdentifier(projectOperations .getFocusedModuleName()));
/** * Returns project name to set CXF configuration file. * * @return Project Name. */ private String getProjectName() { // Project metadata from project identifier ProjectMetadata projectMetadata = (ProjectMetadata) getMetadataService() .get(ProjectMetadata .getProjectIdentifier(getProjectOperations() .getFocusedModuleName())); Validate.isTrue(projectMetadata != null, "Project metadata required"); return getProjectOperations().getProjectName( getProjectOperations().getFocusedModuleName()); }
public void installBundlor(String bundleName) { projectOperations.buildPluginUpdate(PLUGIN_DEPENDENCY,new Execution("bundlor","transform")); // copy the template across ProjectMetadata project = (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier()); String destination = pathResolver.getIdentifier(Path.ROOT, "template.mf"); if (!fileManager.exists(destination)) { writeTemplateFile(destination,bundleName,project.getDependencies()); } // monitor any dependencies added or removed by other addons projectOperations.addDependencyListener(this); }
ProjectMetadata.getProjectIdentifier(moduleName), metadataIdentificationString);
/** * Check if pom.xml file exists in the project and return the path. * <p> * Checks if exists pom.xml config file. If not exists, null will be * returned. * </p> * * @return Path to the pom.xml file or null if not exists. */ private String getPomFilePath() { // Project ID String prjId = ProjectMetadata .getProjectIdentifier(getProjectOperations() .getFocusedModuleName()); ProjectMetadata projectMetadata = (ProjectMetadata) getMetadataService() .get(prjId); Validate.isTrue(projectMetadata != null, "Project metadata required"); String pomFileName = "pom.xml"; // Checks for pom.xml String pomPath = getProjectOperations().getPathResolver() .getIdentifier(LogicalPath.getInstance(Path.ROOT, ""), pomFileName); boolean pomInstalled = getFileManager().exists(pomPath); if (pomInstalled) { return pomPath; } else { return null; } }
/** * Check if all dependencies are registered in project (pom.xml). * * @param type Web service type * @return true if all dependencies are registed already */ protected boolean dependenciesRegistered(WsType type) { // Get project to check installed dependencies ProjectMetadata project = (ProjectMetadata) getMetadataService().get( ProjectMetadata.getProjectIdentifier(getProjectOperations() .getFocusedModuleName())); if (project == null) { return false; } // Iterate all dependencies for (Element dependency : getDependencies(type)) { // Some dependency not registered: all dependencies not installed Pom pom = project.getPom(); if (!pom.isDependencyRegistered(new Dependency(dependency))) { return false; } } // All dependencies are installed return true; }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); final IdentifierAnnotationValues annotationValues = new IdentifierAnnotationValues(governorPhysicalTypeMetadata); if (!annotationValues.isAnnotationFound()) { return null; } // We know governor type details are non-null and can be safely cast final JavaType javaType = IdentifierMetadata.getJavaType(metadataIdentificationString); final List<Identifier> identifierServiceResult = getIdentifiersForType(javaType); final LogicalPath path = PhysicalTypeIdentifierNamingUtils.getPath(metadataIdentificationString); if (projectOperations.isProjectAvailable(path.getModule())) { // If the project itself changes, we want a chance to refresh this // item getMetadataDependencyRegistry().registerDependency( ProjectMetadata.getProjectIdentifier(path.getModule()), metadataIdentificationString); } return new IdentifierMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, identifierServiceResult); }