use of org.apache.maven.model.Activation in project intellij-community by JetBrains.
the class Maven30ServerEmbedderImpl method applyProfiles.
public static ProfileApplicationResult applyProfiles(MavenModel model, File basedir, MavenExplicitProfiles explicitProfiles, Collection<String> alwaysOnProfiles) throws RemoteException {
Model nativeModel = MavenModelConverter.toNativeModel(model);
Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
List<Profile> activatedPom = new ArrayList<Profile>();
List<Profile> activatedExternal = new ArrayList<Profile>();
List<Profile> activeByDefault = new ArrayList<Profile>();
List<Profile> rawProfiles = nativeModel.getProfiles();
List<Profile> expandedProfilesCache = null;
List<Profile> deactivatedProfiles = new ArrayList<Profile>();
for (int i = 0; i < rawProfiles.size(); i++) {
Profile eachRawProfile = rawProfiles.get(i);
if (disabledProfiles.contains(eachRawProfile.getId())) {
deactivatedProfiles.add(eachRawProfile);
continue;
}
boolean shouldAdd = enabledProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());
Activation activation = eachRawProfile.getActivation();
if (activation != null) {
if (activation.isActiveByDefault()) {
activeByDefault.add(eachRawProfile);
}
// expand only if necessary
if (expandedProfilesCache == null)
expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
Profile eachExpandedProfile = expandedProfilesCache.get(i);
for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
try {
if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
shouldAdd = true;
break;
}
} catch (ProfileActivationException e) {
Maven3ServerGlobals.getLogger().warn(e);
}
}
}
if (shouldAdd) {
if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
activatedPom.add(eachRawProfile);
} else {
activatedExternal.add(eachRawProfile);
}
}
}
List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
activatedProfiles.addAll(activatedExternal);
for (Profile each : activatedProfiles) {
new DefaultProfileInjector().injectProfile(nativeModel, each, null, null);
}
return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null), new MavenExplicitProfiles(collectProfilesIds(activatedProfiles), collectProfilesIds(deactivatedProfiles)));
}
use of org.apache.maven.model.Activation 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.Activation in project tesb-studio-se by Talend.
the class CreateMavenBundlePom method addProfileForCloud.
/**
* skip depoly phase in publich to cloud in parent pom, enable in nexus.
*/
private Profile addProfileForCloud() {
Profile deployCloudProfile = new Profile();
deployCloudProfile.setId("deploy-cloud");
Activation deployCloudActivation = new Activation();
ActivationProperty activationProperty = new ActivationProperty();
activationProperty.setName("!altDeploymentRepository");
deployCloudActivation.setProperty(activationProperty);
deployCloudProfile.setActivation(deployCloudActivation);
deployCloudProfile.setBuild(new Build());
deployCloudProfile.getBuild().addPlugin(addSkipDeployFeatureMavenPlugin());
return deployCloudProfile;
}
use of org.apache.maven.model.Activation in project tesb-studio-se by Talend.
the class CreateMavenDataServicePom method addProfileForCloud.
/**
* DOC skip depoly phase in publich to cloud in parent pom, enable in nexus.
*/
private Profile addProfileForCloud() {
Profile deployCloudProfile = new Profile();
deployCloudProfile.setId("deploy-cloud");
Activation deployCloudActivation = new Activation();
ActivationProperty activationProperty = new ActivationProperty();
activationProperty.setName("!altDeploymentRepository");
deployCloudActivation.setProperty(activationProperty);
deployCloudProfile.setActivation(deployCloudActivation);
deployCloudProfile.setBuild(new Build());
deployCloudProfile.getBuild().addPlugin(addSkipDeployFeatureMavenPlugin());
return deployCloudProfile;
}
Aggregations