use of org.apache.maven.model.Profile in project maven-archetype by apache.
the class DefaultPomManager method mergeProfiles.
private void mergeProfiles(Model model, Model generatedModel) {
@SuppressWarnings("unchecked") List<Profile> generatedProfiles = generatedModel.getProfiles();
if (generatedProfiles != null && generatedProfiles.size() > 0) {
@SuppressWarnings("unchecked") List<Profile> modelProfiles = model.getProfiles();
Map<String, Profile> modelProfileIdMap = new HashMap<String, Profile>();
if (modelProfiles == null) {
modelProfiles = new ArrayList<Profile>();
model.setProfiles(modelProfiles);
} else if (modelProfiles.size() > 0) {
// add profile ids from the model for later lookups to the modelProfileIds set
for (Profile modelProfile : modelProfiles) {
modelProfileIdMap.put(modelProfile.getId(), modelProfile);
}
}
for (Profile generatedProfile : generatedProfiles) {
String generatedProfileId = generatedProfile.getId();
if (!modelProfileIdMap.containsKey(generatedProfileId)) {
model.addProfile(generatedProfile);
} else {
getLogger().warn("Try to merge profiles with id " + generatedProfileId);
mergeModelBase((Profile) modelProfileIdMap.get(generatedProfileId), generatedProfile);
mergeProfileBuild((Profile) modelProfileIdMap.get(generatedProfileId), generatedProfile);
}
}
}
}
use of org.apache.maven.model.Profile in project maven-archetype by apache.
the class MavenJDOMWriter method iterateProfile.
// -- void iteratePluginExecution(Counter, Element, java.util.Collection, java.lang.String,
// java.lang.String)
/**
* Method iterateProfile.
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateProfile(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()) {
Profile value = (Profile) 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);
}
updateProfile(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
Aggregations