mirror of https://github.com/apache/maven.git
[MNG-6609] Maven 3.9: profile activation by packaging (#849)
Generate raw model before profile activation context is generated
This commit is contained in:
parent
eb66f225db
commit
e921f1564e
|
@ -276,6 +276,14 @@ public class DefaultModelBuilder
|
|||
|
||||
DefaultModelProblemCollector problems = new DefaultModelProblemCollector( result );
|
||||
|
||||
// read and validate raw model
|
||||
Model inputModel = request.getRawModel();
|
||||
if ( inputModel == null )
|
||||
{
|
||||
inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems );
|
||||
request.setRawModel( inputModel );
|
||||
}
|
||||
|
||||
// profile activation
|
||||
DefaultProfileActivationContext profileActivationContext = getProfileActivationContext( request );
|
||||
|
||||
|
@ -296,13 +304,6 @@ public class DefaultModelBuilder
|
|||
profileActivationContext.setUserProperties( profileProps );
|
||||
}
|
||||
|
||||
// read and validate raw model
|
||||
Model inputModel = request.getRawModel();
|
||||
if ( inputModel == null )
|
||||
{
|
||||
inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems );
|
||||
}
|
||||
|
||||
problems.setRootModel( inputModel );
|
||||
|
||||
ModelData resultData = new ModelData( request.getModelSource(), inputModel );
|
||||
|
@ -707,7 +708,11 @@ 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();
|
||||
userProperties.computeIfAbsent( (Object) ProfileActivationContext.PROPERTY_NAME_PACKAGING,
|
||||
( p ) -> (Object) request.getRawModel().getPackaging() );
|
||||
context.setUserProperties( userProperties );
|
||||
context.setProjectDirectory( ( request.getPomFile() != null ) ? request.getPomFile().getParentFile() : null );
|
||||
|
||||
return context;
|
||||
|
|
|
@ -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 3.9
|
||||
*/
|
||||
String PROPERTY_NAME_PACKAGING = "packaging";
|
||||
|
||||
/**
|
||||
* Gets the identifiers of those profiles that should be activated by explicit demand.
|
||||
|
|
Loading…
Reference in New Issue