public Map < String , String > readPropertiesFromActiveProfiles ( final String prefix , final String ... properties ) { if ( settings == null ) { console . debug ( "No maven setting injected" ) ; return Collections . emptyMap ( ) ; } final List < String > activeProfilesList = settings . getActiveProfiles ( ) ; if ( activeProfilesList . isEmpty ( ) ) { console . debug ( "No active profiles found" ) ; return Collections . emptyMap ( ) ; } final Map < String , String > map = new HashMap < String , String > ( ) ; final Set < String > activeProfiles = new HashSet < String > ( activeProfilesList ) ; // Iterate over all active profiles in order for ( final Profile profile : settings . getProfiles ( ) ) { // Check if the profile is active final String profileId = profile . getId ( ) ; if ( activeProfiles . contains ( profileId ) ) { console . debug ( "Trying active profile " + profileId ) ; for ( final String property : properties ) { final String propKey = prefix != null ? prefix + property : property ; final String value = profile . getProperties ( ) . getProperty ( propKey ) ; if ( value != null ) { console . debug ( "Found property " + property + " in profile " + profileId ) ; map . put ( property , value ) ; } } } } return map ; }
Read properties from the active profiles .