mirror of https://github.com/apache/maven.git
MNG-5771 use extension.xml to define core exported artifacts and packages
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
45563ff5cb
commit
8631d79ca3
|
@ -27,6 +27,9 @@ public interface ArtifactFilterManager
|
|||
{
|
||||
/**
|
||||
* Returns a filter for core + extension artifacts.
|
||||
*
|
||||
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin
|
||||
* extensions.
|
||||
*/
|
||||
ArtifactFilter getArtifactFilter();
|
||||
|
||||
|
@ -36,9 +39,10 @@ public interface ArtifactFilterManager
|
|||
ArtifactFilter getCoreArtifactFilter();
|
||||
|
||||
/**
|
||||
* Exclude an extension artifact (doesn't affect getArtifactFilter's result,
|
||||
* only getExtensionArtifactFilter).
|
||||
* @param artifactId
|
||||
* Exclude an extension artifact (doesn't affect getArtifactFilter's result, only getExtensionArtifactFilter).
|
||||
*
|
||||
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin
|
||||
* extensions.
|
||||
*/
|
||||
void excludeArtifact( String artifactId );
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.apache.maven;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core extensions.
|
||||
*/
|
||||
public interface ArtifactFilterManagerDelegate
|
||||
{
|
||||
|
||||
|
|
|
@ -19,96 +19,43 @@ package org.apache.maven;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.apache.maven.extension.internal.DefaultCoreExports;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @todo this should probably be a component with some dynamic control of filtering
|
||||
*/
|
||||
@Component( role = ArtifactFilterManager.class )
|
||||
@Named
|
||||
@Singleton
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public class DefaultArtifactFilterManager
|
||||
implements ArtifactFilterManager
|
||||
{
|
||||
|
||||
private static final Set<String> DEFAULT_EXCLUSIONS;
|
||||
// this is a live injected collection
|
||||
protected final List<ArtifactFilterManagerDelegate> delegates;
|
||||
|
||||
@Requirement
|
||||
private PlexusContainer plexus;
|
||||
protected final Set<String> coreArtifacts;
|
||||
|
||||
static
|
||||
protected final Set<String> excludedArtifacts;
|
||||
|
||||
@Inject
|
||||
public DefaultArtifactFilterManager( List<ArtifactFilterManagerDelegate> delegates, DefaultCoreExports extensions )
|
||||
{
|
||||
Set<String> artifacts = new HashSet<String>();
|
||||
|
||||
artifacts.add( "classworlds:classworlds" );
|
||||
artifacts.add( "org.codehaus.plexus:plexus-classworlds" );
|
||||
artifacts.add( "org.codehaus.plexus:plexus-component-api" );
|
||||
artifacts.add( "org.codehaus.plexus:plexus-container-default" );
|
||||
artifacts.add( "plexus:plexus-container-default" );
|
||||
artifacts.add( "org.sonatype.spice:spice-inject-plexus" );
|
||||
artifacts.add( "org.sonatype.sisu:sisu-inject-plexus" );
|
||||
artifacts.add( "org.eclipse.sisu:org.eclipse.sisu.plexus" );
|
||||
artifacts.add( "org.apache.maven:maven-artifact" );
|
||||
artifacts.add( "org.apache.maven:maven-aether-provider" );
|
||||
artifacts.add( "org.apache.maven:maven-artifact-manager" );
|
||||
artifacts.add( "org.apache.maven:maven-compat" );
|
||||
artifacts.add( "org.apache.maven:maven-core" );
|
||||
artifacts.add( "org.apache.maven:maven-error-diagnostics" );
|
||||
artifacts.add( "org.apache.maven:maven-lifecycle" );
|
||||
artifacts.add( "org.apache.maven:maven-model" );
|
||||
artifacts.add( "org.apache.maven:maven-model-builder" );
|
||||
artifacts.add( "org.apache.maven:maven-monitor" );
|
||||
artifacts.add( "org.apache.maven:maven-plugin-api" );
|
||||
artifacts.add( "org.apache.maven:maven-plugin-descriptor" );
|
||||
artifacts.add( "org.apache.maven:maven-plugin-parameter-documenter" );
|
||||
artifacts.add( "org.apache.maven:maven-plugin-registry" );
|
||||
artifacts.add( "org.apache.maven:maven-profile" );
|
||||
artifacts.add( "org.apache.maven:maven-project" );
|
||||
artifacts.add( "org.apache.maven:maven-repository-metadata" );
|
||||
artifacts.add( "org.apache.maven:maven-settings" );
|
||||
artifacts.add( "org.apache.maven:maven-settings-builder" );
|
||||
artifacts.add( "org.apache.maven:maven-toolchain" );
|
||||
artifacts.add( "org.apache.maven.wagon:wagon-provider-api" );
|
||||
artifacts.add( "org.eclipse.aether:aether-api" );
|
||||
artifacts.add( "org.eclipse.aether:aether-spi" );
|
||||
artifacts.add( "org.eclipse.aether:aether-impl" );
|
||||
//
|
||||
// We must also filter out the old or NoClassDefFoundErrors will surface
|
||||
//
|
||||
artifacts.add( "org.sonatype.aether:aether-api" );
|
||||
artifacts.add( "org.sonatype.aether:aether-spi" );
|
||||
artifacts.add( "org.sonatype.aether:aether-impl" );
|
||||
|
||||
/*
|
||||
* NOTE: Don't exclude the wagons or any of their dependencies (apart from the wagon API). This would otherwise
|
||||
* provoke linkage errors for wagons contributed by build extensions. We also don't need to exclude the wagons
|
||||
* from plugins. Plugins that use wagons directly and declare the corresponding dependency will simply use a
|
||||
* wagon from their plugin realm.
|
||||
*/
|
||||
|
||||
DEFAULT_EXCLUSIONS = Collections.unmodifiableSet( artifacts );
|
||||
}
|
||||
|
||||
protected Set<String> excludedArtifacts = new HashSet<String>( DEFAULT_EXCLUSIONS );
|
||||
|
||||
/**
|
||||
* @deprecated Use this class as a component instead, and then use getArtifactFilter().
|
||||
*/
|
||||
public static ArtifactFilter createStandardFilter()
|
||||
{
|
||||
// TODO: configure this from bootstrap or scan lib
|
||||
return new ExclusionSetFilter( DEFAULT_EXCLUSIONS );
|
||||
this.delegates = delegates;
|
||||
this.coreArtifacts = ImmutableSet.copyOf( extensions.getExportedArtifacts() );
|
||||
this.excludedArtifacts = new LinkedHashSet<String>( extensions.getExportedArtifacts() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,7 +67,7 @@ public class DefaultArtifactFilterManager
|
|||
{
|
||||
Set<String> excludes = new LinkedHashSet<String>( excludedArtifacts );
|
||||
|
||||
for ( ArtifactFilterManagerDelegate delegate : getDelegates() )
|
||||
for ( ArtifactFilterManagerDelegate delegate : delegates )
|
||||
{
|
||||
delegate.addExcludes( excludes );
|
||||
}
|
||||
|
@ -138,21 +85,6 @@ public class DefaultArtifactFilterManager
|
|||
return new ExclusionSetFilter( getCoreArtifactExcludes() );
|
||||
}
|
||||
|
||||
private List<ArtifactFilterManagerDelegate> getDelegates()
|
||||
{
|
||||
try
|
||||
{
|
||||
return plexus.lookupList( ArtifactFilterManagerDelegate.class );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
return new ArrayList<ArtifactFilterManagerDelegate>();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.maven.ArtifactFilterManager#excludeArtifact(java.lang.String)
|
||||
*/
|
||||
public void excludeArtifact( String artifactId )
|
||||
{
|
||||
excludedArtifacts.add( artifactId );
|
||||
|
@ -160,9 +92,9 @@ public class DefaultArtifactFilterManager
|
|||
|
||||
public Set<String> getCoreArtifactExcludes()
|
||||
{
|
||||
Set<String> excludes = new LinkedHashSet<String>( DEFAULT_EXCLUSIONS );
|
||||
Set<String> excludes = new LinkedHashSet<String>( coreArtifacts );
|
||||
|
||||
for ( ArtifactFilterManagerDelegate delegate : getDelegates() )
|
||||
for ( ArtifactFilterManagerDelegate delegate : delegates )
|
||||
{
|
||||
delegate.addCoreExcludes( excludes );
|
||||
}
|
||||
|
|
|
@ -31,8 +31,13 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.classrealm.ClassRealmRequest.RealmType;
|
||||
import org.apache.maven.extension.internal.DefaultCoreExports;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.codehaus.plexus.MutablePlexusContainer;
|
||||
|
@ -40,13 +45,12 @@ import org.codehaus.plexus.PlexusContainer;
|
|||
import org.codehaus.plexus.classworlds.ClassWorld;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Manages the class realms used by Maven. <strong>Warning:</strong> This is an internal utility class that is only
|
||||
* public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted
|
||||
|
@ -54,7 +58,8 @@ import org.eclipse.aether.artifact.Artifact;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = ClassRealmManager.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultClassRealmManager
|
||||
implements ClassRealmManager
|
||||
{
|
||||
|
@ -69,23 +74,38 @@ public class DefaultClassRealmManager
|
|||
*/
|
||||
private static final ClassLoader PARENT_CLASSLOADER = ClassWorld.class.getClassLoader();
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
private final Logger logger;
|
||||
|
||||
@Requirement
|
||||
protected PlexusContainer container;
|
||||
private final ClassWorld world;
|
||||
|
||||
private final ClassRealm containerRealm;
|
||||
|
||||
// this is a live injected collection
|
||||
private final List<ClassRealmManagerDelegate> delegates;
|
||||
|
||||
private final Map<String, ClassLoader> coreImports;
|
||||
|
||||
private ClassRealm mavenRealm;
|
||||
|
||||
private ClassWorld getClassWorld()
|
||||
@Inject
|
||||
public DefaultClassRealmManager( Logger logger, PlexusContainer container,
|
||||
List<ClassRealmManagerDelegate> delegates, DefaultCoreExports coreExtensions )
|
||||
{
|
||||
return ( (MutablePlexusContainer) container ).getClassWorld();
|
||||
this.logger = logger;
|
||||
this.world = ( (MutablePlexusContainer) container ).getClassWorld();
|
||||
this.containerRealm = container.getContainerRealm();
|
||||
this.delegates = delegates;
|
||||
|
||||
Map<String, ClassLoader> coreImports = new HashMap<String, ClassLoader>();
|
||||
for ( String corePackage : coreExtensions.getExportedPackages() )
|
||||
{
|
||||
coreImports.put( corePackage, containerRealm );
|
||||
}
|
||||
this.coreImports = ImmutableMap.copyOf( coreImports );
|
||||
}
|
||||
|
||||
private ClassRealm newRealm( String id )
|
||||
{
|
||||
ClassWorld world = getClassWorld();
|
||||
|
||||
synchronized ( world )
|
||||
{
|
||||
String realmId = id;
|
||||
|
@ -123,8 +143,7 @@ public class DefaultClassRealmManager
|
|||
|
||||
List<String> parentImports = new ArrayList<String>();
|
||||
|
||||
Map<String, ClassLoader> foreignImports = new HashMap<String, ClassLoader>();
|
||||
importMavenApi( foreignImports );
|
||||
Map<String, ClassLoader> foreignImports = new HashMap<String, ClassLoader>( coreImports );
|
||||
|
||||
callDelegates( mavenRealm, RealmType.Core, mavenRealm.getParentClassLoader(), parentImports,
|
||||
foreignImports, constituents );
|
||||
|
@ -137,104 +156,6 @@ public class DefaultClassRealmManager
|
|||
return mavenRealm;
|
||||
}
|
||||
|
||||
private void importMavenApi( Map<String, ClassLoader> imports )
|
||||
{
|
||||
ClassRealm coreRealm = getCoreRealm();
|
||||
|
||||
// maven-*
|
||||
imports.put( "org.apache.maven.*", coreRealm );
|
||||
imports.put( "org.apache.maven.artifact", coreRealm );
|
||||
imports.put( "org.apache.maven.classrealm", coreRealm );
|
||||
imports.put( "org.apache.maven.cli", coreRealm );
|
||||
imports.put( "org.apache.maven.configuration", coreRealm );
|
||||
imports.put( "org.apache.maven.exception", coreRealm );
|
||||
imports.put( "org.apache.maven.execution", coreRealm );
|
||||
imports.put( "org.apache.maven.execution.scope", coreRealm );
|
||||
imports.put( "org.apache.maven.lifecycle", coreRealm );
|
||||
imports.put( "org.apache.maven.model", coreRealm );
|
||||
imports.put( "org.apache.maven.monitor", coreRealm );
|
||||
imports.put( "org.apache.maven.plugin", coreRealm );
|
||||
imports.put( "org.apache.maven.profiles", coreRealm );
|
||||
imports.put( "org.apache.maven.project", coreRealm );
|
||||
imports.put( "org.apache.maven.reporting", coreRealm );
|
||||
imports.put( "org.apache.maven.repository", coreRealm );
|
||||
imports.put( "org.apache.maven.rtinfo", coreRealm );
|
||||
imports.put( "org.apache.maven.settings", coreRealm );
|
||||
imports.put( "org.apache.maven.toolchain", coreRealm );
|
||||
imports.put( "org.apache.maven.usability", coreRealm );
|
||||
|
||||
// wagon-api
|
||||
imports.put( "org.apache.maven.wagon.*", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.authentication", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.authorization", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.events", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.observers", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.proxy", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.repository", coreRealm );
|
||||
imports.put( "org.apache.maven.wagon.resource", coreRealm );
|
||||
|
||||
// aether-api, aether-spi, aether-impl
|
||||
imports.put( "org.eclipse.aether.*", coreRealm );
|
||||
imports.put( "org.eclipse.aether.artifact", coreRealm );
|
||||
imports.put( "org.eclipse.aether.collection", coreRealm );
|
||||
imports.put( "org.eclipse.aether.deployment", coreRealm );
|
||||
imports.put( "org.eclipse.aether.graph", coreRealm );
|
||||
imports.put( "org.eclipse.aether.impl", coreRealm );
|
||||
imports.put( "org.eclipse.aether.internal.impl", coreRealm );
|
||||
imports.put( "org.eclipse.aether.installation", coreRealm );
|
||||
imports.put( "org.eclipse.aether.metadata", coreRealm );
|
||||
imports.put( "org.eclipse.aether.repository", coreRealm );
|
||||
imports.put( "org.eclipse.aether.resolution", coreRealm );
|
||||
imports.put( "org.eclipse.aether.spi", coreRealm );
|
||||
imports.put( "org.eclipse.aether.transfer", coreRealm );
|
||||
imports.put( "org.eclipse.aether.version", coreRealm );
|
||||
|
||||
// plexus-classworlds
|
||||
imports.put( "org.codehaus.plexus.classworlds", coreRealm );
|
||||
|
||||
// classworlds (for legacy code)
|
||||
imports.put( "org.codehaus.classworlds", coreRealm );
|
||||
|
||||
// plexus-utils (for DOM-type fields in maven-model)
|
||||
imports.put( "org.codehaus.plexus.util.xml.Xpp3Dom", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParser", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParserException", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.util.xml.pull.XmlSerializer", coreRealm );
|
||||
|
||||
// plexus-container, plexus-component-annotations
|
||||
imports.put( "org.codehaus.plexus.*", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.component", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.configuration", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.container", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.context", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.lifecycle", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.logging", coreRealm );
|
||||
imports.put( "org.codehaus.plexus.personality", coreRealm );
|
||||
|
||||
// javax.inject (JSR-330)
|
||||
imports.put( "javax.inject.*", coreRealm );
|
||||
// javax.enterprise.inject (JSR-299)
|
||||
imports.put( "javax.enterprise.util.*", coreRealm );
|
||||
imports.put( "javax.enterprise.inject.*", coreRealm );
|
||||
|
||||
// com.google
|
||||
//
|
||||
// We may potentially want to export these, but right now I'm not sure that anything Guice specific needs
|
||||
// to be made available to plugin authors. If we find people are getting fancy and want to take advantage
|
||||
// of Guice specifics we can expose that later. Really some testing needs to be done to see full hiding
|
||||
// of Guice has any impact on what we may categorize as a standard JSR-330 based Tesla/Maven plugin.
|
||||
//
|
||||
// imports.put( "com.google.inject.*", coreRealm );
|
||||
// imports.put( "com.google.inject.binder.*", coreRealm );
|
||||
// imports.put( "com.google.inject.matcher.*", coreRealm );
|
||||
// imports.put( "com.google.inject.name.*", coreRealm );
|
||||
// imports.put( "com.google.inject.spi.*", coreRealm );
|
||||
// imports.put( "com.google.inject.util.*", coreRealm );
|
||||
|
||||
// SLF4J
|
||||
imports.put( "org.slf4j.*", coreRealm );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new class realm with the specified parent and imports.
|
||||
*
|
||||
|
@ -312,7 +233,7 @@ public class DefaultClassRealmManager
|
|||
|
||||
public ClassRealm getCoreRealm()
|
||||
{
|
||||
return container.getContainerRealm();
|
||||
return containerRealm;
|
||||
}
|
||||
|
||||
public ClassRealm createProjectRealm( Model model, List<Artifact> artifacts )
|
||||
|
@ -387,24 +308,10 @@ public class DefaultClassRealmManager
|
|||
return gid + ':' + aid + ':' + type + ( StringUtils.isNotEmpty( cls ) ? ':' + cls : "" ) + ':' + ver;
|
||||
}
|
||||
|
||||
private List<ClassRealmManagerDelegate> getDelegates()
|
||||
{
|
||||
try
|
||||
{
|
||||
return container.lookupList( ClassRealmManagerDelegate.class );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
logger.error( "Failed to lookup class realm delegates: " + e.getMessage(), e );
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private void callDelegates( ClassRealm classRealm, RealmType type, ClassLoader parent, List<String> parentImports,
|
||||
Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents )
|
||||
{
|
||||
List<ClassRealmManagerDelegate> delegates = getDelegates();
|
||||
List<ClassRealmManagerDelegate> delegates = new ArrayList<ClassRealmManagerDelegate>( this.delegates );
|
||||
|
||||
if ( !delegates.isEmpty() )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
package org.apache.maven.extension.internal;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.project.ExtensionDescriptor;
|
||||
import org.apache.maven.project.ExtensionDescriptorBuilder;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @since 3.2.6
|
||||
*/
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultCoreExports
|
||||
{
|
||||
private static final ExtensionDescriptorBuilder builder = new ExtensionDescriptorBuilder();
|
||||
|
||||
private final Set<String> artifacts;
|
||||
|
||||
private final Set<String> packages;
|
||||
|
||||
@Inject
|
||||
public DefaultCoreExports( PlexusContainer container )
|
||||
throws IOException
|
||||
{
|
||||
Set<String> artifacts = new LinkedHashSet<String>();
|
||||
Set<String> packages = new LinkedHashSet<String>();
|
||||
|
||||
Enumeration<URL> extensions =
|
||||
container.getContainerRealm().getResources( builder.getExtensionDescriptorLocation() );
|
||||
while ( extensions.hasMoreElements() )
|
||||
{
|
||||
InputStream is = extensions.nextElement().openStream();
|
||||
try
|
||||
{
|
||||
ExtensionDescriptor descriptor = builder.build( is );
|
||||
|
||||
artifacts.addAll( descriptor.getExportedArtifacts() );
|
||||
packages.addAll( descriptor.getExportedPackages() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( is );
|
||||
}
|
||||
}
|
||||
this.artifacts = ImmutableSet.copyOf( artifacts );
|
||||
this.packages = ImmutableSet.copyOf( packages );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns artifacts exported by Maven core and core extensions. Artifacts are identified by their
|
||||
* groupId:artifactId.
|
||||
*/
|
||||
public Set<String> getExportedArtifacts()
|
||||
{
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns packages exported by Maven core and core extensions.
|
||||
*/
|
||||
public Set<String> getExportedPackages()
|
||||
{
|
||||
return packages;
|
||||
}
|
||||
}
|
|
@ -43,7 +43,10 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|||
public class ExtensionDescriptorBuilder
|
||||
{
|
||||
|
||||
private String getExtensionDescriptorLocation()
|
||||
/**
|
||||
* @since 3.2.6
|
||||
*/
|
||||
public String getExtensionDescriptorLocation()
|
||||
{
|
||||
return "META-INF/maven/extension.xml";
|
||||
}
|
||||
|
@ -71,7 +74,14 @@ public class ExtensionDescriptorBuilder
|
|||
{
|
||||
InputStream is = pluginJar.getInputStream( pluginDescriptorEntry );
|
||||
|
||||
extensionDescriptor = build( is );
|
||||
try
|
||||
{
|
||||
extensionDescriptor = build( is );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -100,7 +110,10 @@ public class ExtensionDescriptorBuilder
|
|||
return extensionDescriptor;
|
||||
}
|
||||
|
||||
ExtensionDescriptor build( InputStream is )
|
||||
/**
|
||||
* @since 3.2.6
|
||||
*/
|
||||
public ExtensionDescriptor build( InputStream is )
|
||||
throws IOException
|
||||
{
|
||||
ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor();
|
||||
|
@ -114,10 +127,6 @@ public class ExtensionDescriptorBuilder
|
|||
{
|
||||
throw (IOException) new IOException( e.getMessage() ).initCause( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( is );
|
||||
}
|
||||
|
||||
if ( !"extension".equals( dom.getName() ) )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<extension>
|
||||
<exportedPackages>
|
||||
<!-- maven-* -->
|
||||
<exportedPackage>org.apache.maven.*</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.artifact</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.classrealm</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.cli</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.configuration</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.exception</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.execution</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.execution.scope</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.lifecycle</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.model</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.monitor</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.plugin</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.profiles</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.project</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.reporting</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.repository</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.rtinfo</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.settings</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.toolchain</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.usability</exportedPackage>
|
||||
|
||||
|
||||
<!-- wagon-api -->
|
||||
<exportedPackage>org.apache.maven.wagon.*</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.authentication</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.authorization</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.events</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.observers</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.proxy</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.repository</exportedPackage>
|
||||
<exportedPackage>org.apache.maven.wagon.resource</exportedPackage>
|
||||
|
||||
<!-- aether-api, aether-spi, aether-impl -->
|
||||
<exportedPackage>org.eclipse.aether.*</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.artifact</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.collection</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.deployment</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.graph</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.impl</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.internal.impl</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.installation</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.metadata</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.repository</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.resolution</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.spi</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.transfer</exportedPackage>
|
||||
<exportedPackage>org.eclipse.aether.version</exportedPackage>
|
||||
|
||||
<!-- plexus-classworlds -->
|
||||
<exportedPackage>org.codehaus.plexus.classworlds</exportedPackage>
|
||||
|
||||
<!-- classworlds (for legacy code) -->
|
||||
<exportedPackage>org.codehaus.classworlds</exportedPackage>
|
||||
|
||||
<!-- plexus-utils (for DOM-type fields in maven-model) -->
|
||||
<exportedPackage>org.codehaus.plexus.util.xml.Xpp3Dom</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.util.xml.pull.XmlPullParser</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.util.xml.pull.XmlPullParserException</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.util.xml.pull.XmlSerializer</exportedPackage>
|
||||
|
||||
<!-- plexus-container, plexus-component-annotations -->
|
||||
<exportedPackage>org.codehaus.plexus.*</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.component</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.configuration</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.container</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.context</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.lifecycle</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.logging</exportedPackage>
|
||||
<exportedPackage>org.codehaus.plexus.personality</exportedPackage>
|
||||
|
||||
<!-- javax.inject (JSR-330) -->
|
||||
<exportedPackage>javax.inject.*</exportedPackage>
|
||||
<!-- javax.enterprise.inject (JSR-299) -->
|
||||
<exportedPackage>javax.enterprise.util.*</exportedPackage>
|
||||
<exportedPackage>javax.enterprise.inject.*</exportedPackage>
|
||||
|
||||
|
||||
<!--
|
||||
| We may potentially want to export these, but right now I'm not sure that anything Guice specific needs
|
||||
| to be made available to plugin authors. If we find people are getting fancy and want to take advantage of
|
||||
| Guice specifics we can expose that later. Really some testing needs to be done to see full hiding
|
||||
| of Guice has any impact on what we may categorize as a standard JSR-330 based Tesla/Maven plugin.
|
||||
|
||||
<exportedPackage>com.google.inject.*</exportedPackage>
|
||||
<exportedPackage>com.google.inject.binder.*</exportedPackage>
|
||||
<exportedPackage>com.google.inject.matcher.*</exportedPackage>
|
||||
<exportedPackage>com.google.inject.name.*</exportedPackage>
|
||||
<exportedPackage>com.google.inject.spi.*</exportedPackage>
|
||||
<exportedPackage>com.google.inject.util.*</exportedPackage>
|
||||
-->
|
||||
|
||||
<!-- SLF4J -->
|
||||
<exportedPackage>org.slf4j.*</exportedPackage>
|
||||
|
||||
</exportedPackages>
|
||||
|
||||
<exportedArtifacts>
|
||||
<exportedArtifact>classworlds:classworlds</exportedArtifact>
|
||||
<exportedArtifact>org.codehaus.plexus:plexus-classworlds</exportedArtifact>
|
||||
<exportedArtifact>org.codehaus.plexus:plexus-component-api</exportedArtifact>
|
||||
<exportedArtifact>org.codehaus.plexus:plexus-container-default</exportedArtifact>
|
||||
<exportedArtifact>plexus:plexus-container-default</exportedArtifact>
|
||||
<exportedArtifact>org.sonatype.spice:spice-inject-plexus</exportedArtifact>
|
||||
<exportedArtifact>org.sonatype.sisu:sisu-inject-plexus</exportedArtifact>
|
||||
<exportedArtifact>org.eclipse.sisu:org.eclipse.sisu.plexus</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-artifact</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-aether-provider</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-artifact-manager</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-compat</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-core</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-error-diagnostics</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-lifecycle</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-model</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-model-builder</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-monitor</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-plugin-api</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-plugin-descriptor</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-plugin-parameter-documenter</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-plugin-registry</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-profile</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-project</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-repository-metadata</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-settings</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-settings-builder</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven:maven-toolchain</exportedArtifact>
|
||||
<exportedArtifact>org.apache.maven.wagon:wagon-provider-api</exportedArtifact>
|
||||
<exportedArtifact>org.eclipse.aether:aether-api</exportedArtifact>
|
||||
<exportedArtifact>org.eclipse.aether:aether-spi</exportedArtifact>
|
||||
<exportedArtifact>org.eclipse.aether:aether-impl</exportedArtifact>
|
||||
|
||||
<!--
|
||||
| We must also filter out the old or NoClassDefFoundErrors will surface
|
||||
-->
|
||||
<exportedArtifact>org.sonatype.aether:aether-api</exportedArtifact>
|
||||
<exportedArtifact>org.sonatype.aether:aether-spi</exportedArtifact>
|
||||
<exportedArtifact>org.sonatype.aether:aether-impl</exportedArtifact>
|
||||
|
||||
<!--
|
||||
| NOTE: Don't exclude the wagons or any of their dependencies (apart from the wagon API). This would otherwise
|
||||
| provoke linkage errors for wagons contributed by build extensions. We also don't need to exclude the wagons
|
||||
| from plugins. Plugins that use wagons directly and declare the corresponding dependency will simply use a
|
||||
| wagon from their plugin realm.
|
||||
-->
|
||||
</exportedArtifacts>
|
||||
</extension>
|
Loading…
Reference in New Issue