You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2022/10/19 04:42:44 UTC
[maven] 01/01: [MNG-6609] expose packaging via property "project.packaging"
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/profile-activation-by-packaging
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 0c35ec6430d825055f988a1a125bb7b9367d948c
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Oct 19 06:42:32 2022 +0200
[MNG-6609] expose packaging via property "project.packaging"
This can be used for packaging specific profiles with the property
activator.
---
.../org/apache/maven/model/building/DefaultModelBuilder.java | 9 ++++++++-
.../org/apache/maven/model/profile/ProfileActivationContext.java | 6 ++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 3e21fc72e..0b7fccc4b 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -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;
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java
index d501e660a..42a4ddf32 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java
@@ -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 = "project.packaging";
/**
* Gets the identifiers of those profiles that should be activated by explicit demand.