mirror of https://github.com/apache/maven.git
o remove MissingRepositoryElementException from the core and just leave in compat
o make the project builder's read from path use a file instead of a input stream git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@726942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
805b15fea2
commit
ff09f5beb7
|
@ -57,7 +57,7 @@ public class InvalidRepositoryException
|
|||
this.repositoryId = null;
|
||||
}
|
||||
|
||||
protected InvalidRepositoryException( String message,
|
||||
public InvalidRepositoryException( String message,
|
||||
String repositoryId )
|
||||
{
|
||||
super( message );
|
||||
|
|
|
@ -122,13 +122,12 @@ public class DefaultMavenTools
|
|||
|
||||
if ( id == null || id.trim().length() < 1 )
|
||||
{
|
||||
throw new MissingRepositoryElementException( "Repository ID must not be empty (URL is: " + url + ")." );
|
||||
throw new InvalidRepositoryException( "Repository ID must not be empty (URL is: " + url + ").", url );
|
||||
}
|
||||
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
{
|
||||
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").",
|
||||
id );
|
||||
throw new InvalidRepositoryException( "Repository URL must not be empty (ID is: " + id + ").", id );
|
||||
}
|
||||
|
||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
|
||||
|
@ -169,7 +168,7 @@ public class DefaultMavenTools
|
|||
}
|
||||
|
||||
// From MavenExecutionRequestPopulator
|
||||
|
||||
|
||||
public ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||
throws IOException
|
||||
{
|
||||
|
@ -371,4 +370,30 @@ public class DefaultMavenTools
|
|||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws IOException
|
||||
{
|
||||
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
artifact.setFile( artifactFile );
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,10 +37,6 @@ import java.util.List;
|
|||
*/
|
||||
public interface MavenTools
|
||||
{
|
||||
// ----------------------------------------------------------------------------
|
||||
// Methods taken from ProjectUtils
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
List<ArtifactRepository> buildArtifactRepositories( List<Repository> repositories )
|
||||
throws InvalidRepositoryException;
|
||||
|
||||
|
@ -66,7 +62,11 @@ public interface MavenTools
|
|||
void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
List buildArtifactRepositories( Model model )
|
||||
List<ArtifactRepository> buildArtifactRepositories( Model model )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
// PomArtifactResolver
|
||||
|
||||
void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.maven.project;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
@ -551,7 +550,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
try
|
||||
{
|
||||
mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ),
|
||||
mavenProject = projectBuilder.buildFromLocalPath( projectDescriptor,
|
||||
Arrays.asList(
|
||||
getSuperProject( config, projectDescriptor, true ).getModel() ),
|
||||
null,
|
||||
|
|
|
@ -19,6 +19,21 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.maven.MavenTools;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
|
@ -61,21 +76,6 @@ import org.apache.maven.project.artifact.MavenMetadataSource;
|
|||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* The concern of the project is provide runtime values based on the model. <p/>
|
||||
* The values in the model remain untouched but during the process of building a
|
||||
|
@ -195,14 +195,13 @@ public class MavenProject
|
|||
setModel( model );
|
||||
}
|
||||
|
||||
public MavenProject( Model model, ArtifactFactory artifactFactory, MavenTools mavenTools, MavenProjectBuilder mavenProjectBuilder,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
public MavenProject( Model model, ArtifactFactory artifactFactory, MavenTools mavenTools, MavenProjectBuilder mavenProjectBuilder, ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
setModel( model );
|
||||
this.artifactFactory = artifactFactory;
|
||||
this.mavenProjectBuilder = mavenProjectBuilder;
|
||||
this.projectBuilderConfiguration = projectBuilderConfiguration;
|
||||
this.artifactFactory = artifactFactory;
|
||||
originalModel = model;
|
||||
DistributionManagement dm = model.getDistributionManagement();
|
||||
|
||||
|
@ -354,16 +353,6 @@ public class MavenProject
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
try {
|
||||
parent = mavenProjectBuilder.buildStandaloneSuperProject(projectBuilderConfiguration);
|
||||
} catch (ProjectBuildingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.InvalidRepositoryException;
|
||||
|
||||
public class MissingRepositoryElementException
|
||||
extends InvalidRepositoryException
|
||||
{
|
||||
|
||||
public MissingRepositoryElementException( String message, String repositoryId )
|
||||
{
|
||||
super( message, repositoryId );
|
||||
}
|
||||
|
||||
public MissingRepositoryElementException( String message )
|
||||
{
|
||||
super( message, "-unknown-" );
|
||||
}
|
||||
|
||||
}
|
|
@ -50,7 +50,7 @@ public interface ProjectBuilder
|
|||
* @return a maven project for the specified input stream
|
||||
* @throws IOException if there is a problem in the construction of the maven project
|
||||
*/
|
||||
MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels, Collection<ImportModel> importModels,
|
||||
MavenProject buildFromLocalPath( File pom, List<Model> inheritedModels, Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver, File baseDirectory,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
|
|
|
@ -83,7 +83,7 @@ public final class DefaultProjectBuilder
|
|||
/**
|
||||
* @see ProjectBuilder#buildFromLocalPath(java.io.InputStream, java.util.List, java.util.Collection, java.util.Collection, org.apache.maven.project.builder.PomArtifactResolver, java.io.File, org.apache.maven.project.ProjectBuilderConfiguration)
|
||||
*/
|
||||
public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels,
|
||||
public MavenProject buildFromLocalPath( File pom, List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver, File projectDirectory,
|
||||
|
|
Loading…
Reference in New Issue