mirror of https://github.com/apache/maven.git
clean up project exception handling
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d7ef6be79
commit
10a8e05df6
|
@ -536,7 +536,7 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new TransferFailedException( "Invalid checksum file", e );
|
throw new ChecksumFailedException( "Invalid checksum file", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error constructing an artifact repository.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InvalidRepositoryException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
public InvalidRepositoryException( String message, Throwable throwable )
|
||||||
|
{
|
||||||
|
super( message, throwable );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,18 @@
|
||||||
package org.apache.maven.usability.plugin;
|
package org.apache.maven.usability.plugin;/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
public class ExpressionDocumentationException
|
public class ExpressionDocumentationException
|
||||||
extends Exception
|
extends Exception
|
||||||
|
|
|
@ -5,11 +5,9 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.util.DirectoryScanner;
|
import org.codehaus.plexus.util.DirectoryScanner;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -28,8 +26,8 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
||||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||||
throws ExtractionException, InvalidPluginDescriptorException
|
throws ExtractionException, InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
Map scriptFilesKeyedByBasedir = gatherScriptSourcesByBasedir( project.getScriptSourceRoots(),
|
Map scriptFilesKeyedByBasedir =
|
||||||
getScriptFileExtension() );
|
gatherScriptSourcesByBasedir( project.getScriptSourceRoots(), getScriptFileExtension() );
|
||||||
|
|
||||||
List mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, pluginDescriptor );
|
List mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, pluginDescriptor );
|
||||||
|
|
||||||
|
@ -74,32 +72,14 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
||||||
outputFile.getParentFile().mkdirs();
|
outputFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream in = null;
|
|
||||||
FileOutputStream out = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in = new FileInputStream( scriptFile );
|
FileUtils.copyFile( scriptFile, outputFile );
|
||||||
out = new FileOutputStream( outputFile );
|
|
||||||
|
|
||||||
byte[] buffer = new byte[16];
|
|
||||||
int read = -1;
|
|
||||||
|
|
||||||
while ( ( read = in.read( buffer ) ) > -1 )
|
|
||||||
{
|
|
||||||
out.write( buffer, 0, read );
|
|
||||||
}
|
|
||||||
|
|
||||||
out.flush();
|
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new ExtractionException( "Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
|
throw new ExtractionException(
|
||||||
}
|
"Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( in );
|
|
||||||
IOUtil.close( out );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
package org.apache.maven.profiles.activation;
|
package org.apache.maven.profiles.activation;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
public class ProfileActivationException
|
public class ProfileActivationException
|
||||||
extends Exception
|
extends Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.project;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.ArtifactStatus;
|
import org.apache.maven.artifact.ArtifactStatus;
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
|
@ -184,7 +185,9 @@ public class DefaultMavenProjectBuilder
|
||||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||||
Artifact projectArtifact = project.getArtifact();
|
Artifact projectArtifact = project.getArtifact();
|
||||||
|
|
||||||
Map managedVersions = createManagedVersionMap( project.getId(), project.getDependencyManagement() );
|
String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||||
|
|
||||||
|
Map managedVersions = createManagedVersionMap( projectId, project.getDependencyManagement() );
|
||||||
|
|
||||||
ensureMetadataSourceIsInitialized();
|
ensureMetadataSourceIsInitialized();
|
||||||
|
|
||||||
|
@ -194,7 +197,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( project.getId(), "Error in dependency version", e );
|
throw new ProjectBuildingException( projectId, "Error in dependency version", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( transferListener != null )
|
if ( transferListener != null )
|
||||||
|
@ -224,7 +227,8 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.", e );
|
throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.",
|
||||||
|
e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,8 +281,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactRepository localRepository,
|
private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactRepository localRepository,
|
||||||
ProfileManager profileManager,
|
ProfileManager profileManager, boolean checkDistributionManagementStatus )
|
||||||
boolean checkDistributionManagementStatus )
|
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
Model model = readModel( "unknown", projectDescriptor );
|
Model model = readModel( "unknown", projectDescriptor );
|
||||||
|
@ -294,9 +297,12 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( checkDistributionManagementStatus )
|
if ( checkDistributionManagementStatus )
|
||||||
{
|
{
|
||||||
if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
|
if ( project.getDistributionManagement() != null &&
|
||||||
|
project.getDistributionManagement().getStatus() != null )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( project.getId(),
|
String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||||
|
|
||||||
|
throw new ProjectBuildingException( projectId,
|
||||||
"Invalid project file: distribution status must not be specified for a project outside of the repository" );
|
"Invalid project file: distribution status must not be specified for a project outside of the repository" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,9 +562,16 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
Repository mavenRepo = (Repository) repoIterator.next();
|
Repository mavenRepo = (Repository) repoIterator.next();
|
||||||
|
|
||||||
ArtifactRepository artifactRepo = ProjectUtils.buildArtifactRepository( mavenRepo,
|
ArtifactRepository artifactRepo = null;
|
||||||
artifactRepositoryFactory,
|
try
|
||||||
container );
|
{
|
||||||
|
artifactRepo =
|
||||||
|
ProjectUtils.buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
|
||||||
|
}
|
||||||
|
catch ( InvalidRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
aggregatedRemoteWagonRepositories.add( artifactRepo );
|
aggregatedRemoteWagonRepositories.add( artifactRepo );
|
||||||
}
|
}
|
||||||
|
@ -566,8 +579,16 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
Model originalModel = ModelUtils.cloneModel( model );
|
Model originalModel = ModelUtils.cloneModel( model );
|
||||||
|
|
||||||
MavenProject project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
|
MavenProject project = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
|
||||||
aggregatedRemoteWagonRepositories, externalProfileManager );
|
aggregatedRemoteWagonRepositories, externalProfileManager );
|
||||||
|
}
|
||||||
|
catch ( InvalidRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
project.setOriginalModel( originalModel );
|
project.setOriginalModel( originalModel );
|
||||||
|
|
||||||
|
@ -603,8 +624,11 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( ModelInterpolationException e )
|
catch ( ModelInterpolationException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( project.getId(), "Error building project from \'" + pomLocation + "\': " + model.getId(),
|
throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
|
||||||
e );
|
}
|
||||||
|
catch ( InvalidRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
|
||||||
}
|
}
|
||||||
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
|
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
|
||||||
project );
|
project );
|
||||||
|
@ -633,7 +657,17 @@ public class DefaultMavenProjectBuilder
|
||||||
private List buildArtifactRepositories( Model model )
|
private List buildArtifactRepositories( Model model )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container );
|
try
|
||||||
|
{
|
||||||
|
return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory,
|
||||||
|
container );
|
||||||
|
}
|
||||||
|
catch ( InvalidRepositoryException e )
|
||||||
|
{
|
||||||
|
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||||
|
|
||||||
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -645,7 +679,7 @@ public class DefaultMavenProjectBuilder
|
||||||
*/
|
*/
|
||||||
private MavenProject processProjectLogic( String pomLocation, MavenProject project, List remoteRepositories,
|
private MavenProject processProjectLogic( String pomLocation, MavenProject project, List remoteRepositories,
|
||||||
ProfileManager profileMgr, File projectDir )
|
ProfileManager profileMgr, File projectDir )
|
||||||
throws ProjectBuildingException, ModelInterpolationException
|
throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
|
||||||
{
|
{
|
||||||
Model model = project.getModel();
|
Model model = project.getModel();
|
||||||
String key = createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() );
|
String key = createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() );
|
||||||
|
@ -732,18 +766,21 @@ public class DefaultMavenProjectBuilder
|
||||||
// Must validate before artifact construction to make sure dependencies are good
|
// Must validate before artifact construction to make sure dependencies are good
|
||||||
ModelValidationResult validationResult = validator.validate( model );
|
ModelValidationResult validationResult = validator.validate( model );
|
||||||
|
|
||||||
|
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||||
|
|
||||||
if ( validationResult.getMessageCount() > 0 )
|
if ( validationResult.getMessageCount() > 0 )
|
||||||
{
|
{
|
||||||
throw new InvalidProjectModelException( project.getId(), pomLocation, "Failed to validate POM", validationResult );
|
throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM",
|
||||||
|
validationResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
project.setRemoteArtifactRepositories(
|
project.setRemoteArtifactRepositories(
|
||||||
ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
|
ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
|
||||||
|
|
||||||
// TODO: these aren't taking active project artifacts into consideration in the reactor
|
// TODO: these aren't taking active project artifacts into consideration in the reactor
|
||||||
project.setPluginArtifacts( createPluginArtifacts( project.getId(), project.getBuildPlugins() ) );
|
project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) );
|
||||||
project.setReportArtifacts( createReportArtifacts( project.getId(), project.getReportPlugins() ) );
|
project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) );
|
||||||
project.setExtensionArtifacts( createExtensionArtifacts( project.getId(), project.getBuildExtensions() ) );
|
project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) );
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
@ -754,7 +791,7 @@ public class DefaultMavenProjectBuilder
|
||||||
private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
|
private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
|
||||||
File projectDir, List parentSearchRepositories,
|
File projectDir, List parentSearchRepositories,
|
||||||
Set aggregatedRemoteWagonRepositories, ProfileManager externalProfileManager )
|
Set aggregatedRemoteWagonRepositories, ProfileManager externalProfileManager )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException, InvalidRepositoryException
|
||||||
{
|
{
|
||||||
if ( !model.getRepositories().isEmpty() )
|
if ( !model.getRepositories().isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -793,7 +830,8 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||||
|
|
||||||
throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles.", e );
|
throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles: " +
|
||||||
|
e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenProject project = new MavenProject( model );
|
MavenProject project = new MavenProject( model );
|
||||||
|
@ -824,8 +862,8 @@ public class DefaultMavenProjectBuilder
|
||||||
// the only way this will have a value is if we find the parent on disk...
|
// the only way this will have a value is if we find the parent on disk...
|
||||||
File parentDescriptor = null;
|
File parentDescriptor = null;
|
||||||
|
|
||||||
MavenProject p = getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(),
|
MavenProject p =
|
||||||
parentModel.getVersion() );
|
getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() );
|
||||||
if ( p != null )
|
if ( p != null )
|
||||||
{
|
{
|
||||||
model = p.getModel();
|
model = p.getModel();
|
||||||
|
@ -949,7 +987,7 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||||
|
|
||||||
throw new ProjectBuildingException( projectId, "Failed to calculate active build profiles.", e );
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
|
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
|
||||||
|
@ -1019,17 +1057,13 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( FileNotFoundException e )
|
catch ( FileNotFoundException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( projectId, "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
|
throw new ProjectBuildingException( projectId,
|
||||||
|
"Could not find the model file '" + file.getAbsolutePath() + "'.", e );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( projectId, "Failed to build model from file '" + file.getAbsolutePath() +
|
throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
|
||||||
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
}
|
|
||||||
catch ( XmlPullParserException e )
|
|
||||||
{
|
|
||||||
throw new ProjectBuildingException( projectId, "Failed to parse model from file '" + file.getAbsolutePath() +
|
|
||||||
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1038,7 +1072,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model readModel( String projectId, String pomLocation, Reader reader )
|
private Model readModel( String projectId, String pomLocation, Reader reader )
|
||||||
throws IOException, XmlPullParserException, InvalidProjectModelException
|
throws IOException, InvalidProjectModelException
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
|
||||||
|
@ -1053,8 +1087,15 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
StringReader sReader = new StringReader( modelSource );
|
StringReader sReader = new StringReader( modelSource );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
return modelReader.read( sReader );
|
return modelReader.read( sReader );
|
||||||
}
|
}
|
||||||
|
catch ( XmlPullParserException e )
|
||||||
|
{
|
||||||
|
throw new InvalidProjectModelException( projectId, pomLocation, "Parse error reading POM", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Model readModel( String projectId, URL url )
|
private Model readModel( String projectId, URL url )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
|
@ -1070,11 +1111,6 @@ public class DefaultMavenProjectBuilder
|
||||||
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
|
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
|
||||||
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
}
|
}
|
||||||
catch ( XmlPullParserException e )
|
|
||||||
{
|
|
||||||
throw new ProjectBuildingException( projectId, "Failed to parse model from URL \'" + url.toExternalForm() +
|
|
||||||
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtil.close( reader );
|
IOUtil.close( reader );
|
||||||
|
@ -1233,6 +1269,8 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
profileManager.addProfiles( superModel.getProfiles() );
|
profileManager.addProfiles( superModel.getProfiles() );
|
||||||
|
|
||||||
|
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||||
|
|
||||||
activeProfiles = injectActiveProfiles( profileManager, superModel );
|
activeProfiles = injectActiveProfiles( profileManager, superModel );
|
||||||
|
|
||||||
MavenProject project = new MavenProject( superModel );
|
MavenProject project = new MavenProject( superModel );
|
||||||
|
@ -1243,9 +1281,6 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO: remove - confirm this was a correct decision
|
|
||||||
// project.setFile( new File( ".", "pom.xml" ) );
|
|
||||||
|
|
||||||
List remoteRepositories = buildArtifactRepositories( superModel );
|
List remoteRepositories = buildArtifactRepositories( superModel );
|
||||||
|
|
||||||
project = processProjectLogic( "<Super-POM>", project, remoteRepositories, null, null );
|
project = processProjectLogic( "<Super-POM>", project, remoteRepositories, null, null );
|
||||||
|
@ -1256,9 +1291,11 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( ModelInterpolationException e )
|
catch ( ModelInterpolationException e )
|
||||||
{
|
{
|
||||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
|
}
|
||||||
throw new ProjectBuildingException( projectId, "Error building super-project", e );
|
catch ( InvalidRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,38 @@
|
||||||
package org.apache.maven.project;
|
package org.apache.maven.project;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.project.validation.ModelValidationResult;
|
import org.apache.maven.project.validation.ModelValidationResult;
|
||||||
|
|
||||||
public class InvalidProjectModelException
|
public class InvalidProjectModelException
|
||||||
extends ProjectBuildingException
|
extends ProjectBuildingException
|
||||||
{
|
{
|
||||||
|
|
||||||
private final String pomLocation;
|
private final String pomLocation;
|
||||||
|
|
||||||
private ModelValidationResult validationResult;
|
private ModelValidationResult validationResult;
|
||||||
|
|
||||||
public InvalidProjectModelException( String projectId, String pomLocation, String message, ModelValidationResult validationResult )
|
public InvalidProjectModelException( String projectId, String pomLocation, String message, Throwable cause )
|
||||||
|
{
|
||||||
|
super( projectId, message, cause );
|
||||||
|
this.pomLocation = pomLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidProjectModelException( String projectId, String pomLocation, String message,
|
||||||
|
ModelValidationResult validationResult )
|
||||||
{
|
{
|
||||||
super( projectId, message );
|
super( projectId, message );
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,15 @@ package org.apache.maven.project;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
|
import org.apache.maven.model.DeploymentRepository;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.model.RepositoryBase;
|
import org.apache.maven.model.RepositoryBase;
|
||||||
import org.apache.maven.model.RepositoryPolicy;
|
import org.apache.maven.model.RepositoryPolicy;
|
||||||
import org.apache.maven.model.DeploymentRepository;
|
|
||||||
import org.codehaus.plexus.PlexusContainer;
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public final class ProjectUtils
|
||||||
public static List buildArtifactRepositories( List repositories,
|
public static List buildArtifactRepositories( List repositories,
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||||
PlexusContainer container )
|
PlexusContainer container )
|
||||||
throws ProjectBuildingException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
|
|
||||||
List repos = new ArrayList();
|
List repos = new ArrayList();
|
||||||
|
@ -49,8 +50,8 @@ public final class ProjectUtils
|
||||||
{
|
{
|
||||||
Repository mavenRepo = (Repository) i.next();
|
Repository mavenRepo = (Repository) i.next();
|
||||||
|
|
||||||
ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo, artifactRepositoryFactory,
|
ArtifactRepository artifactRepo =
|
||||||
container );
|
buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
|
||||||
|
|
||||||
if ( !repos.contains( artifactRepo ) )
|
if ( !repos.contains( artifactRepo ) )
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,7 @@ public final class ProjectUtils
|
||||||
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
|
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||||
PlexusContainer container )
|
PlexusContainer container )
|
||||||
throws ProjectBuildingException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
if ( repo != null )
|
if ( repo != null )
|
||||||
{
|
{
|
||||||
|
@ -73,7 +74,8 @@ public final class ProjectUtils
|
||||||
// TODO: make this a map inside the factory instead, so no lookup needed
|
// TODO: make this a map inside the factory instead, so no lookup needed
|
||||||
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
|
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
|
||||||
|
|
||||||
return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() );
|
return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout,
|
||||||
|
repo.isUniqueVersion() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,7 +86,7 @@ public final class ProjectUtils
|
||||||
public static ArtifactRepository buildArtifactRepository( Repository repo,
|
public static ArtifactRepository buildArtifactRepository( Repository repo,
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||||
PlexusContainer container )
|
PlexusContainer container )
|
||||||
throws ProjectBuildingException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
if ( repo != null )
|
if ( repo != null )
|
||||||
{
|
{
|
||||||
|
@ -128,7 +130,7 @@ public final class ProjectUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
|
private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
|
||||||
throws ProjectBuildingException
|
throws InvalidRepositoryException
|
||||||
{
|
{
|
||||||
String layout = mavenRepo.getLayout();
|
String layout = mavenRepo.getLayout();
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ public final class ProjectUtils
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException( "all", "Cannot find layout implementation corresponding to: \'" + layout +
|
throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout +
|
||||||
"\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
|
"\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
|
||||||
}
|
}
|
||||||
return repositoryLayout;
|
return repositoryLayout;
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.project;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
|
@ -126,10 +127,10 @@ public class TestArtifactResolver
|
||||||
List artifactRepositories;
|
List artifactRepositories;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
|
artifactRepositories =
|
||||||
repositoryFactory, container );
|
ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( InvalidRepositoryException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( e );
|
throw new ArtifactMetadataRetrievalException( e );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue