diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
index bfeef2fb8a..a51186a19f 100644
--- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
+++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
@@ -536,7 +536,7 @@ public class DefaultWagonManager
}
catch ( IOException e )
{
- throw new TransferFailedException( "Invalid checksum file", e );
+ throw new ChecksumFailedException( "Invalid checksum file", e );
}
}
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java
new file mode 100644
index 0000000000..180b008795
--- /dev/null
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java
@@ -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 Brett Porter
+ * @version $Id$
+ */
+public class InvalidRepositoryException
+ extends Exception
+{
+ public InvalidRepositoryException( String message, Throwable throwable )
+ {
+ super( message, throwable );
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java b/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
index b4c53c0844..886a09ceaa 100644
--- a/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
+++ b/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
@@ -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
extends Exception
diff --git a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
index 6147216023..4104c66125 100644
--- a/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
+++ b/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
@@ -5,11 +5,9 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.AbstractLogEnabled;
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.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
@@ -28,8 +26,8 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
throws ExtractionException, InvalidPluginDescriptorException
{
- Map scriptFilesKeyedByBasedir = gatherScriptSourcesByBasedir( project.getScriptSourceRoots(),
- getScriptFileExtension() );
+ Map scriptFilesKeyedByBasedir =
+ gatherScriptSourcesByBasedir( project.getScriptSourceRoots(), getScriptFileExtension() );
List mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, pluginDescriptor );
@@ -74,32 +72,14 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
outputFile.getParentFile().mkdirs();
}
- FileInputStream in = null;
- FileOutputStream out = null;
-
try
{
- in = new FileInputStream( scriptFile );
- 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();
+ FileUtils.copyFile( scriptFile, outputFile );
}
catch ( IOException e )
{
- throw new ExtractionException( "Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
- }
- finally
- {
- IOUtil.close( in );
- IOUtil.close( out );
+ throw new ExtractionException(
+ "Cannot copy script file: " + scriptFile + " to output: " + outputFile, e );
}
}
}
diff --git a/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java b/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java
index b8755e65f0..8ab1552588 100644
--- a/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java
+++ b/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.java
@@ -1,5 +1,21 @@
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
extends Exception
{
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 c373605ee5..b1919d7c04 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
@@ -19,6 +19,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactStatus;
import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager;
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
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();
@@ -194,7 +197,7 @@ public class DefaultMavenProjectBuilder
}
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 )
@@ -224,7 +227,8 @@ public class DefaultMavenProjectBuilder
}
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,
- ProfileManager profileManager,
- boolean checkDistributionManagementStatus )
+ ProfileManager profileManager, boolean checkDistributionManagementStatus )
throws ProjectBuildingException
{
Model model = readModel( "unknown", projectDescriptor );
@@ -294,10 +297,13 @@ public class DefaultMavenProjectBuilder
if ( checkDistributionManagementStatus )
{
- if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
+ if ( project.getDistributionManagement() != null &&
+ project.getDistributionManagement().getStatus() != null )
{
- throw new ProjectBuildingException( project.getId(),
- "Invalid project file: distribution status must not be specified for a project outside of the repository" );
+ 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" );
}
}
@@ -364,7 +370,7 @@ public class DefaultMavenProjectBuilder
if ( project == null )
{
String projectId = ArtifactUtils.versionlessKey( projectArtifact );
-
+
try
{
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
@@ -530,7 +536,7 @@ public class DefaultMavenProjectBuilder
Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
+
List activeExternalProfiles;
try
{
@@ -556,9 +562,16 @@ public class DefaultMavenProjectBuilder
{
Repository mavenRepo = (Repository) repoIterator.next();
- ArtifactRepository artifactRepo = ProjectUtils.buildArtifactRepository( mavenRepo,
- artifactRepositoryFactory,
- container );
+ ArtifactRepository artifactRepo = null;
+ try
+ {
+ artifactRepo =
+ ProjectUtils.buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
+ }
+ catch ( InvalidRepositoryException e )
+ {
+ throw new ProjectBuildingException( projectId, e.getMessage(), e );
+ }
aggregatedRemoteWagonRepositories.add( artifactRepo );
}
@@ -566,8 +579,16 @@ public class DefaultMavenProjectBuilder
Model originalModel = ModelUtils.cloneModel( model );
- MavenProject project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
- aggregatedRemoteWagonRepositories, externalProfileManager );
+ MavenProject project = null;
+ try
+ {
+ project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
+ aggregatedRemoteWagonRepositories, externalProfileManager );
+ }
+ catch ( InvalidRepositoryException e )
+ {
+ throw new ProjectBuildingException( projectId, e.getMessage(), e );
+ }
project.setOriginalModel( originalModel );
@@ -603,8 +624,11 @@ public class DefaultMavenProjectBuilder
}
catch ( ModelInterpolationException e )
{
- throw new ProjectBuildingException( project.getId(), "Error building project from \'" + pomLocation + "\': " + model.getId(),
- e );
+ throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
+ }
+ catch ( InvalidRepositoryException e )
+ {
+ throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
}
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
project );
@@ -614,26 +638,36 @@ public class DefaultMavenProjectBuilder
private String safeVersionlessKey( String groupId, String artifactId )
{
String gid = groupId;
-
+
if ( StringUtils.isEmpty( gid ) )
{
gid = "unknown";
}
-
+
String aid = artifactId;
-
+
if ( StringUtils.isEmpty( aid ) )
{
aid = "unknown";
}
-
+
return ArtifactUtils.versionlessKey( gid, aid );
}
private List buildArtifactRepositories( Model model )
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,
ProfileManager profileMgr, File projectDir )
- throws ProjectBuildingException, ModelInterpolationException
+ throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
{
Model model = project.getModel();
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
ModelValidationResult validationResult = validator.validate( model );
+ String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
+
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(
ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
// TODO: these aren't taking active project artifacts into consideration in the reactor
- project.setPluginArtifacts( createPluginArtifacts( project.getId(), project.getBuildPlugins() ) );
- project.setReportArtifacts( createReportArtifacts( project.getId(), project.getReportPlugins() ) );
- project.setExtensionArtifacts( createExtensionArtifacts( project.getId(), project.getBuildExtensions() ) );
+ project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) );
+ project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) );
+ project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) );
return project;
}
@@ -754,7 +791,7 @@ public class DefaultMavenProjectBuilder
private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
File projectDir, List parentSearchRepositories,
Set aggregatedRemoteWagonRepositories, ProfileManager externalProfileManager )
- throws ProjectBuildingException
+ throws ProjectBuildingException, InvalidRepositoryException
{
if ( !model.getRepositories().isEmpty() )
{
@@ -792,8 +829,9 @@ public class DefaultMavenProjectBuilder
catch ( ProfileActivationException e )
{
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 );
@@ -807,7 +845,7 @@ public class DefaultMavenProjectBuilder
if ( parentModel != null )
{
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
+
if ( StringUtils.isEmpty( parentModel.getGroupId() ) )
{
throw new ProjectBuildingException( projectId, "Missing groupId element from parent element" );
@@ -824,8 +862,8 @@ public class DefaultMavenProjectBuilder
// the only way this will have a value is if we find the parent on disk...
File parentDescriptor = null;
- MavenProject p = getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(),
- parentModel.getVersion() );
+ MavenProject p =
+ getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() );
if ( p != null )
{
model = p.getModel();
@@ -948,8 +986,8 @@ public class DefaultMavenProjectBuilder
catch ( ProfileActivationException e )
{
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(); )
@@ -1019,17 +1057,13 @@ public class DefaultMavenProjectBuilder
}
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 )
{
- throw new ProjectBuildingException( projectId, "Failed to build model from file '" + 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 );
+ throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
+ file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
}
finally
{
@@ -1038,7 +1072,7 @@ public class DefaultMavenProjectBuilder
}
private Model readModel( String projectId, String pomLocation, Reader reader )
- throws IOException, XmlPullParserException, InvalidProjectModelException
+ throws IOException, InvalidProjectModelException
{
StringWriter sw = new StringWriter();
@@ -1053,7 +1087,14 @@ public class DefaultMavenProjectBuilder
StringReader sReader = new StringReader( modelSource );
- return modelReader.read( sReader );
+ try
+ {
+ return modelReader.read( sReader );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new InvalidProjectModelException( projectId, pomLocation, "Parse error reading POM", e );
+ }
}
private Model readModel( String projectId, URL url )
@@ -1070,11 +1111,6 @@ public class DefaultMavenProjectBuilder
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
}
- catch ( XmlPullParserException e )
- {
- throw new ProjectBuildingException( projectId, "Failed to parse model from URL \'" + url.toExternalForm() +
- "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
- }
finally
{
IOUtil.close( reader );
@@ -1233,6 +1269,8 @@ public class DefaultMavenProjectBuilder
profileManager.addProfiles( superModel.getProfiles() );
+ String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
+
activeProfiles = injectActiveProfiles( profileManager, superModel );
MavenProject project = new MavenProject( superModel );
@@ -1243,9 +1281,6 @@ public class DefaultMavenProjectBuilder
try
{
- // TODO: remove - confirm this was a correct decision
-// project.setFile( new File( ".", "pom.xml" ) );
-
List remoteRepositories = buildArtifactRepositories( superModel );
project = processProjectLogic( "", project, remoteRepositories, null, null );
@@ -1256,9 +1291,11 @@ public class DefaultMavenProjectBuilder
}
catch ( ModelInterpolationException e )
{
- String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
-
- throw new ProjectBuildingException( projectId, "Error building super-project", e );
+ throw new ProjectBuildingException( projectId, e.getMessage(), e );
+ }
+ catch ( InvalidRepositoryException e )
+ {
+ throw new ProjectBuildingException( projectId, e.getMessage(), e );
}
}
@@ -1272,7 +1309,7 @@ public class DefaultMavenProjectBuilder
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
-
+
return readModel( projectId, url );
}
diff --git a/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java b/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
index 4667e27682..6d6bbb4830 100644
--- a/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
+++ b/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
@@ -1,18 +1,41 @@
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;
public class InvalidProjectModelException
extends ProjectBuildingException
{
-
private final String pomLocation;
+
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 );
-
+
this.pomLocation = pomLocation;
this.validationResult = validationResult;
}
@@ -20,7 +43,7 @@ public class InvalidProjectModelException
public InvalidProjectModelException( String projectId, String pomLocation, String message )
{
super( projectId, message );
-
+
this.pomLocation = pomLocation;
}
diff --git a/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java b/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
index b43ea71c76..a9de6b9df4 100644
--- a/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
+++ b/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
@@ -16,14 +16,15 @@ package org.apache.maven.project;
* limitations under the License.
*/
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
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.RepositoryBase;
import org.apache.maven.model.RepositoryPolicy;
-import org.apache.maven.model.DeploymentRepository;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -40,7 +41,7 @@ public final class ProjectUtils
public static List buildArtifactRepositories( List repositories,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws ProjectBuildingException
+ throws InvalidRepositoryException
{
List repos = new ArrayList();
@@ -49,8 +50,8 @@ public final class ProjectUtils
{
Repository mavenRepo = (Repository) i.next();
- ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo, artifactRepositoryFactory,
- container );
+ ArtifactRepository artifactRepo =
+ buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
if ( !repos.contains( artifactRepo ) )
{
@@ -63,7 +64,7 @@ public final class ProjectUtils
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws ProjectBuildingException
+ throws InvalidRepositoryException
{
if ( repo != null )
{
@@ -73,7 +74,8 @@ public final class ProjectUtils
// TODO: make this a map inside the factory instead, so no lookup needed
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
- return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() );
+ return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout,
+ repo.isUniqueVersion() );
}
else
{
@@ -84,7 +86,7 @@ public final class ProjectUtils
public static ArtifactRepository buildArtifactRepository( Repository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws ProjectBuildingException
+ throws InvalidRepositoryException
{
if ( repo != null )
{
@@ -128,7 +130,7 @@ public final class ProjectUtils
}
private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
- throws ProjectBuildingException
+ throws InvalidRepositoryException
{
String layout = mavenRepo.getLayout();
@@ -139,7 +141,7 @@ public final class ProjectUtils
}
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 );
}
return repositoryLayout;
diff --git a/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java b/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
index 7d07dd8580..03fb9d62a6 100644
--- a/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
+++ b/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
@@ -17,6 +17,7 @@ package org.apache.maven.project;
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -126,10 +127,10 @@ public class TestArtifactResolver
List artifactRepositories;
try
{
- artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
- repositoryFactory, container );
+ artifactRepositories =
+ ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
}
- catch ( ProjectBuildingException e )
+ catch ( InvalidRepositoryException e )
{
throw new ArtifactMetadataRetrievalException( e );
}