[MNG-7051] Return unmodifiable profile lists

This helps deprecation and keeps the code consistent.

Closes #452.
This commit is contained in:
Maarten Mulders 2021-02-12 17:06:47 +01:00
parent 9643ac630c
commit ad24f599ce
2 changed files with 11 additions and 10 deletions

View File

@ -278,51 +278,51 @@ public interface MavenExecutionRequest
MavenExecutionRequest setProfiles( List<Profile> 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<String> profiles );
/**
* @deprecated Use {@link #getProfileActivation()}.
* @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/
@Deprecated
MavenExecutionRequest setActiveProfiles( List<String> 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<String> 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<String> profiles );
/**
* @deprecated Use {@link #getProfileActivation()}.
* @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/
@Deprecated
MavenExecutionRequest setInactiveProfiles( List<String> 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<String> getInactiveProfiles();

View File

@ -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<String> 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<String> getInactiveProfiles()
{
return new ArrayList<>( getProfileIds( pa -> !pa.active ) );
return Collections.unmodifiableList( new ArrayList<>( getProfileIds( pa -> !pa.active ) ) );
}
/**