You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "mbenson (via GitHub)" <gi...@apache.org> on 2024/03/18 22:39:55 UTC
[PR] [MNG-5235] interpolate available properties during default profile selection (Maven 3.9.x) [maven]
mbenson opened a new pull request, #1447:
URL: https://github.com/apache/maven/pull/1447
Using the available ModelInterpolator, evaluate profile activations after having interpolated any embedded property constructs among configurations of activations only.
Following this checklist to help us incorporate your
contribution quickly and easily:
- [X] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
- [X] Each commit in the pull request should have a meaningful subject line and body.
- [X] Format the pull request title like `[MNG-XXX] SUMMARY`,
where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA issue.
- [X] Also format the first line of the commit message like `[MNG-XXX] SUMMARY`.
Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
- [X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [X] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
be performed on your pull request automatically.
- [X] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [X] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [X] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-5235] interpolate available properties during default profile selection (Maven 3.9.x) [maven]
Posted by "rmannibucau (via GitHub)" <gi...@apache.org>.
rmannibucau commented on code in PR #1447:
URL: https://github.com/apache/maven/pull/1447#discussion_r1529831101
##########
maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java:
##########
@@ -44,29 +54,56 @@
@Singleton
public class DefaultProfileSelector implements ProfileSelector {
+ private static Properties asProperties(Map<String, String> m) {
+ return m.entrySet().stream()
+ .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (l, r) -> r, Properties::new));
+ }
+
@Inject
private List<ProfileActivator> activators = new ArrayList<>();
+ @Inject
+ private ModelInterpolator interpolator = new ModelInterpolator() {
Review Comment:
`@Inject` = new? :thinking:
##########
maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java:
##########
@@ -89,6 +126,35 @@ public List<Profile> getActiveProfiles(
return activeProfiles;
}
+ private Map<String, Profile> earlyInterpolateProfileActivations(
+ Collection<Profile> original, ProfileActivationContext context) {
+
+ Model model = new Model();
+
+ UnaryOperator<Profile> activatableProfile = p -> {
+ Profile result = new Profile();
+ result.setId(p.getId());
+ result.setActivation(p.getActivation());
+ return result;
+ };
+ model.setProfiles(original.stream().map(activatableProfile).collect(Collectors.toList()));
+
+ ModelBuildingRequest mbr = new DefaultModelBuildingRequest()
+ .setActiveProfileIds(context.getActiveProfileIds())
+ .setInactiveProfileIds(context.getInactiveProfileIds())
+ .setRawModel(model)
+ .setSystemProperties(asProperties(context.getSystemProperties()))
+ .setUserProperties(asProperties(context.getUserProperties()))
+ .setTwoPhaseBuilding(true)
+ .setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
+
+ interpolator
+ .interpolateModel(model, context.getProjectDirectory(), mbr, problem -> {})
+ .getProfiles();
+
+ return model.getProfiles().stream().collect(Collectors.toMap(Profile::getId, UnaryOperator.identity()));
Review Comment:
identity belongs to Function IIRC
##########
maven-model-builder/pom.xml:
##########
@@ -87,6 +87,11 @@ under the License.
<artifactId>xmlunit-matchers</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
Review Comment:
:pray: why mocking there? this is a hell anywhere in maven code base and ultimately the related tests are useless in general so let's try to avoid it
##########
maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java:
##########
@@ -89,6 +126,35 @@ public List<Profile> getActiveProfiles(
return activeProfiles;
}
+ private Map<String, Profile> earlyInterpolateProfileActivations(
+ Collection<Profile> original, ProfileActivationContext context) {
+
+ Model model = new Model();
+
+ UnaryOperator<Profile> activatableProfile = p -> {
+ Profile result = new Profile();
+ result.setId(p.getId());
+ result.setActivation(p.getActivation());
+ return result;
+ };
+ model.setProfiles(original.stream().map(activatableProfile).collect(Collectors.toList()));
+
+ ModelBuildingRequest mbr = new DefaultModelBuildingRequest()
Review Comment:
guess it would be saner to use the actual loaded model we already have at that time and avoid `asProperties` too since request is already there
can be done in `DefaultModelBuilder` probably
side note: we must somehow align it on `master` and not create a behavior in v3 which is different from v4 so for me ensuring v4 behavior (merge) and impl alignment is a prerequisite to this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8081] interpolate available properties during default profile selection (Maven 3.9.x) [maven]
Posted by "mbenson (via GitHub)" <gi...@apache.org>.
mbenson commented on PR #1447:
URL: https://github.com/apache/maven/pull/1447#issuecomment-2079676825
Sounds like this approach would keep the v3/v4 impls more similar. I'll work on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8081] Interpolate available properties during default profile selection (Maven 3.9.x) [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #1447:
URL: https://github.com/apache/maven/pull/1447
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8081] Interpolate available properties during default profile selection (Maven 3.9.x) [maven]
Posted by "mbenson (via GitHub)" <gi...@apache.org>.
mbenson commented on PR #1447:
URL: https://github.com/apache/maven/pull/1447#issuecomment-2090632621
Thanks @gnodet !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org