diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java index 041b9f584e..74570eb38b 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java @@ -40,6 +40,10 @@ import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.graph.DependencyFilter; @@ -83,14 +87,16 @@ public class BootstrapCoreExtensionManager { RepositorySystemSession repoSession = repositorySystemSessionFactory.newRepositorySession( request ); List repositories = RepositoryUtils.toRepos( request.getPluginArtifactRepositories() ); + Interpolator interpolator = createInterpolator( request ); - return resolveCoreExtensions( repoSession, repositories, providedArtifacts, extensions ); + return resolveCoreExtensions( repoSession, repositories, providedArtifacts, extensions, interpolator ); } private List resolveCoreExtensions( RepositorySystemSession repoSession, List repositories, Set providedArtifacts, - List configuration ) + List configuration, + Interpolator interpolator ) throws Exception { List extensions = new ArrayList<>(); @@ -99,7 +105,8 @@ public class BootstrapCoreExtensionManager for ( CoreExtension extension : configuration ) { - List artifacts = resolveExtension( extension, repoSession, repositories, dependencyFilter ); + List artifacts = resolveExtension( extension, repoSession, repositories, + dependencyFilter, interpolator ); if ( !artifacts.isEmpty() ) { extensions.add( createExtension( extension, artifacts ) ); @@ -127,18 +134,20 @@ public class BootstrapCoreExtensionManager } private List resolveExtension( CoreExtension extension, RepositorySystemSession repoSession, - List repositories, DependencyFilter dependencyFilter ) + List repositories, DependencyFilter dependencyFilter, + Interpolator interpolator ) throws ExtensionResolutionException { try { - // TODO: enhance the PluginDependenciesResolver to provide a - // TODO: resolveCoreExtension method which uses a CoreExtension - // TODO: object instead of a Plugin as this makes no sense + /* TODO: Enhance the PluginDependenciesResolver to provide a + * resolveCoreExtension method which uses a CoreExtension + * object instead of a Plugin as this makes no sense. + */ Plugin plugin = new Plugin(); - plugin.setGroupId( extension.getGroupId() ); - plugin.setArtifactId( extension.getArtifactId() ); - plugin.setVersion( extension.getVersion() ); + plugin.setGroupId( interpolator.interpolate( extension.getGroupId() ) ); + plugin.setArtifactId( interpolator.interpolate( extension.getArtifactId() ) ); + plugin.setVersion( interpolator.interpolate( extension.getVersion() ) ); DependencyNode root = pluginDependenciesResolver .resolveCoreExtension( plugin, dependencyFilter, repositories, repoSession ); @@ -151,6 +160,18 @@ public class BootstrapCoreExtensionManager { throw new ExtensionResolutionException( extension, e.getCause() ); } + catch ( InterpolationException e ) + { + throw new ExtensionResolutionException( extension, e ); + } + } + + private static Interpolator createInterpolator( MavenExecutionRequest request ) + { + StringSearchInterpolator interpolator = new StringSearchInterpolator(); + interpolator.addValueSource( new MapBasedValueSource( request.getUserProperties() ) ); + interpolator.addValueSource( new MapBasedValueSource( request.getSystemProperties() ) ); + return interpolator; } }