Put back in repository helper due to problems of building with clean repo.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@700813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2008-10-01 15:33:08 +00:00
parent 7f70506c55
commit d7ae13be90
4 changed files with 113 additions and 36 deletions

View File

@ -93,6 +93,8 @@ public class DefaultMavenProjectBuilder
private ProjectBuilder projectBuilder; private ProjectBuilder projectBuilder;
private RepositoryHelper repositoryHelper;
private Logger logger; private Logger logger;
//DO NOT USE, it is here only for backward compatibility reasons. The existing //DO NOT USE, it is here only for backward compatibility reasons. The existing
@ -129,7 +131,7 @@ public class DefaultMavenProjectBuilder
throws ProjectBuildingException throws ProjectBuildingException
{ {
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
config.getLocalRepository(), buildArtifactRepositories( config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config ); getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
project.setFile( projectDescriptor ); project.setFile( projectDescriptor );
@ -180,29 +182,21 @@ public class DefaultMavenProjectBuilder
if ( project != null ) if ( project != null )
{ {
return project; return project;
} }
File originalArtifactFile = artifact.getFile();
File f; File f = (artifact.getFile() != null) ? artifact.getFile() :
if ( !"pom".equals( artifact.getType() ) ) new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );;
{ repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
Artifact a = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope() );
f = new File( localRepository.getBasedir(), localRepository.pathOf( a ) );
} else
{
f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
}
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( remoteArtifactRepositories ); List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( remoteArtifactRepositories );
artifactRepositories.addAll( buildArtifactRepositories( getSuperProject( config, f, false ).getModel() ) ); artifactRepositories.addAll( repositoryHelper.buildArtifactRepositories( getSuperProject( config, artifact.getFile(), false ).getModel() ) );
project = readModelFromLocalPath( "unknown", f, new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config ); project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
project = buildInternal( project.getModel(), config, f, project.getParentFile(), false ); project = buildInternal( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
artifact.setFile( originalArtifactFile );
artifact.setFile( f );
project.setVersion( artifact.getVersion() ); project.setVersion( artifact.getVersion() );
hm.put( artifact.getId(), project ); hm.put( artifact.getId(), project );
@ -619,20 +613,4 @@ public class DefaultMavenProjectBuilder
setBuildOutputDirectoryOnParent( parent ); setBuildOutputDirectoryOnParent( parent );
} }
} }
public List buildArtifactRepositories( Model model )
throws ProjectBuildingException
{
try
{
return mavenTools.buildArtifactRepositories( model.getRepositories() );
}
catch ( InvalidRepositoryException e )
{
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
throw new ProjectBuildingException( projectId, e.getMessage(), e );
}
}
} }

View File

@ -88,7 +88,10 @@ under the License.
<role>org.apache.maven.project.MavenProjectBuilder</role> <role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>default</role-hint> <role-hint>default</role-hint>
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation> <implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements> <requirements>
<requirement>
<role>org.apache.maven.project.RepositoryHelper</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role> <role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement> </requirement>
@ -116,6 +119,27 @@ under the License.
</requirement> </requirement>
</requirements> </requirements>
</component> </component>
<!--Eliminate this component after Mercury Integration-->
<component>
<role>org.apache.maven.project.RepositoryHelper</role>
<implementation>org.apache.maven.project.DefaultRepositoryHelper</implementation>
<requirements>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<!-- <!--
| |
| |

View File

@ -19,6 +19,41 @@ under the License.
<plexus> <plexus>
<components> <components>
<!--Eliminate this component after Mercury Integration-->
<component>
<role>org.apache.maven.project.RepositoryHelper</role>
<implementation>org.apache.maven.project.DefaultRepositoryHelper</implementation>
<requirements>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<!-- 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> <component>
<role>org.apache.maven.profiles.injection.ProfileInjector</role> <role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint> <role-hint>test</role-hint>
@ -79,6 +114,9 @@ under the License.
<role-hint>test</role-hint> <role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation> <implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements> <requirements>
<requirement>
<role>org.apache.maven.project.RepositoryHelper</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role> <role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement> </requirement>

View File

@ -18,7 +18,41 @@ under the License.
--> -->
<plexus> <plexus>
<components> <components><!--Eliminate this component after Mercury Integration-->
<component>
<role>org.apache.maven.project.RepositoryHelper</role>
<implementation>org.apache.maven.project.DefaultRepositoryHelper</implementation>
<requirements>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
</requirements>
</component>
<!-- 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> <component>
<role>org.apache.maven.profiles.injection.ProfileInjector</role> <role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint> <role-hint>test</role-hint>
@ -77,6 +111,9 @@ under the License.
<role-hint>test</role-hint> <role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation> <implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements> <requirements>
<requirement>
<role>org.apache.maven.project.RepositoryHelper</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role> <role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement> </requirement>