Examples of POM


Examples of org.springframework.roo.project.maven.Pom

                : existingJsfImplementation;
    }

    private JsfLibrary getExistingOrDefaultJsfLibrary(
            final Element configuration) {
        final Pom pom = projectOperations
                .getPomFromModuleName(projectOperations.getFocusedModuleName());
        JsfLibrary existingJsfImplementation = null;
        for (final JsfLibrary value : JsfLibrary.values()) {
            final Element jsfDependencyElement = XmlUtils.findFirstElement(
                    JSF_LIBRARY_XPATH + "[@id = '" + value.name() + "']"
                            + DEPENDENCY_XPATH, configuration);
            if (jsfDependencyElement != null
                    && pom.isDependencyRegistered(new Dependency(
                            jsfDependencyElement))) {
                existingJsfImplementation = value;
                break;
            }
        }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

                    final Element rootElement = XmlUtils
                            .stringToElement(pomContents);
                    resolvePoms(rootElement, pathToChangedPom, pomModuleMap);
                    final String moduleName = getModuleName(FileUtils
                            .getFirstDirectory(pathToChangedPom));
                    final Pom pom = pomFactory.getInstance(rootElement,
                            pathToChangedPom, moduleName);
                    Validate.notNull(pom,
                            "POM is null for module '%s' and path '%s'",
                            moduleName, pathToChangedPom);
                    pomMap.put(pathToChangedPom, pom);
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    private String getProposedJavaType(final String fileCanonicalPath) {
        Validate.notBlank(fileCanonicalPath, "File canonical path required");
        // Determine the JavaType for this file
        String relativePath = "";
        final Pom moduleForFileIdentifier = projectOperations
                .getModuleForFileIdentifier(fileCanonicalPath);
        if (moduleForFileIdentifier == null) {
            return relativePath;
        }

        for (final PhysicalPath physicalPath : moduleForFileIdentifier
                .getPhysicalPaths()) {
            final String moduleCanonicalPath = FileUtils
                    .ensureTrailingSeparator(FileUtils
                            .getCanonicalPath(physicalPath.getLocation()));
            if (fileCanonicalPath.startsWith(moduleCanonicalPath)) {
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

                "Plugin modification prohibited at this time");
        Validate.notNull(newPlugins, "Plugins required");
        if (CollectionUtils.isEmpty(newPlugins)) {
            return;
        }
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so plugin addition cannot be performed");

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element root = document.getDocumentElement();
        final Element pluginsElement = DomUtils.createChildIfNotExists(
                "/project/build/plugins", root, document);
        final List<Element> existingPluginElements = XmlUtils.findElements(
                "plugin", pluginsElement);

        final List<String> addedPlugins = new ArrayList<String>();
        final List<String> removedPlugins = new ArrayList<String>();
        for (final Plugin newPlugin : newPlugins) {
            if (newPlugin != null) {

                // Look for any existing instances of this plugin
                boolean inserted = false;
                for (final Element existingPluginElement : existingPluginElements) {
                    final Plugin existingPlugin = new Plugin(
                            existingPluginElement);
                    if (existingPlugin.hasSameCoordinates(newPlugin)) {
                        // It's the same artifact, but might have a different
                        // version, exclusions, etc.
                        if (!inserted) {
                            // We haven't added the new one yet; do so now
                            pluginsElement.insertBefore(
                                    newPlugin.getElement(document),
                                    existingPluginElement);
                            inserted = true;
                            if (!newPlugin.getVersion().equals(
                                    existingPlugin.getVersion())) {
                                // It's a genuine version change => mention the
                                // old and new versions in the message
                                addedPlugins.add(newPlugin
                                        .getSimpleDescription());
                                removedPlugins.add(existingPlugin
                                        .getSimpleDescription());
                            }
                        }
                        // Either way, we remove the previous one in case it was
                        // different in any way
                        pluginsElement.removeChild(existingPluginElement);
                    }
                    // Keep looping in case it's present more than once
                }
                if (!inserted) {
                    // We didn't encounter any existing dependencies with the
                    // same coordinates; add it now
                    pluginsElement.appendChild(newPlugin.getElement(document));
                    addedPlugins.add(newPlugin.getSimpleDescription());
                }
            }
        }

        if (!newPlugins.isEmpty()) {
            final String message = getPomPluginsUpdateMessage(addedPlugins,
                    removedPlugins);
            fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                    XmlUtils.nodeToString(document), message, false);
        }
    }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    public void addDependencies(final String moduleName,
            final Collection<? extends Dependency> newDependencies) {
        Validate.isTrue(isProjectAvailable(moduleName),
                "Dependency modification prohibited; no such module '%s'",
                moduleName);
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so dependencies cannot be added");

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element dependenciesElement = DomUtils.createChildIfNotExists(
                "dependencies", document.getDocumentElement(), document);
        final List<Element> existingDependencyElements = XmlUtils.findElements(
                "dependency", dependenciesElement);

        final List<String> addedDependencies = new ArrayList<String>();
        final List<String> removedDependencies = new ArrayList<String>();
        final List<String> skippedDependencies = new ArrayList<String>();
        for (final Dependency newDependency : newDependencies) {
            if (pom.canAddDependency(newDependency)) {
                // Look for any existing instances of this dependency
                boolean inserted = false;
                for (final Element existingDependencyElement : existingDependencyElements) {
                    final Dependency existingDependency = new Dependency(
                            existingDependencyElement);
                    if (existingDependency.hasSameCoordinates(newDependency)) {
                        // It's the same artifact, but might have a different
                        // version, exclusions, etc.
                        if (!inserted) {
                            // We haven't added the new one yet; do so now
                            dependenciesElement.insertBefore(
                                    newDependency.getElement(document),
                                    existingDependencyElement);
                            inserted = true;
                            if (!newDependency.getVersion().equals(
                                    existingDependency.getVersion())) {
                                // It's a genuine version change => mention the
                                // old and new versions in the message
                                addedDependencies.add(newDependency
                                        .getSimpleDescription());
                                removedDependencies.add(existingDependency
                                        .getSimpleDescription());
                            }
                        }
                        // Either way, we remove the previous one in case it was
                        // different in any way
                        dependenciesElement
                                .removeChild(existingDependencyElement);
                    }
                    // Keep looping in case it's present more than once
                }
                if (!inserted) {
                    // We didn't encounter any existing dependencies with the
                    // same coordinates; add it now
                    dependenciesElement.appendChild(newDependency
                            .getElement(document));
                    addedDependencies.add(newDependency.getSimpleDescription());
                }
            }
            else {
                skippedDependencies.add(newDependency.getSimpleDescription());
            }
        }
        if (!newDependencies.isEmpty() || !skippedDependencies.isEmpty()) {
            final String message = getPomDependenciesUpdateMessage(
                    addedDependencies, removedDependencies, skippedDependencies);
            fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                    XmlUtils.nodeToString(document), message, false);
        }
    }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    public void addFilter(final String moduleName, final Filter filter) {
        Validate.isTrue(isProjectAvailable(moduleName),
                "Filter modification prohibited at this time");
        Validate.notNull(filter, "Filter required");
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so filter addition cannot be performed");
        if (filter == null || pom.isFilterRegistered(filter)) {
            return;
        }

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element root = document.getDocumentElement();
        final String descriptionOfChange;
        final Element buildElement = XmlUtils.findFirstElement(
                "/project/build", root);
        final Element existingFilter = XmlUtils.findFirstElement(
                "filters/filter['" + filter.getValue() + "']", buildElement);
        if (existingFilter == null) {
            // No such filter; add it
            final Element filtersElement = DomUtils.createChildIfNotExists(
                    "filters", buildElement, document);
            filtersElement.appendChild(XmlUtils.createTextElement(document,
                    "filter", filter.getValue()));
            descriptionOfChange = highlight(ADDED + " filter") + " '"
                    + filter.getValue() + "'";
        }
        else {
            existingFilter.setTextContent(filter.getValue());
            descriptionOfChange = highlight(UPDATED + " filter") + " '"
                    + filter.getValue() + "'";
        }

        fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                XmlUtils.nodeToString(document), descriptionOfChange, false);
    }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    public void addModuleDependency(final String moduleToDependUpon) {
        if (StringUtils.isBlank(moduleToDependUpon)) {
            return; // No need to ever add a dependency upon the root POM
        }
        final Pom focusedModule = getFocusedModule();
        if (focusedModule != null
                && StringUtils.isNotBlank(focusedModule.getModuleName())
                && !moduleToDependUpon.equals(focusedModule.getModuleName())) {
            final ProjectMetadata dependencyProject = getProjectMetadata(moduleToDependUpon);
            if (dependencyProject != null) {
                final Pom dependencyPom = dependencyProject.getPom();
                if (!dependencyPom.getPath().equals(focusedModule.getPath())) {
                    final Dependency dependency = dependencyPom
                            .asDependency(COMPILE);
                    if (!focusedModule
                            .hasDependencyExcludingVersion(dependency)) {
                        addDependency(focusedModule.getModuleName(), dependency);
                        detectCircularDependency(focusedModule, dependencyPom);
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    public void addProperty(final String moduleName, final Property property) {
        Validate.isTrue(isProjectAvailable(moduleName),
                "Property modification prohibited at this time");
        Validate.notNull(property, "Property to add required");
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so property addition cannot be performed");
        if (pom.isPropertyRegistered(property)) {
            return;
        }

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element root = document.getDocumentElement();
        final String descriptionOfChange;
        final Element existing = XmlUtils.findFirstElement(
                "/project/properties/" + property.getName(), root);
        if (existing == null) {
            // No existing property of this name; add it
            final Element properties = DomUtils.createChildIfNotExists(
                    "properties", document.getDocumentElement(), document);
            properties.appendChild(XmlUtils.createTextElement(document,
                    property.getName(), property.getValue()));
            descriptionOfChange = highlight(ADDED + " property") + " '"
                    + property.getName() + "' = '" + property.getValue() + "'";
        }
        else {
            // A property of this name exists; update it
            existing.setTextContent(property.getValue());
            descriptionOfChange = highlight(UPDATED + " property") + " '"
                    + property.getName() + "' to '" + property.getValue() + "'";
        }

        fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                XmlUtils.nodeToString(document), descriptionOfChange, false);
    }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

        Validate.notNull(repositories, "Repositories required");

        if (CollectionUtils.isEmpty(repositories)) {
            return;
        }
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so repository addition cannot be performed");
        if ("pluginRepository".equals(path)) {
            if (pom.isAllPluginRepositoriesRegistered(repositories)) {
                return;
            }
        }
        else if (pom.isAllRepositoriesRegistered(repositories)) {
            return;
        }

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element repositoriesElement = DomUtils.createChildIfNotExists(
                containingPath, document.getDocumentElement(), document);

        final List<String> addedRepositories = new ArrayList<String>();
        for (final Repository repository : repositories) {
            if ("pluginRepository".equals(path)) {
                if (pom.isPluginRepositoryRegistered(repository)) {
                    continue;
                }
            }
            else {
                if (pom.isRepositoryRegistered(repository)) {
                    continue;
                }
            }
            if (repository != null) {
                repositoriesElement.appendChild(repository.getElement(document,
                        path));
                addedRepositories.add(repository.getUrl());
            }
        }
        final String message = getDescriptionOfChange(ADDED, addedRepositories,
                path, containingPath);

        fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                XmlUtils.nodeToString(document), message, false);
    }
View Full Code Here

Examples of org.springframework.roo.project.maven.Pom

    public void addResource(final String moduleName, final Resource resource) {
        Validate.isTrue(isProjectAvailable(moduleName),
                "Resource modification prohibited at this time");
        Validate.notNull(resource, "Resource to add required");
        final Pom pom = getPomFromModuleName(moduleName);
        Validate.notNull(pom,
                "The pom is not available, so resource addition cannot be performed");
        if (pom.isResourceRegistered(resource)) {
            return;
        }

        final Document document = XmlUtils.readXml(fileManager
                .getInputStream(pom.getPath()));
        final Element buildElement = XmlUtils.findFirstElement(
                "/project/build", document.getDocumentElement());
        final Element resourcesElement = DomUtils.createChildIfNotExists(
                "resources", buildElement, document);
        resourcesElement.appendChild(resource.getElement(document));
        final String descriptionOfChange = highlight(ADDED + " resource") + " "
                + resource.getSimpleDescription();

        fileManager.createOrUpdateTextFileIfRequired(pom.getPath(),
                XmlUtils.nodeToString(document), descriptionOfChange, false);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.