diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 1b688ab75e..11f7c57880 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -45,6 +45,14 @@ org.codehaus.plexus plexus-component-metadata + 1.0-beta-3-SNAPSHOT + + + org.codehaus.plexus + plexus-container-default + 1.0-beta-3-SNAPSHOT + + diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 68b43775cc..a3c549c9d8 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -129,6 +129,18 @@ public class MavenSession return container.lookup( role, roleHint ); } + public T lookup( Class type ) + throws ComponentLookupException + { + return container.lookup( type ); + } + + public T lookup( Class type, String roleHint ) + throws ComponentLookupException + { + return container.lookup( type, roleHint ); + } + public List lookupList( String role ) throws ComponentLookupException { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 4f3737e666..ba3113fe22 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -367,7 +367,7 @@ public class DefaultLifecycleExecutor * from the core Maven realm, and contains the specific build-extension * components referenced in that project, the lookup realms must be managed for * each project that's used to fire off a mojo execution. This helps ensure - * that unsafe {@link PlexusContainer#lookup(String)} and related calls will + * that unsafe {@link PlexusContainer#lookup} and related calls will * have access to these build-extension components. *
* This method simply restores the original Maven-core lookup realm when a @@ -386,7 +386,7 @@ public class DefaultLifecycleExecutor * from the core Maven realm, and contains the specific build-extension * components referenced in that project, the lookup realms must be managed for * each project that's used to fire off a mojo execution. This helps ensure - * that unsafe {@link PlexusContainer#lookup(String)} and related calls will + * that unsafe {@link PlexusContainer#lookup} and related calls will * have access to these build-extension components. *
* This method is meant to find a project-specific realm, if one exists, for diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 3a99a03645..bd67a1a4d8 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -815,12 +815,12 @@ public class DefaultPluginManager getLogger().debug( "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm " + pluginRealm.getId() + " - descRealmId=" - + mojoDescriptor.getRealmId() ); + + mojoDescriptor.getRealm() ); Mojo mojo; try { - mojo = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint(), pluginRealm ); + mojo = container.lookup( Mojo.class, mojoDescriptor.getRoleHint() ); } catch ( ComponentLookupException e ) { @@ -1344,11 +1344,11 @@ public class DefaultPluginManager // so that this meethod could entirely be handled by a plexus lookup? if ( StringUtils.isNotEmpty( configuratorId ) ) { - configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, configuratorId, realm ); + configurator = container.lookup( ComponentConfigurator.class, configuratorId ); } else { - configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic", realm ); + configurator = container.lookup( ComponentConfigurator.class, "basic" ); } ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); diff --git a/maven-core/src/main/java/org/apache/maven/realm/DefaultMavenRealmManager.java b/maven-core/src/main/java/org/apache/maven/realm/DefaultMavenRealmManager.java index d6d12c4b98..a2c812ed6b 100644 --- a/maven-core/src/main/java/org/apache/maven/realm/DefaultMavenRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/realm/DefaultMavenRealmManager.java @@ -186,7 +186,7 @@ public class DefaultMavenRealmManager // that allows most of the extension to stay hidden, and the // specific local extension components are still accessible // from the project-level realm. - comp.setRealmId( realm.getId() ); + comp.setRealm( realm ); // Finally, add the extension component's descriptor (with projectRealm // set as the lookup realm) to the container. diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenRealmManagerTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenRealmManagerTest.java index 282a9b6020..7a335a9052 100644 --- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenRealmManagerTest.java +++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenRealmManagerTest.java @@ -21,7 +21,7 @@ public class DefaultMavenRealmManagerTest { super.setUp(); - factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + factory = lookup( ArtifactFactory.class ); } public void test_ReuseSingleExtensionRealmFromMultipleProjectRealms_UsingTwoManagerInstances() @@ -57,9 +57,7 @@ public class DefaultMavenRealmManagerTest mgr1.importExtensionsIntoProjectRealm( "org.group", pAid1, "2", ext1 ); - String targetClass = ArtifactFactory.ROLE; - - Object result1 = getContainer().lookup( targetClass, "test", mgr1.getProjectRealm( "org.group", pAid1, "2" ) ); + ArtifactFactory result1 = getContainer().lookup( ArtifactFactory.class, "test" ); assertNotNull( result1 ); @@ -72,7 +70,7 @@ public class DefaultMavenRealmManagerTest // ext2 doesn't have a file associated with it, but it SHOULD succeed anyway. mgr2.importExtensionsIntoProjectRealm( "org.group", pAid2, "2", ext2 ); - Object result2 = getContainer().lookup( targetClass, "test", mgr2.getProjectRealm( "org.group", pAid2, "2" ) ); + ArtifactFactory result2 = getContainer().lookup( ArtifactFactory.class, "test" ); assertNotNull( result2 ); diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/LegacyLifecycleMappingParserTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/LegacyLifecycleMappingParserTest.java index ee51b1aa00..b5d451f59b 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/LegacyLifecycleMappingParserTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/LegacyLifecycleMappingParserTest.java @@ -27,11 +27,11 @@ public class LegacyLifecycleMappingParserTest { super.setUp(); - parser = (LegacyLifecycleMappingParser) lookup( LegacyLifecycleMappingParser.ROLE, "default" ); + parser = lookup( LegacyLifecycleMappingParser.class, "default" ); - testComponent = (LegacyLifecycleParsingTestComponent) lookup( LegacyLifecycleParsingTestComponent.ROLE, "default" ); - testMapping = (LifecycleMapping) lookup( LifecycleMapping.ROLE, "test-mapping" ); - testMapping2 = (LifecycleMapping) lookup( LifecycleMapping.ROLE, "test-mapping2" ); + testComponent = lookup( LegacyLifecycleParsingTestComponent.class, "default" ); + testMapping = lookup( LifecycleMapping.class, "test-mapping" ); + testMapping2 = lookup( LifecycleMapping.class, "test-mapping2" ); } public void tearDown() diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManagerTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManagerTest.java index c0c20bedb8..2c0533516b 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManagerTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManagerTest.java @@ -44,7 +44,7 @@ public class DefaultLifecycleBindingManagerTest { super.setUp(); - mgr = (LifecycleBindingManager) lookup( LifecycleBindingManager.ROLE, "default" ); + mgr = lookup( LifecycleBindingManager.class, "default" ); } public void testLookup() diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java index 78dd82698f..3dcb17d3d7 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java @@ -17,7 +17,7 @@ public class DefaultMojoBindingFactoryTest { super.setUp(); - factory = (MojoBindingFactory) lookup( MojoBindingFactory.ROLE, "default" ); + factory = lookup( MojoBindingFactory.class, "default" ); } public void testPrefixGoalSpec_PrefixReferenceNotAllowed() diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultBuildPlannerTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultBuildPlannerTest.java index 890e085255..491b56971b 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultBuildPlannerTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultBuildPlannerTest.java @@ -44,8 +44,8 @@ public class DefaultBuildPlannerTest throws Exception { super.setUp(); - buildPlanner = (DefaultBuildPlanner) lookup( BuildPlanner.class.getName(), "default" ); - pluginLoader = (TestPluginLoader) lookup( PluginLoader.class.getName(), "default" ); + buildPlanner = (DefaultBuildPlanner) lookup( BuildPlanner.class ); + pluginLoader = (TestPluginLoader) lookup( PluginLoader.class ); } public void test_constructBuildPlan_ForkedPhaseFromMojoBoundInThatPhase() diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index ba03da1f18..adbacf8f64 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -39,6 +39,7 @@ import org.apache.maven.path.PathTranslator; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.logging.Logger; @@ -73,8 +74,8 @@ public class PluginParameterExpressionEvaluatorTest throws Exception { super.setUp(); - factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - pathTranslator = (PathTranslator) lookup( PathTranslator.ROLE ); + factory = lookup( ArtifactFactory.class ); + pathTranslator = lookup( PathTranslator.class ); } public void testPluginDescriptorExpressionReference() @@ -108,7 +109,7 @@ public class PluginParameterExpressionEvaluatorTest null, Artifact.SCOPE_COMPILE ); - List deps = new ArrayList(); + List deps = new ArrayList(); deps.add( depArtifact ); exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); @@ -139,7 +140,7 @@ public class PluginParameterExpressionEvaluatorTest null, Artifact.SCOPE_COMPILE ); - List deps = new ArrayList(); + List deps = new ArrayList(); deps.add( depArtifact ); exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); @@ -419,12 +420,11 @@ public class PluginParameterExpressionEvaluatorTest Properties executionProperties ) throws Exception { - ArtifactRepositoryLayout repoLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); + ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepository repo = new DefaultArtifactRepository( "local", "target/repo", repoLayout ); - PlexusContainer container = getContainer(); + MutablePlexusContainer container = (MutablePlexusContainer) getContainer(); MavenSession session = createSession( container, repo ); MojoDescriptor mojo = new MojoDescriptor(); @@ -442,7 +442,7 @@ public class PluginParameterExpressionEvaluatorTest String version ) throws Exception { - ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + ArtifactFactory artifactFactory = lookup( ArtifactFactory.class ); // TODO: used to be SCOPE_COMPILE, check return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java b/maven-embedder/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java index beb7329ec1..9f0c8cd30a 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java @@ -105,7 +105,7 @@ public abstract class AbstractConsoleDownloadMonitor public void transferError( TransferEvent transferEvent ) { // TODO: can't use getLogger() because this isn't currently instantiated as a component - transferEvent.getException().printStackTrace(); + // transferEvent.getException().printStackTrace(); } /** diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index d54867c517..9e33bbbdde 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -324,7 +324,7 @@ public class MavenEmbedder ArtifactNotFoundException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { - PluginManager pluginManager = (PluginManager) container.lookup( PluginManager.ROLE ); + PluginManager pluginManager = container.lookup( PluginManager.class ); // MavenSession session = new MavenSession( container, request, null, null, projectSessions ); MavenSession session = new MavenSession( container, request, null, null ); @@ -611,7 +611,7 @@ public class MavenEmbedder ContainerConfiguration cc = new DefaultContainerConfiguration() .addComponentDiscoverer( new MavenPluginDiscoverer() ) .addComponentDiscoveryListener( new MavenPluginCollector() ) - .setClassWorld( classWorld ).setParentContainer( configuration.getParentContainer() ).setName( "embedder" ); + .setClassWorld( classWorld ).setName( "embedder" ); container = new DefaultPlexusContainer( cc ); } @@ -646,23 +646,23 @@ public class MavenEmbedder modelWriter = new MavenXpp3Writer(); - maven = (Maven) container.lookup( Maven.ROLE ); + maven = container.lookup( Maven.class ); - mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE ); + mavenProjectBuilder = container.lookup( MavenProjectBuilder.class ); // ---------------------------------------------------------------------- // Artifact related components // ---------------------------------------------------------------------- - artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE ); + artifactFactory = container.lookup( ArtifactFactory.class ); - artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE, "default" ); + artifactResolver = container.lookup( ArtifactResolver.class ); - populator = (MavenExecutionRequestPopulator) container.lookup( MavenExecutionRequestPopulator.ROLE ); + populator = container.lookup( MavenExecutionRequestPopulator.class ); - buildPlanner = (BuildPlanner) container.lookup( BuildPlanner.class ); + buildPlanner = container.lookup( BuildPlanner.class ); - artifactHandlerManager = (ArtifactHandlerManager) container.lookup( ArtifactHandlerManager.ROLE ); + artifactHandlerManager = container.lookup( ArtifactHandlerManager.class ); // This is temporary as we can probably cache a single request and use it for default values and // simply cascade values in from requests used for individual executions. diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java index e1ae07deeb..2e9b0e0687 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java @@ -50,6 +50,7 @@ import org.apache.maven.settings.SettingsUtils; import org.apache.maven.wagon.repository.RepositoryPermissions; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; @@ -89,7 +90,7 @@ public class DefaultMavenExecutionRequestPopulator private ArtifactRepositoryLayout defaultArtifactRepositoryLayout; - private PlexusContainer container; + private MutablePlexusContainer container; private WagonManager wagonManager; @@ -574,7 +575,7 @@ public class DefaultMavenExecutionRequestPopulator private void resolveParameters( Settings settings ) throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException { - WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE ); + WagonManager wagonManager = container.lookup( WagonManager.class ); try { @@ -715,6 +716,6 @@ public class DefaultMavenExecutionRequestPopulator public void contextualize( Context context ) throws ContextException { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + container = (MutablePlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } } diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java index a9b5e2e904..6da865ca2b 100644 --- a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java @@ -86,12 +86,12 @@ public class MavenEmbedderProjectWithExtensionReadingTest .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() ) ); } - protected Map getPluginExtensionComponents( Plugin plugin ) + protected Map getPluginExtensionComponents( Plugin plugin ) throws PluginManagerException { try { - return getPlexusContainer().lookupMap( ArtifactHandler.ROLE ); + return getPlexusContainer().lookupMap( ArtifactHandler.class ); } catch ( ComponentLookupException e ) { diff --git a/maven-lifecycle/src/test/java/org/apache/maven/lifecycle/ClassLoaderXmlBindingLoaderTest.java b/maven-lifecycle/src/test/java/org/apache/maven/lifecycle/ClassLoaderXmlBindingLoaderTest.java index 3d346bea80..994a561f7b 100644 --- a/maven-lifecycle/src/test/java/org/apache/maven/lifecycle/ClassLoaderXmlBindingLoaderTest.java +++ b/maven-lifecycle/src/test/java/org/apache/maven/lifecycle/ClassLoaderXmlBindingLoaderTest.java @@ -37,7 +37,7 @@ public class ClassLoaderXmlBindingLoaderTest public void testComponentAccess_ParseSingleCleanBinding() throws Exception { - LifecycleBindingLoader loader = (LifecycleBindingLoader) lookup( LifecycleBindingLoader.ROLE, "single-clean-mapping" ); + LifecycleBindingLoader loader = lookup( LifecycleBindingLoader.class, "single-clean-mapping" ); LifecycleBindings bindings = loader.getBindings(); diff --git a/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java b/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java index c780cec799..61d41d5586 100644 --- a/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java +++ b/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java @@ -28,6 +28,7 @@ import org.apache.maven.profiles.activation.ProfileActivationContext; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.profiles.activation.ProfileActivator; import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; @@ -41,7 +42,7 @@ import java.util.Map.Entry; public class DefaultProfileManager implements ProfileManager { - private PlexusContainer container; + private MutablePlexusContainer container; private Map profilesById = new LinkedHashMap(); @@ -53,7 +54,7 @@ public class DefaultProfileManager */ public DefaultProfileManager( PlexusContainer container, ProfileActivationContext profileActivationContext ) { - this.container = container; + this.container = (MutablePlexusContainer) container; if ( profileActivationContext == null ) { this.profileActivationContext = createDefaultActivationContext(); @@ -70,7 +71,7 @@ public class DefaultProfileManager */ public DefaultProfileManager( PlexusContainer container ) { - this.container = container; + this.container = (MutablePlexusContainer) container; profileActivationContext = createDefaultActivationContext(); } @@ -259,16 +260,14 @@ public class DefaultProfileManager private boolean isActive( Profile profile, ProfileActivationContext context ) throws ProfileActivationException { - List activators = null; + List activators = null; try { - activators = container.lookupList( ProfileActivator.ROLE ); + activators = container.lookupList( ProfileActivator.class ); - for ( Iterator activatorIterator = activators.iterator(); activatorIterator.hasNext(); ) + for ( ProfileActivator activator : activators ) { - ProfileActivator activator = (ProfileActivator) activatorIterator.next(); - if ( activator.canDetermineActivation( profile, context ) ) { if ( activator.isActive( profile, context ) ) diff --git a/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java b/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java index fae9ede650..918e25304c 100644 --- a/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java +++ b/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java @@ -84,7 +84,7 @@ public class CustomActivator try { - activator = (ProfileActivator) container.lookup( ProfileActivator.ROLE, type ); + activator = container.lookup( ProfileActivator.class, type ); } catch ( ComponentLookupException e ) { diff --git a/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index 00a8411c60..62d2373b4e 100644 --- a/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -51,12 +51,12 @@ public abstract class AbstractMavenProjectTestCase if ( getContainer().hasComponent( MavenProjectBuilder.ROLE, "test" ) ) { - projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE, "test" ); + projectBuilder = lookup( MavenProjectBuilder.class, "test" ); } else { // default over to the main project builder... - projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); + projectBuilder = lookup( MavenProjectBuilder.class ); } } @@ -95,8 +95,7 @@ public abstract class AbstractMavenProjectTestCase protected ArtifactRepository getLocalRepository() throws Exception { - ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, - "legacy" ); + ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), diff --git a/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java index 0206c74f47..0507bd9b40 100644 --- a/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java @@ -50,7 +50,7 @@ public class DefaultMavenProjectBuilderTest { super.setUp(); - projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); + projectBuilder = lookup( MavenProjectBuilder.class ); localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() ); localRepoDir.mkdirs(); @@ -115,8 +115,7 @@ public class DefaultMavenProjectBuilderTest protected ArtifactRepository getLocalRepository() throws Exception { - ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, - "legacy" ); + ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + localRepoDir.getAbsolutePath(), repoLayout ); diff --git a/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectHelperTest.java b/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectHelperTest.java index da750cf830..26f6ff8499 100644 --- a/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectHelperTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectHelperTest.java @@ -20,8 +20,8 @@ public class DefaultMavenProjectHelperTest { super.setUp(); - mavenProjectHelper = (MavenProjectHelper) lookup( MavenProjectHelper.ROLE ); - artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + mavenProjectHelper = lookup( MavenProjectHelper.class ); + artifactFactory = lookup( ArtifactFactory.class ); } public void testShouldThrowExceptionWhenDuplicateAttachmentIsAdded() diff --git a/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index 5256d06c8b..fea0c3f644 100644 --- a/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -38,9 +38,9 @@ public class ProjectClasspathTest File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" ); // assertEquals( TestArtifactResolver.class, getContainer().lookup( ArtifactResolver.ROLE ).getClass() ); - TestProjectBuilder builder = (TestProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE, "test" ); + TestProjectBuilder builder = (TestProjectBuilder) getContainer().lookup( MavenProjectBuilder.class, "test" ); - TestArtifactResolver testArtifactResolver = (TestArtifactResolver) getContainer().lookup( TestArtifactResolver.class.getName() ); + TestArtifactResolver testArtifactResolver = getContainer().lookup( TestArtifactResolver.class ); builder.setArtifactResolver( testArtifactResolver ); builder.setArtifactMetadataSource( testArtifactResolver.source() ); diff --git a/maven-project/src/test/java/org/apache/maven/project/SuperPomProjectBuilderTest.java b/maven-project/src/test/java/org/apache/maven/project/SuperPomProjectBuilderTest.java index d50aea25da..a3b18ec56a 100644 --- a/maven-project/src/test/java/org/apache/maven/project/SuperPomProjectBuilderTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/SuperPomProjectBuilderTest.java @@ -38,7 +38,7 @@ public class SuperPomProjectBuilderTest { super.setUp(); - projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); + projectBuilder = lookup( MavenProjectBuilder.class ); } public void testStandaloneSuperPomContainsInjectedExternalProfileRepositories() diff --git a/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java b/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java index b1e66d5a39..1d64c03744 100644 --- a/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java @@ -66,7 +66,7 @@ public class MavenMetadataSourceTest deps.add( dep1 ); deps.add( dep2 ); - ArtifactFactory factory = ( ArtifactFactory ) lookup( ArtifactFactory.ROLE ); + ArtifactFactory factory = lookup( ArtifactFactory.class ); ArtifactFilter dependencyFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); @@ -105,7 +105,7 @@ public class MavenMetadataSourceTest MavenProject project = new MavenProject( model ); - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + ArtifactFactory factory = lookup( ArtifactFactory.class ); project.setArtifacts( project.createArtifacts( factory, null, null ) ); @@ -158,7 +158,7 @@ public class MavenMetadataSourceTest injector.injectDefaults( model ); - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + ArtifactFactory factory = lookup( ArtifactFactory.class ); project.setArtifacts( project.createArtifacts( factory, null, null ) ); diff --git a/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java b/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java index 18857bea16..b83aa7703d 100644 --- a/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java @@ -223,7 +223,7 @@ public class DefaultModelValidatorTest MavenXpp3Reader reader = new MavenXpp3Reader(); - validator = (ModelValidator) lookup( ModelValidator.ROLE ); + validator = lookup( ModelValidator.class ); model = reader.read( input ); diff --git a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java index 5546aa3fac..6dcd99ca26 100644 --- a/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java +++ b/maven-shared-model/src/main/java/org/apache/maven/shared/model/ModelMarshaller.java @@ -38,6 +38,7 @@ import java.util.Set; * Provides methods for marshalling and unmarshalling XML that does not contain attributes. */ public final class ModelMarshaller + implements ModelPropertiesGenerator { /** @@ -47,6 +48,16 @@ public final class ModelMarshaller { } + public List generateModelProperties( InputStream inputStream, String baseUri, Set collections ) + throws IOException + { + return marshallXmlToModelProperties( inputStream, baseUri, collections ); + } + + public void registerModelPropertyListener( String uri ) + { + } + /** * Returns list of model properties transformed from the specified input stream. * diff --git a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java index 81acab0efc..35a3577ab6 100644 --- a/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java +++ b/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java @@ -77,7 +77,7 @@ public class DefaultToolchainManager extends AbstractLogEnabled try { PersistedToolchains pers = readToolchainSettings (); - Map factories = container.lookupMap( ToolchainFactory.ROLE ); + Map factories = container.lookupMap( ToolchainFactory.class ); List toRet = new ArrayList( ); if ( pers != null ) { @@ -88,7 +88,7 @@ public class DefaultToolchainManager extends AbstractLogEnabled while ( it.hasNext() ) { ToolchainModel toolchainModel = (ToolchainModel) it.next(); - ToolchainFactory fact = (ToolchainFactory) factories.get( toolchainModel.getType() ); + ToolchainFactory fact = factories.get( toolchainModel.getType() ); if ( fact != null ) { toRet.add( fact.createToolchain( toolchainModel ) ); @@ -100,11 +100,9 @@ public class DefaultToolchainManager extends AbstractLogEnabled } } } - Iterator it = factories.values().iterator(); - while ( it.hasNext() ) + for ( ToolchainFactory toolchainFactory : factories.values() ) { - ToolchainFactory fact = (ToolchainFactory) it.next(); - ToolchainPrivate tool = fact.createDefaultToolchain(); + ToolchainPrivate tool = toolchainFactory.createDefaultToolchain(); if ( tool != null ) { toRet.add( tool ); @@ -136,7 +134,7 @@ public class DefaultToolchainManager extends AbstractLogEnabled { try { - ToolchainFactory fact = (ToolchainFactory) container.lookup(ToolchainFactory.ROLE, type); + ToolchainFactory fact = container.lookup(ToolchainFactory.class, type); return fact.createToolchain( model ); } catch ( ComponentLookupException ex ) diff --git a/pom.xml b/pom.xml index 9ad315ae80..8b458e85b2 100644 --- a/pom.xml +++ b/pom.xml @@ -156,7 +156,7 @@ under the License. org.codehaus.plexus plexus-component-metadata - 1.0-beta-1.2 + 1.0-beta-3-SNAPSHOT @@ -280,12 +280,12 @@ under the License. 3.0-alpha-2-SNAPSHOT 1.5.3 - 1.2-alpha-13 + 1.2 1.0 1.0-alpha-9 1.2_Java1.3 3.8.1 - 1.0-beta-1.2 + 1.0-beta-2-SNAPSHOT 1.0-alpha-6 1.1 1.5.5