From 8d53cd4cc60a7d2d4c4186bc5bbcceaefb74b809 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 18 Nov 2010 12:25:06 +0000 Subject: [PATCH] [MNG-4900] "Unresolveable build extension" when using shade plugin and repositories in profile git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1036433 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/DefaultMavenProjectBuilder.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 25cc8a879f..5625bf8bb3 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -85,6 +85,26 @@ public class DefaultMavenProjectBuilder request.setActiveProfileIds( profileManager.getExplicitlyActivatedIds() ); request.setInactiveProfileIds( profileManager.getExplicitlyDeactivatedIds() ); } + else + { + /* + * MNG-4900: Hack to workaround deficiency of legacy API which makes it impossible for plugins to access the + * global profile manager which is required to build a POM like a CLI invocation does. Failure to consider + * the activated profiles can cause repo declarations to be lost which in turn will result in artifact + * resolution failures, in particular when using the enhanced local repo which guards access to local files + * based on the configured remote repos. + */ + MavenSession session = legacySupport.getSession(); + if ( session != null ) + { + MavenExecutionRequest req = session.getRequest(); + if ( req != null ) + { + request.setActiveProfileIds( req.getActiveProfiles() ); + request.setInactiveProfileIds( req.getInactiveProfiles() ); + } + } + } return request; }