mirror of https://github.com/apache/maven.git
o we don't need to pass in the project builder configuration when we just want the domain model
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@726972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0638d3d8a0
commit
ee9e67af9b
|
@ -53,7 +53,7 @@ import org.apache.maven.profiles.activation.ProfileActivationException;
|
|||
import org.apache.maven.profiles.build.ProfileAdvisor;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.builder.Interpolator;
|
||||
import org.apache.maven.project.builder.PomArtifactResolver;
|
||||
import org.apache.maven.project.builder.DefaultPomArtifactResolver;
|
||||
import org.apache.maven.project.builder.PomInterpolatorTag;
|
||||
import org.apache.maven.project.builder.ProjectBuilder;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
|
@ -138,7 +138,7 @@ public class DefaultMavenProjectBuilder
|
|||
public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( config.getLocalRepository(), mavenTools
|
||||
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new DefaultPomArtifactResolver( config.getLocalRepository(), mavenTools
|
||||
.buildArtifactRepositories( getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
|
||||
|
||||
project.setFile( projectDescriptor );
|
||||
|
@ -199,7 +199,7 @@ public class DefaultMavenProjectBuilder
|
|||
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( remoteArtifactRepositories );
|
||||
artifactRepositories.addAll( mavenTools.buildArtifactRepositories( getSuperProject( config, artifact.getFile(), false ).getModel() ) );
|
||||
|
||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), new DefaultPomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
||||
project = buildWithProfiles( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
|
||||
artifact.setFile( f );
|
||||
project.setVersion( artifact.getVersion() );
|
||||
|
@ -517,7 +517,7 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
}
|
||||
|
||||
private MavenProject readModelFromLocalPath( String projectId, File projectDescriptor, PomArtifactResolver resolver,
|
||||
private MavenProject readModelFromLocalPath( String projectId, File projectDescriptor, DefaultPomArtifactResolver resolver,
|
||||
ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
|
|
@ -161,11 +161,13 @@ public class MavenProject
|
|||
|
||||
private Stack previousExecutionProjects = new Stack();
|
||||
|
||||
//!! Components that need to be taken out of here
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
|
||||
private ProjectBuilderConfiguration projectBuilderConfiguration;
|
||||
//
|
||||
|
||||
private File parentFile;
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package org.apache.maven.project.builder;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides methods for resolving of artifacts.
|
||||
*/
|
||||
public class DefaultPomArtifactResolver
|
||||
implements PomArtifactResolver
|
||||
{
|
||||
/**
|
||||
* Local repository used in resolving artifacts
|
||||
*/
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
/**
|
||||
* Remote repositories used in resolving artifacts
|
||||
*/
|
||||
private List<ArtifactRepository> remoteRepositories;
|
||||
|
||||
/**
|
||||
* Artifact resolver used to resolve artifacts
|
||||
*/
|
||||
private ArtifactResolver resolver;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param localRepository local repository used in resolving artifacts
|
||||
* @param remoteRepositories remote repositories used in resolving artifacts
|
||||
* @param resolver artifact resolver used to resolve artifacts
|
||||
*/
|
||||
public DefaultPomArtifactResolver( ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactResolver resolver )
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the specified artifact
|
||||
*
|
||||
* @param artifact the artifact to resolve
|
||||
* @throws IOException if there is a problem resolving the artifact
|
||||
*/
|
||||
public void resolve( Artifact artifact )
|
||||
throws IOException
|
||||
{
|
||||
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
artifact.setFile( artifactFile );
|
||||
|
||||
try
|
||||
{
|
||||
resolver.resolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,93 +1,11 @@
|
|||
package org.apache.maven.project.builder;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides methods for resolving of artifacts.
|
||||
*/
|
||||
public class PomArtifactResolver
|
||||
public interface PomArtifactResolver
|
||||
{
|
||||
|
||||
/**
|
||||
* Local repository used in resolving artifacts
|
||||
*/
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
/**
|
||||
* Remote repositories used in resolving artifacts
|
||||
*/
|
||||
private List<ArtifactRepository> remoteRepositories;
|
||||
|
||||
/**
|
||||
* Artifact resolver used to resolve artifacts
|
||||
*/
|
||||
private ArtifactResolver resolver;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param localRepository local repository used in resolving artifacts
|
||||
* @param remoteRepositories remote repositories used in resolving artifacts
|
||||
* @param resolver artifact resolver used to resolve artifacts
|
||||
*/
|
||||
public PomArtifactResolver( ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
|
||||
ArtifactResolver resolver )
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the specified artifact
|
||||
*
|
||||
* @param artifact the artifact to resolve
|
||||
* @throws IOException if there is a problem resolving the artifact
|
||||
*/
|
||||
public void resolve( Artifact artifact )
|
||||
throws IOException
|
||||
{
|
||||
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
artifact.setFile( artifactFile );
|
||||
|
||||
try
|
||||
{
|
||||
resolver.resolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ public interface ProjectBuilder
|
|||
List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
DefaultPomArtifactResolver resolver )
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -58,7 +57,7 @@ public interface ProjectBuilder
|
|||
List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver,
|
||||
DefaultPomArtifactResolver resolver,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.builder.ArtifactModelContainerFactory;
|
||||
import org.apache.maven.project.builder.IdModelContainerFactory;
|
||||
import org.apache.maven.project.builder.PomArtifactResolver;
|
||||
import org.apache.maven.project.builder.DefaultPomArtifactResolver;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModel;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModelFactory;
|
||||
import org.apache.maven.project.builder.PomClassicTransformer;
|
||||
|
@ -81,8 +81,7 @@ public final class DefaultProjectBuilder
|
|||
public PomClassicDomainModel buildModel( File pom, List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
DefaultPomArtifactResolver resolver )
|
||||
throws IOException
|
||||
{
|
||||
if ( pom == null )
|
||||
|
@ -168,7 +167,7 @@ public final class DefaultProjectBuilder
|
|||
public MavenProject buildFromLocalPath( File pom, List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver,
|
||||
DefaultPomArtifactResolver resolver,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws IOException
|
||||
{
|
||||
|
@ -176,8 +175,7 @@ public final class DefaultProjectBuilder
|
|||
inheritedModels,
|
||||
importModels,
|
||||
interpolatorProperties,
|
||||
resolver,
|
||||
projectBuilderConfiguration );
|
||||
resolver );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -223,7 +221,7 @@ public final class DefaultProjectBuilder
|
|||
}
|
||||
|
||||
private List<DomainModel> getDomainModelParentsFromRepository( PomClassicDomainModel domainModel,
|
||||
PomArtifactResolver artifactResolver )
|
||||
DefaultPomArtifactResolver artifactResolver )
|
||||
throws IOException
|
||||
{
|
||||
List<DomainModel> domainModels = new ArrayList<DomainModel>();
|
||||
|
@ -263,7 +261,7 @@ public final class DefaultProjectBuilder
|
|||
* @throws IOException
|
||||
*/
|
||||
private List<DomainModel> getDomainModelParentsFromLocalPath( PomClassicDomainModel domainModel,
|
||||
PomArtifactResolver artifactResolver,
|
||||
DefaultPomArtifactResolver artifactResolver,
|
||||
File projectDirectory )
|
||||
throws IOException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue