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();
}
}
}
}
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();
}
}
}
}
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();
}
}
}
}
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();
}
}
}
}
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;
}
Aggregations