From ad24f599cecf2cbaa94c0339d9256946f846b173 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Fri, 12 Feb 2021 17:06:47 +0100 Subject: [PATCH] [MNG-7051] Return unmodifiable profile lists This helps deprecation and keeps the code consistent. Closes #452. --- .../maven/execution/MavenExecutionRequest.java | 16 ++++++++-------- .../maven/execution/ProfileActivation.java | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index f31e33fb24..d0ac0f1bd0 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -278,51 +278,51 @@ public interface MavenExecutionRequest MavenExecutionRequest setProfiles( List profiles ); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest addActiveProfile( String profile ); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest addActiveProfiles( List profiles ); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest setActiveProfiles( List profiles ); /** * @return The list of profiles that the user wants to activate. - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated List getActiveProfiles(); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest addInactiveProfile( String profile ); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest addInactiveProfiles( List profiles ); /** - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated MavenExecutionRequest setInactiveProfiles( List profiles ); /** * @return The list of profiles that the user wants to de-activate. - * @deprecated Use {@link #getProfileActivation()}. + * @deprecated Since Maven 4: use {@link #getProfileActivation()}. */ @Deprecated List getInactiveProfiles(); diff --git a/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java b/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java index 21530bd75c..1837696a4d 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java +++ b/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java @@ -20,6 +20,7 @@ package org.apache.maven.execution; */ import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -74,7 +75,7 @@ public class ProfileActivation @Deprecated public List getActiveProfiles() { - return new ArrayList<>( getProfileIds( pa -> pa.active ) ); + return Collections.unmodifiableList( new ArrayList<>( getProfileIds( pa -> pa.active ) ) ); } /** @@ -84,7 +85,7 @@ public class ProfileActivation @Deprecated public List getInactiveProfiles() { - return new ArrayList<>( getProfileIds( pa -> !pa.active ) ); + return Collections.unmodifiableList( new ArrayList<>( getProfileIds( pa -> !pa.active ) ) ); } /**