use of org.apache.maven.model.Profile in project maven-plugins 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();
}
}
}
}
use of org.apache.maven.model.Profile in project felix 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, 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()) {
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();
}
}
}
}
use of org.apache.maven.model.Profile in project pom-manipulation-ext by release-engineering.
the class Project method getResolvedProfilePlugins.
/**
* This method will scan the plugins in the potentially active Profiles in this project and
* return a fully resolved list. Note that while updating the {@link Plugin} reference
* returned will be reflected in the Model as it is the same object, if you wish to
* remove or add items to the Model then you must use {@link #getModel()}
*
* @param session MavenSessionHandler, used by {@link PropertyResolver}
* @return a list of fully resolved {@link ProjectVersionRef} to the original {@link Plugin}
* @throws ManipulationException if an error occurs
*/
public HashMap<Profile, HashMap<ProjectVersionRef, Plugin>> getResolvedProfilePlugins(MavenSessionHandler session) throws ManipulationException {
if (resolvedProfilePlugins == null) {
resolvedProfilePlugins = new HashMap<>();
for (final Profile profile : ProfileUtils.getProfiles(session, model)) {
HashMap<ProjectVersionRef, Plugin> profileDeps = new HashMap<>();
if (profile.getBuild() != null) {
resolvePlugins(session, profile.getBuild().getPlugins(), profileDeps);
}
resolvedProfilePlugins.put(profile, profileDeps);
}
}
return resolvedProfilePlugins;
}
use of org.apache.maven.model.Profile in project pom-manipulation-ext by release-engineering.
the class Project method updateProfiles.
public void updateProfiles(List<Profile> remoteProfiles) {
final List<Profile> profiles = model.getProfiles();
if (!remoteProfiles.isEmpty()) {
for (Profile profile : remoteProfiles) {
final Iterator<Profile> i = profiles.iterator();
while (i.hasNext()) {
final Profile p = i.next();
if (profile.getId().equals(p.getId())) {
logger.debug("Removing local profile {} ", p);
i.remove();
// Don't break out of the loop so we can check for active profiles
}
// of activeByDefault. Therefore replace the activation.
if (p.getActivation() != null && p.getActivation().isActiveByDefault()) {
logger.warn("Profile {} is activeByDefault", p);
final Activation replacement = new Activation();
final ActivationProperty replacementProp = new ActivationProperty();
replacementProp.setName("!disableProfileActivation");
replacement.setProperty(replacementProp);
p.setActivation(replacement);
}
}
logger.debug("Adding profile {}", profile);
profiles.add(profile);
}
logger.info("Clearing resolved profile caches to trigger rescanning...");
resolvedProfileDependencies = null;
allResolvedProfileDependencies = null;
resolvedProfileManagedDependencies = null;
resolvedProfileManagedPlugins = null;
resolvedProfilePlugins = null;
}
}
use of org.apache.maven.model.Profile in project pom-manipulation-ext by release-engineering.
the class Project method getAllResolvedProfileDependencies.
/**
* This method will scan the dependencies in the potentially active Profiles in this project and
* return a fully resolved list. Note that this will return all dependencies including managed
* i.e. those with a group, artifact and potentially empty version.
*
* Note that while updating the {@link Dependency} reference returned will be reflected in the
* Model as it is the same object, if you wish to remove or add items to the Model then you
* must use {@link #getModel()}
*
* @param session MavenSessionHandler, used by {@link PropertyResolver}
* @return a list of fully resolved {@link ArtifactRef} to the original {@link Dependency}
* @throws ManipulationException if an error occurs
*/
public HashMap<Profile, HashMap<ArtifactRef, Dependency>> getAllResolvedProfileDependencies(MavenSessionHandler session) throws ManipulationException {
if (allResolvedProfileDependencies == null) {
allResolvedProfileDependencies = new HashMap<>();
for (final Profile profile : ProfileUtils.getProfiles(session, model)) {
HashMap<ArtifactRef, Dependency> profileDeps = new HashMap<>();
resolveDeps(session, profile.getDependencies(), true, profileDeps);
allResolvedProfileDependencies.put(profile, profileDeps);
}
}
return allResolvedProfileDependencies;
}
Aggregations