@Override protected void notifyForGenericListener(final String upstreamDependency) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); // If the upstream dependency is null or invalid do not continue if (StringUtils.isBlank(upstreamDependency) || !MetadataIdentificationUtils.isValid(upstreamDependency)) { return; } // If the upstream dependency isn't ProjectMetadata do not continue if (!ProjectMetadata.isValid(upstreamDependency)) { return; } // If the project isn't valid do not continue if (projectOperations.isProjectAvailable(ProjectMetadata.getModuleName(upstreamDependency))) { final boolean isGaeEnabled = projectOperations.isFeatureInstalled(FeatureNames.GAE); // We need to determine if the persistence state has changed, we do // this by comparing the last known state to the current state final boolean hasGaeStateChanged = wasGaeEnabled == null || isGaeEnabled != wasGaeEnabled; if (hasGaeStateChanged) { wasGaeEnabled = isGaeEnabled; for (final String producedMid : producedMids) { getMetadataService().evictAndGet(producedMid); } } } }
/** * 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 Pom getFocusedModule() { final ProjectMetadata focusedProjectMetadata = getFocusedProjectMetadata(); if (focusedProjectMetadata == null) { return null; } return focusedProjectMetadata.getPom(); }
public MetadataItem get(final String metadataId) { Validate.isTrue(ProjectMetadata.isValid(metadataId), "Unexpected metadata request '%s' for this provider", metadataId); // Just rebuild on demand. We always do this as we expect // MetadataService to cache on our behalf final Pom pom = pomManagementService.getPomFromModuleName(ProjectMetadata.getModuleName(metadataId)); // Read the file, if it is available if (pom == null || !fileManager.exists(pom.getPath())) { return null; } return new ProjectMetadata(pom); }
/** * {@inheritDoc} When Project metadata changes look for SpringSecurity * dependency and update menu artifacts. */ public void notify(String upstreamDependency, String downstreamDependency) { // Check if is project metadata if (ProjectMetadata.isValid(upstreamDependency)) { if (getProjectOperations().isFeatureInstalledInFocusedModule( "gvnix-bootstrap") && getGeoOperations().isInstalledInModule( "gvnix-geo-component")) { getGeoOperations().updateGeoAddonToBootstrap(); } } }
/** * 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; }
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); } }
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(); }
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); }
getProjectOperations().getProjectMetadata(module.getModuleName()).getId());
/** * {@inheritDoc} When Project metadata changes look for SpringSecurity * dependency and update menu artifacts. */ public void notify(String upstreamDependency, String downstreamDependency) { // Check if is project metadata if (ProjectMetadata.isValid(upstreamDependency)) { if (getProjectOperations().isFeatureInstalledInFocusedModule( "gvnix-bootstrap") && getTypicalsecurityOperations() .isTypicalSecurityInstalled() && !getTypicalsecurityOperations().isLoginModified()) { getTypicalsecurityOperations() .updateTypicalSecurityAddonToBootstrap(); } } }
public final ProjectMetadata getProjectMetadata(final String moduleName) { return (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier(moduleName)); }
public void notify(final String upstreamDependency, final String downstreamDependency) { if (bundleVersionInfo != null && ProjectMetadata.isValid(upstreamDependency)) { final String moduleName = ProjectMetadata.getModuleName(upstreamDependency);
/** * {@inheritDoc} When Project metadata changes look for SpringSecurity * dependency and update menu artifacts. */ public void notify(String upstreamDependency, String downstreamDependency) { // Check if is project metadata if (ProjectMetadata.isValid(upstreamDependency)) { if (getProjectOperations().isFeatureInstalledInFocusedModule( "gvnix-bootstrap") && getProjectOperations() .isFeatureInstalledInFocusedModule( FeatureNames.SECURITY) && !getBootstrapOperations().isTypicalSecurityInstalled() && !getBootstrapOperations().isLoginModified()) { getBootstrapOperations().updateSecurityAddonToBootstrap(); } } }
public final Pom getPomFromModuleName(final String moduleName) { final ProjectMetadata projectMetadata = getProjectMetadata(moduleName); return projectMetadata == null ? null : projectMetadata.getPom(); }
@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(); }
@Override protected void notifyForGenericListener(final String upstreamDependency) { if (projectOperations == null) { projectOperations = getProjectOperations(); } Validate.notNull(projectOperations, "ProjectOperations is required"); // If the upstream dependency is null or invalid do not continue if (StringUtils.isBlank(upstreamDependency) || !MetadataIdentificationUtils.isValid(upstreamDependency)) { return; } // If the upstream dependency isn't ProjectMetadata do not continue if (!ProjectMetadata.isValid(upstreamDependency)) { return; } // If the project isn't valid do not continue if (projectOperations.isProjectAvailable(ProjectMetadata.getModuleName(upstreamDependency))) { final boolean isGaeEnabled = projectOperations.isFeatureInstalled(FeatureNames.GAE); // We need to determine if the persistence state has changed, we do // this by comparing the last known state to the current state final boolean hasGaeStateChanged = wasGaeEnabled == null || isGaeEnabled != wasGaeEnabled; if (hasGaeStateChanged) { wasGaeEnabled = isGaeEnabled; for (final String producedMid : producedMids) { getMetadataService().evictAndGet(producedMid); } } } }
/** * {@inheritDoc} When Project metadata changes look for SpringSecurity * dependency and update menu artifacts. */ public void notify(String upstreamDependency, String downstreamDependency) { // Check if is project metadata if (ProjectMetadata.isValid(upstreamDependency)) { // Check if gvNIX menu is installed if (getMenuEntryOperations().isGvNixMenuAvailable()) { // if dependency changes or its first call if (!ObjectUtils.equals(getMenuEntryOperations() .isSpringSecurityInstalled(), hasSpringSecurity)) { LOGGER.finest("Spring Security changed or startup"); // update hasSpringSecurity variable and update artifacts hasSpringSecurity = getMenuEntryOperations() .isSpringSecurityInstalled(); getMenuEntryOperations().createWebArtefacts("~.web.menu"); } // If Bootstrap is installed and gvNIX Bootstrap menu is not // installed // is neccessary to install it. if (getProjectOperations().isFeatureInstalledInFocusedModule( "gvnix-bootstrap") && !getMenuEntryOperations() .isGvNixMenuBootstrapAvailable()) { getMenuEntryOperations().setupBootstrapMenu(); } } } }
final ProjectMetadata dependencyProject = getProjectMetadata(moduleToDependUpon); if (dependencyProject != null) { final Pom dependencyPom = dependencyProject.getPom(); if (!dependencyPom.getPath().equals(module.getPath())) { if (testDependency) {