Resolving: MNG-1022...Adding TestProfileInjector to avoid injecting profiles for tests, and still guard against NPEs when profiles exist.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291751 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-09-26 21:27:00 +00:00
parent 945af48359
commit b1c59f6d19
4 changed files with 120 additions and 6 deletions

View File

@ -23,6 +23,7 @@ import org.apache.maven.project.AbstractMavenProjectTestCase;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.util.Iterator;
import java.util.List;
/**
@ -53,11 +54,21 @@ public class CanonicalProjectBuilderTest
// Plugin0 [plexus]
Plugin plugin = (Plugin) plugins.get( 0 );
String key = "org.apache.maven.plugins:maven-plexus-plugin";
assertEquals( "org.apache.maven.plugins", plugin.getGroupId() );
Plugin plugin = null;
for ( Iterator it = plugins.iterator(); it.hasNext(); )
{
Plugin check = (Plugin) it.next();
assertEquals( "maven-plexus-plugin", plugin.getArtifactId() );
if ( key.equals( check.getKey() ) )
{
plugin = check;
break;
}
}
assertNotNull( plugin );
assertEquals( "1.0", plugin.getVersion() );

View File

@ -0,0 +1,15 @@
package org.apache.maven.project.injection;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
public class TestProfileInjector
implements ProfileInjector
{
public void inject( Profile profile, Model model )
{
// do nothing.
}
}

View File

@ -14,6 +14,11 @@
</requirements>
</component>
-->
<component>
<role>org.apache.maven.project.injection.ProfileInjector</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.injection.TestProfileInjector</implementation>
</component>
<component>
<role>org.apache.maven.project.TestArtifactResolver</role>
<implementation>org.apache.maven.project.TestArtifactResolver</implementation>
@ -43,6 +48,10 @@
<requirement>
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
</requirement>
<requirement>
<role>org.apache.maven.project.injection.ProfileInjector</role>
<role-hint>test</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
</requirement>

View File

@ -0,0 +1,79 @@
<plexus>
<components>
<!-- Due to PLX-108, have to work around it...
<component>
<role>org.apache.maven.artifact.ArtifactResolver</role>
<implementation>org.apache.maven.project.TestArtifactResolvertion>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
</requirements>
</component>
-->
<component>
<role>org.apache.maven.project.injection.ProfileInjector</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.injection.TestProfileInjector</implementation>
</component>
<component>
<role>org.apache.maven.project.TestArtifactResolver</role>
<implementation>org.apache.maven.project.TestArtifactResolver</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
</requirement>
<requirement>
<role>org.apache.maven.project.injection.ProfileInjector</role>
<role-hint>test</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
</requirement>
<requirement>
<role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
</requirement>
<requirement>
<role>org.apache.maven.project.validation.ModelValidator</role>
</requirement>
<requirement>
<role>org.apache.maven.project.path.PathTranslator</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
</requirements>
</component>
</components>
</plexus>