[MNG-6609] expose packaging via property "project.packaging" (#835)

This commit is contained in:
Konrad Windszus 2022-10-24 13:13:35 +02:00 committed by GitHub
parent 0d70f7295d
commit 79b6dd0bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1046,7 +1046,14 @@ public class DefaultModelBuilder
context.setActiveProfileIds( request.getActiveProfileIds() );
context.setInactiveProfileIds( request.getInactiveProfileIds() );
context.setSystemProperties( request.getSystemProperties() );
context.setUserProperties( request.getUserProperties() );
// enrich user properties with project packaging
Properties userProperties = request.getUserProperties();
if ( !userProperties.containsKey( ProfileActivationContext.PROPERTY_NAME_PACKAGING ) )
{
userProperties.put( ProfileActivationContext.PROPERTY_NAME_PACKAGING,
request.getFileModel().getPackaging() );
}
context.setUserProperties( userProperties );
context.setProjectDirectory( ( request.getPomFile() != null ) ? request.getPomFile().getParentFile() : null );
return context;

View File

@ -30,6 +30,12 @@ import java.util.Map;
*/
public interface ProfileActivationContext
{
/**
* Key of the property containing the project's packaging.
* Available in {@link #getUserProperties()}.
* @since 4.0
*/
String PROPERTY_NAME_PACKAGING = "packaging";
/**
* Gets the identifiers of those profiles that should be activated by explicit demand.