From d7ae13be90c881e224083a3e0a94e423125ec1d9 Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Wed, 1 Oct 2008 15:33:08 +0000 Subject: [PATCH] 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 --- .../project/DefaultMavenProjectBuilder.java | 46 +++++-------------- .../resources/META-INF/plexus/components.xml | 26 ++++++++++- .../maven/project/ProjectClasspathTest.xml | 38 +++++++++++++++ .../canonical/CanonicalProjectBuilderTest.xml | 39 +++++++++++++++- 4 files changed, 113 insertions(+), 36 deletions(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index c48a33a5e0..2f4f7671b1 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -93,6 +93,8 @@ public class DefaultMavenProjectBuilder private ProjectBuilder projectBuilder; + private RepositoryHelper repositoryHelper; + private Logger logger; //DO NOT USE, it is here only for backward compatibility reasons. The existing @@ -129,7 +131,7 @@ public class DefaultMavenProjectBuilder throws ProjectBuildingException { MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( - config.getLocalRepository(), buildArtifactRepositories( + config.getLocalRepository(), repositoryHelper.buildArtifactRepositories( getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config ); project.setFile( projectDescriptor ); @@ -180,29 +182,21 @@ public class DefaultMavenProjectBuilder if ( project != null ) { return project; - } - File originalArtifactFile = artifact.getFile(); - File f; - if ( !"pom".equals( artifact.getType() ) ) - { - 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 ) ); - } + } + + File f = (artifact.getFile() != null) ? artifact.getFile() : + new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );; + repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ); List artifactRepositories = new ArrayList( 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 = buildInternal( project.getModel(), config, f, project.getParentFile(), false ); - - artifact.setFile( originalArtifactFile ); + project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config ); + project = buildInternal( project.getModel(), config, artifact.getFile(), project.getParentFile(), false ); + artifact.setFile( f ); project.setVersion( artifact.getVersion() ); hm.put( artifact.getId(), project ); @@ -619,20 +613,4 @@ public class DefaultMavenProjectBuilder 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 ); - } - } - } \ No newline at end of file diff --git a/maven-project/src/main/resources/META-INF/plexus/components.xml b/maven-project/src/main/resources/META-INF/plexus/components.xml index 744cb3b044..3ffc41e6c6 100644 --- a/maven-project/src/main/resources/META-INF/plexus/components.xml +++ b/maven-project/src/main/resources/META-INF/plexus/components.xml @@ -88,7 +88,10 @@ under the License. org.apache.maven.project.MavenProjectBuilder default org.apache.maven.project.DefaultMavenProjectBuilder - + + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.builder.ProjectBuilder @@ -116,6 +119,27 @@ under the License. + + + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.DefaultRepositoryHelper + + + org.apache.maven.profiles.build.ProfileAdvisor + + + org.apache.maven.artifact.factory.ArtifactFactory + + + org.apache.maven.artifact.resolver.ArtifactResolver + default + + + org.apache.maven.MavenTools + + + + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.DefaultRepositoryHelper + + + org.apache.maven.profiles.build.ProfileAdvisor + default + + + org.apache.maven.artifact.factory.ArtifactFactory + + + org.apache.maven.artifact.resolver.ArtifactResolver + default + + + org.apache.maven.MavenTools + + + + org.apache.maven.profiles.injection.ProfileInjector test @@ -79,6 +114,9 @@ under the License. test org.apache.maven.project.TestProjectBuilder + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.builder.ProjectBuilder diff --git a/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml b/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml index f0c3af1072..cad1bd921b 100644 --- a/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml +++ b/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml @@ -18,7 +18,41 @@ under the License. --> - + + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.DefaultRepositoryHelper + + + org.apache.maven.profiles.build.ProfileAdvisor + + + org.apache.maven.artifact.factory.ArtifactFactory + + + org.apache.maven.artifact.resolver.ArtifactResolver + default + + + org.apache.maven.MavenTools + + + + + org.apache.maven.profiles.injection.ProfileInjector test @@ -77,6 +111,9 @@ under the License. test org.apache.maven.project.TestProjectBuilder + + org.apache.maven.project.RepositoryHelper + org.apache.maven.project.builder.ProjectBuilder