Skip to content

Commit

Permalink
[MNG-3309] Cascading profile activation
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 25, 2024
1 parent e82940f commit 3f184eb
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,14 +1055,15 @@ protected ModelBuilder createModelBuilder() {
new DefaultModelUrlNormalizer(new DefaultUrlNormalizer()),
new DefaultSuperPomProvider(modelProcessor),
new DefaultInheritanceAssembler(),
new DefaultProfileSelector(),
new DefaultProfileSelector(
new DefaultInterpolator(),
new ProfileActivationFilePathInterpolator(
new DefaultPathTranslator(), new DefaultRootLocator(), new DefaultInterpolator())),
new DefaultProfileInjector(),
new DefaultPluginManagementInjector(),
new DefaultDependencyManagementInjector(),
new DefaultDependencyManagementImporter(),
new DefaultPluginConfigurationExpander(),
new ProfileActivationFilePathInterpolator(
new DefaultPathTranslator(), new DefaultRootLocator(), new DefaultInterpolator()),
new DefaultModelVersionParser(getVersionScheme()),
List.of(),
new DefaultModelCacheFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.maven.internal.impl.model.DefaultPluginManagementInjector;
import org.apache.maven.internal.impl.model.DefaultProfileInjector;
import org.apache.maven.internal.impl.model.DefaultProfileSelector;
import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator;
import org.apache.maven.internal.impl.model.rootlocator.DefaultRootLocator;
import org.apache.maven.internal.impl.resolver.DefaultArtifactDescriptorReader;
import org.apache.maven.internal.impl.resolver.DefaultModelResolver;
Expand Down Expand Up @@ -1049,14 +1048,12 @@ protected ModelBuilder createModelBuilder() {
new DefaultModelUrlNormalizer(new DefaultUrlNormalizer()),
new DefaultSuperPomProvider(modelProcessor),
new DefaultInheritanceAssembler(),
new DefaultProfileSelector(),
new DefaultProfileSelector(null, null),
new DefaultProfileInjector(),
new DefaultPluginManagementInjector(),
new DefaultDependencyManagementInjector(),
new DefaultDependencyManagementImporter(),
new DefaultPluginConfigurationExpander(),
new ProfileActivationFilePathInterpolator(
new DefaultPathTranslator(), new DefaultRootLocator(), new DefaultInterpolator()),
new DefaultModelVersionParser(getVersionScheme()),
List.of(),
new DefaultModelCacheFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
package org.apache.maven.api.services.model;

import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.maven.api.model.Profile;

/**
* Describes the environmental context used to determine the activation status of profiles.
*
Expand Down Expand Up @@ -78,4 +81,11 @@ public interface ProfileActivationContext {
* @return The project properties, never {@code null}.
*/
Map<String, String> getProjectProperties();

/**
* Inject properties from newly activated profiles in order to trigger the cascading mechanism.
*
* @param activatedProfiles The collection of profiles that have been activated that may trigger the cascading effect.
*/
void addProfileProperties(Collection<Profile> activatedProfiles);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ public interface ProfileSelector {
* @param context The environmental context used to determine the activation status of a profile, must not be
* {@code null}.
* @param problems The container used to collect problems that were encountered, must not be {@code null}.
* @param cascade Indicates whether profile activation should cascade, i.e. properties from an activated profile may
* trigger the activation of other profiles.
* @return The profiles that have been activated, never {@code null}.
*/
List<Profile> getActiveProfiles(
Collection<Profile> profiles, ProfileActivationContext context, ModelProblemCollector problems);
Collection<Profile> profiles,
ProfileActivationContext context,
ModelProblemCollector problems,
boolean cascade);
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static org.apache.maven.api.model.Profile convertFromSettingsProfile(Prof
}

org.apache.maven.api.model.Profile value = profile.build();
value.setSource("settings.xml");
value.setSource(org.apache.maven.api.model.Profile.SOURCE_SETTINGS);
return value;
}

Expand Down
Loading

0 comments on commit 3f184eb

Please sign in to comment.