Search in sources :

Example 1 with Extension

use of org.apache.maven.model.Extension in project maven-plugins by apache.

the class MavenJDOMWriter method iterateExtension.

// -- void iterateExclusion(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
     * Method iterateExtension
     *
     * @param counter
     * @param childTag
     * @param parentTag
     * @param list
     * @param parent
     */
protected void iterateExtension(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            Extension value = (Extension) it.next();
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateExtension(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Extension(org.apache.maven.model.Extension) Element(org.jdom.Element) Iterator(java.util.Iterator)

Example 2 with Extension

use of org.apache.maven.model.Extension in project maven-archetype by apache.

the class MavenJDOMWriter method iterateExtension.

// -- void iterateExclusion(Counter, Element, java.util.Collection, java.lang.String,
// java.lang.String)
/**
 * Method iterateExtension.
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateExtension(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
    boolean shouldExist = (list != null) && (list.size() > 0);
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            Extension value = (Extension) it.next();
            Element el;
            if ((elIt != null) && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateExtension(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Extension(org.apache.maven.model.Extension) Element(org.jdom.Element) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator)

Example 3 with Extension

use of org.apache.maven.model.Extension in project maven-plugins by apache.

the class MavenJDOMWriter method iterateExtension.

// -- void iterateExclusion(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
 * Method iterateExtension
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateExtension(Counter counter, Element parent, Collection<Extension> list, java.lang.String parentTag, java.lang.String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator<?> elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        for (Extension value : list) {
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateExtension(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Extension(org.apache.maven.model.Extension) Element(org.jdom.Element)

Example 4 with Extension

use of org.apache.maven.model.Extension in project felix by apache.

the class MavenJDOMWriter method iterateExtension.

// -- void iterateExclusion(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
 * Method iterateExtension
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateExtension(Counter counter, Element parent, Collection list, String parentTag, String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            Extension value = (Extension) it.next();
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateExtension(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Extension(org.apache.maven.model.Extension) Element(org.jdom.Element) Iterator(java.util.Iterator)

Example 5 with Extension

use of org.apache.maven.model.Extension in project maven-archetype by apache.

the class FilesetArchetypeCreator method createArchetypeProjectPom.

/**
 * Create the archetype project pom.xml file, that will be used to build the archetype.
 */
private File createArchetypeProjectPom(MavenProject project, ProjectBuildingRequest buildingRequest, Properties configurationProperties, File projectDir) throws TemplateCreationException, IOException {
    Model model = new Model();
    model.setModelVersion("4.0.0");
    // these values should be retrieved from the request with sensible defaults
    model.setGroupId(configurationProperties.getProperty(Constants.ARCHETYPE_GROUP_ID, project.getGroupId()));
    model.setArtifactId(configurationProperties.getProperty(Constants.ARCHETYPE_ARTIFACT_ID, project.getArtifactId()));
    model.setVersion(configurationProperties.getProperty(Constants.ARCHETYPE_VERSION, project.getVersion()));
    model.setPackaging("maven-archetype");
    model.setName(configurationProperties.getProperty(Constants.ARCHETYPE_ARTIFACT_ID, project.getArtifactId()));
    model.setUrl(configurationProperties.getProperty(Constants.ARCHETYPE_URL, project.getUrl()));
    model.setDescription(configurationProperties.getProperty(Constants.ARCHETYPE_DESCRIPTION, project.getDescription()));
    model.setLicenses(project.getLicenses());
    model.setDevelopers(project.getDevelopers());
    model.setScm(project.getScm());
    Build build = new Build();
    model.setBuild(build);
    if (project.getParent() != null) {
        MavenProject p = project.getParent();
        if (p.getDistributionManagement() != null) {
            model.setDistributionManagement(p.getDistributionManagement());
        }
        if (p.getBuildExtensions() != null) {
            for (Extension be : p.getBuildExtensions()) {
                model.getBuild().addExtension(be);
            }
        }
    }
    Extension extension = new Extension();
    extension.setGroupId("org.apache.maven.archetype");
    extension.setArtifactId("archetype-packaging");
    extension.setVersion(getArchetypeVersion());
    model.getBuild().addExtension(extension);
    Plugin plugin = new Plugin();
    plugin.setGroupId("org.apache.maven.plugins");
    plugin.setArtifactId("maven-archetype-plugin");
    plugin.setVersion(getArchetypeVersion());
    PluginManagement pluginManagement = new PluginManagement();
    pluginManagement.addPlugin(plugin);
    model.getBuild().setPluginManagement(pluginManagement);
    getLogger().debug("Creating archetype's pom");
    File archetypePomFile = new File(projectDir, Constants.ARCHETYPE_POM);
    archetypePomFile.getParentFile().mkdirs();
    copyResource("pom-prototype.xml", archetypePomFile);
    pomManager.writePom(model, archetypePomFile, archetypePomFile);
    return archetypePomFile;
}
Also used : Extension(org.apache.maven.model.Extension) PluginManagement(org.apache.maven.model.PluginManagement) MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) File(java.io.File) Plugin(org.apache.maven.model.Plugin)

Aggregations

Extension (org.apache.maven.model.Extension)5 Element (org.jdom.Element)4 Iterator (java.util.Iterator)3 File (java.io.File)1 ListIterator (java.util.ListIterator)1 Build (org.apache.maven.model.Build)1 Model (org.apache.maven.model.Model)1 Plugin (org.apache.maven.model.Plugin)1 PluginManagement (org.apache.maven.model.PluginManagement)1 MavenProject (org.apache.maven.project.MavenProject)1