gnodet-bot commented on code in PR #12377:
URL: https://github.com/apache/maven/pull/12377#discussion_r4486905424


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileSelector.java:
##########
@@ -140,4 +142,23 @@ private boolean isActiveByDefault(Profile profile) {
         Activation activation = profile.getActivation();
         return activation != null && activation.isActiveByDefault();
     }
+
+    /**
+     * Determines whether the given profile originates from a POM file
+     * by checking if the profile's {@link InputSource} has a non-empty model 
id.
+     * Profiles from settings.xml or other external sources will have
+     * a {@code null} or empty model id.
+     * Defaults to {@code true} if no location information is available,
+     * matching the previous default behavior.
+     */
+    private boolean isFromPom(Profile profile) {
+        InputLocation location = profile.getLocation("");
+        if (location != null) {
+            InputSource source = location.getSource();
+            if (source != null) {
+                return source.getModelId() != null && 
!source.getModelId().isEmpty();
+            }
+        }
+        return true;
+    }
 }

Review Comment:
   🔁 **Duplication:** `isFromPom()` is added verbatim in 
`DefaultProfileSelector`, `ConditionProfileActivator`, and 
`PropertyProfileActivator`. Consider extracting to a shared utility (e.g. 
`ProfileUtils.isFromPom(Profile)`) to avoid future divergence between copies.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to