You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2007/10/23 20:36:51 UTC
svn commit: r587596 - in
/maven/components/trunk/maven-project/src/main/java/org/apache/maven:
profiles/build/ project/ project/build/model/
Author: carlos
Date: Tue Oct 23 11:36:50 2007
New Revision: 587596
URL: http://svn.apache.org/viewvc?rev=587596&view=rev
Log:
Simplify ProjectBuildingException constructors and store the original File/URI instead of a String
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java?rev=587596&r1=587595&r2=587596&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java Tue Oct 23 11:36:50 2007
@@ -109,7 +109,7 @@
String projectId = ArtifactUtils.versionlessKey( groupId, artifactId );
- throw new ProjectBuildingException( projectId, e.getMessage(), pomFile.getAbsolutePath(), e );
+ throw new ProjectBuildingException( projectId, e.getMessage(), pomFile, e );
}
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
@@ -166,7 +166,7 @@
catch ( ProfileActivationException e )
{
throw new ProjectBuildingException( modelId,
- "Failed to compute active profiles for repository aggregation.", pomFile.getAbsolutePath(), e );
+ "Failed to compute active profiles for repository aggregation.", pomFile, e );
}
LinkedHashSet remoteRepositories = new LinkedHashSet();
@@ -239,13 +239,13 @@
catch ( IOException e )
{
throw new ProjectBuildingException( model.getId(), "Cannot read profiles.xml resource from directory: "
- + projectDir, pomFile.getAbsolutePath(), e );
+ + projectDir, pomFile, e );
}
catch ( XmlPullParserException e )
{
throw new ProjectBuildingException( model.getId(),
"Cannot parse profiles.xml resource from directory: " + projectDir,
- pomFile.getAbsolutePath(), e );
+ pomFile, e );
}
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=587596&r1=587595&r2=587596&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Tue Oct 23 11:36:50 2007
@@ -78,6 +78,8 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -209,7 +211,8 @@
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
- return buildInternal( "Artifact [" + artifact + "]", model, localRepository, remoteArtifactRepositories, null, null, false, false );
+ return buildInternal( artifact.getFile(), model, localRepository, remoteArtifactRepositories, null, null,
+ false, false );
}
private MavenProject superProject;
@@ -289,7 +292,7 @@
{
throw new ProjectBuildingException( projectId,
"Unable to build project due to an invalid dependency version: " +
- e.getMessage(), projectDescriptor.getAbsolutePath(), e );
+ e.getMessage(), projectDescriptor, e );
}
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
@@ -371,7 +374,7 @@
catch ( InvalidVersionSpecificationException e )
{
throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() +
- "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), pomFile.getAbsolutePath(), e );
+ "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), pomFile, e );
}
}
}
@@ -397,7 +400,7 @@
Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING );
- MavenProject project = buildInternal( projectDescriptor.getAbsolutePath(),
+ MavenProject project = buildInternal( projectDescriptor,
model,
localRepository,
buildArtifactRepositories( getSuperModel() ),
@@ -526,7 +529,7 @@
// jvz:note
// We've got a mixture of things going in the USD and from the repository, sometimes the descriptor
// is a real file and sometimes null which makes things confusing.
- private MavenProject buildInternal( String pomLocation,
+ private MavenProject buildInternal( File pomLocation,
Model model,
ArtifactRepository localRepository,
List parentSearchRepositories,
@@ -554,7 +557,7 @@
}
catch ( ProfileActivationException e )
{
- throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor.getAbsolutePath(), e );
+ throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor, e );
}
explicitlyActive = externalProfileManager.getExplicitlyActivatedIds();
@@ -645,11 +648,11 @@
}
catch ( ModelInterpolationException e )
{
- throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
+ throw new InvalidProjectModelException( projectId, e.getMessage(), pomLocation, e );
}
catch ( InvalidRepositoryException e )
{
- throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
+ throw new InvalidProjectModelException( projectId, e.getMessage(), pomLocation, e );
}
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
@@ -798,7 +801,7 @@
* the resolved source roots, etc for the parent - that occurs for the parent when it is constructed independently
* and projects are not cached or reused
*/
- private MavenProject processProjectLogic( String pomLocation,
+ private MavenProject processProjectLogic( File pomLocation,
MavenProject project,
File pomFile,
boolean strict )
@@ -882,7 +885,7 @@
if ( validationResult.getMessageCount() > 0 )
{
- throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM",
+ throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomLocation,
validationResult );
}
@@ -998,17 +1001,17 @@
try
{
reader = ReaderFactory.newXmlReader( file );
- return readModel( projectId, file.getAbsolutePath(), reader, strict );
+ return readModel( projectId, file.toURI(), reader, strict );
}
catch ( FileNotFoundException e )
{
throw new ProjectBuildingException( projectId,
- "Could not find the model file '" + file.getAbsolutePath() + "'.", file.getAbsolutePath(), e );
+ "Could not find the model file '" + file.getAbsolutePath() + "'.", file, e );
}
catch ( IOException e )
{
throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
- file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file.getAbsolutePath(), e );
+ file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file, e );
}
finally
{
@@ -1017,7 +1020,7 @@
}
private Model readModel( String projectId,
- String pomLocation,
+ URI pomLocation,
Reader reader,
boolean strict )
throws IOException, InvalidProjectModelException
@@ -1026,7 +1029,7 @@
if ( modelSource.indexOf( "<modelVersion>" + MAVEN_MODEL_VERSION ) < 0 )
{
- throw new InvalidProjectModelException( projectId, pomLocation, "Not a v" + MAVEN_MODEL_VERSION + " POM." );
+ throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", pomLocation );
}
StringReader sReader = new StringReader( modelSource );
@@ -1037,8 +1040,8 @@
}
catch ( XmlPullParserException e )
{
- throw new InvalidProjectModelException( projectId, pomLocation,
- "Parse error reading POM. Reason: " + e.getMessage(), e );
+ throw new InvalidProjectModelException( projectId, "Parse error reading POM. Reason: " + e.getMessage(),
+ pomLocation, e );
}
}
@@ -1048,15 +1051,22 @@
throws ProjectBuildingException
{
Reader reader = null;
+ URI uri = null;
try
{
+ uri = url.toURI();
reader = ReaderFactory.newXmlReader( url.openStream() );
- return readModel( projectId, url.toExternalForm(), reader, strict );
+ return readModel( projectId, uri, reader, strict );
}
catch ( IOException e )
{
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
- "\'\nError: \'" + e.getLocalizedMessage() + "\'", url.toExternalForm(), e );
+ "\'\nError: \'" + e.getLocalizedMessage() + "\'", uri, e );
+ }
+ catch ( URISyntaxException e )
+ {
+ throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm()
+ + "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
}
finally
{
@@ -1064,10 +1074,33 @@
}
}
+ /**
+ * @deprecated use {@link #createPluginArtifacts(String, List, File)}
+ * @param projectId
+ * @param plugins
+ * @param pomLocation absolute path of pom file
+ * @return
+ * @throws ProjectBuildingException
+ */
protected Set createPluginArtifacts( String projectId,
List plugins, String pomLocation )
throws ProjectBuildingException
{
+ return createPluginArtifacts( projectId, plugins, new File( pomLocation ) );
+ }
+
+ /**
+ *
+ * @param projectId
+ * @param plugins
+ * @param pomLocation pom file
+ * @return
+ * @throws ProjectBuildingException
+ */
+ protected Set createPluginArtifacts( String projectId,
+ List plugins, File pomLocation )
+ throws ProjectBuildingException
+ {
Set pluginArtifacts = new HashSet();
for ( Iterator i = plugins.iterator(); i.hasNext(); )
@@ -1106,11 +1139,26 @@
return pluginArtifacts;
}
- // TODO: share with createPluginArtifacts?
+ /**
+ * @deprecated use {@link #createReportArtifacts(String, List, File)}
+ * @param projectId
+ * @param reports
+ * @param pomLocation absolute path of pom file
+ * @return
+ * @throws ProjectBuildingException
+ */
protected Set createReportArtifacts( String projectId,
List reports, String pomLocation )
throws ProjectBuildingException
{
+ return createReportArtifacts( projectId, reports, new File( pomLocation ) );
+ }
+
+ // TODO: share with createPluginArtifacts?
+ protected Set createReportArtifacts( String projectId,
+ List reports, File pomLocation )
+ throws ProjectBuildingException
+ {
Set pluginArtifacts = new HashSet();
if ( reports != null )
@@ -1152,9 +1200,24 @@
return pluginArtifacts;
}
- // TODO: share with createPluginArtifacts?
+ /**
+ * @deprecated use {@link #createExtensionArtifacts(String, List, File)}
+ * @param projectId
+ * @param extensions
+ * @param pomLocation absolute path of pom file
+ * @return
+ * @throws ProjectBuildingException
+ */
protected Set createExtensionArtifacts( String projectId,
List extensions, String pomLocation )
+ throws ProjectBuildingException
+ {
+ return createExtensionArtifacts( projectId, extensions, new File( pomLocation ) );
+ }
+
+ // TODO: share with createPluginArtifacts?
+ protected Set createExtensionArtifacts( String projectId,
+ List extensions, File pomLocation )
throws ProjectBuildingException
{
Set extensionArtifacts = new HashSet();
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java?rev=587596&r1=587595&r2=587596&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java Tue Oct 23 11:36:50 2007
@@ -1,15 +1,7 @@
package org.apache.maven.project;
-import org.apache.maven.artifact.InvalidRepositoryException;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.profiles.activation.ProfileActivationException;
-import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.interpolation.ModelInterpolationException;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.IOException;
+import java.io.File;
+import java.net.URI;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -39,149 +31,106 @@
{
private final String projectId;
- private String pomLocation;
-
- public ProjectBuildingException( String projectId,
- String message )
- {
- super( message );
- this.projectId = projectId;
- }
-
- protected ProjectBuildingException( String projectId,
- String message,
- String pomLocation )
- {
- super( message );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
- }
-
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- ProfileActivationException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
- }
-
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- IOException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
- }
-
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- XmlPullParserException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
- }
-
- protected ProjectBuildingException( String projectId,
- String message,
- XmlPullParserException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- }
+ private URI pomUri;
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- InvalidRepositoryException cause )
+ public ProjectBuildingException( String projectId, String message )
{
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
+ this( message, projectId, (File) null );
}
- public ProjectBuildingException( String projectId,
- String message,
- InvalidRepositoryException cause )
+ /**
+ * @deprecated use {@link #ProjectBuildingException(String, String, File)}
+ * @param projectId
+ * @param message
+ * @param pomLocation absolute path of the pom file
+ */
+ protected ProjectBuildingException( String projectId, String message, String pomLocation )
{
- super( message, cause );
- this.projectId = projectId;
+ this( projectId, message, pomLocation, null );
}
- public ProjectBuildingException( String projectId,
- String message,
- ArtifactResolutionException cause )
+ /**
+ * @deprecated use {@link #ProjectBuildingException(String, String, File, Throwable)}
+ * @param projectId
+ * @param message
+ * @param pomLocation absolute path of the pom file
+ * @param cause
+ */
+ public ProjectBuildingException( String projectId, String message, String pomLocation, Throwable cause )
{
- super( message, cause );
- this.projectId = projectId;
+ this( projectId, message, new File( pomLocation ), null );
}
- public ProjectBuildingException( String projectId,
- String message,
- ArtifactNotFoundException cause )
+ /**
+ *
+ * @param projectId
+ * @param message
+ * @param pomFile pom file location
+ */
+ public ProjectBuildingException( String projectId, String message, File pomFile )
{
- super( message, cause );
- this.projectId = projectId;
+ this( projectId, message, pomFile, null );
}
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- ArtifactResolutionException cause )
+ /**
+ *
+ * @param projectId
+ * @param message
+ * @param cause
+ */
+ public ProjectBuildingException( String projectId, String message, Throwable cause )
{
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
+ this( projectId, message, (URI) null, cause );
}
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- ArtifactNotFoundException cause )
+ /**
+ * @param projectId
+ * @param message
+ * @param pomFile pom file location
+ * @param cause
+ */
+ public ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause )
{
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
+ this( projectId, message, pomFile.toURI(), cause );
}
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- InvalidVersionSpecificationException cause )
+ /**
+ * Equivalent to new ProjectBuildingException(projectId, message, pomUri, null)
+ * @see #ProjectBuildingException(String, String, URI, Throwable)
+ */
+ public ProjectBuildingException( String projectId, String message, URI pomUri )
{
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
+ this( projectId, message, pomUri, null );
}
- public ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- InvalidDependencyVersionException cause )
+ /**
+ * @param projectId
+ * @param message
+ * @param pomUri location of the pom
+ * @param cause
+ */
+ public ProjectBuildingException( String projectId, String message, URI pomUri, Throwable cause )
{
super( message, cause );
this.projectId = projectId;
- this.pomLocation = pomLocation;
+ this.pomUri = pomUri;
}
- protected ProjectBuildingException( String projectId,
- String message,
- String pomLocation,
- ModelInterpolationException cause )
+ public URI getPomUri()
{
- super( message, cause );
- this.projectId = projectId;
- this.pomLocation = pomLocation;
+ return pomUri;
}
+ /**
+ * @deprecated use {@link #getPomUri()}
+ */
public String getPomLocation()
{
- return pomLocation;
+ if ( "file".equals( getPomUri().getScheme() ) )
+ {
+ return new File( getPomUri() ).getAbsolutePath();
+ }
+ return getPomUri().toString();
}
public String getProjectId()
@@ -192,7 +141,6 @@
public String getMessage()
{
return super.getMessage() + " for project " + projectId
- + ( ( pomLocation == null ? "" : " at " + pomLocation ) );
+ + ( ( getPomUri() == null ? "" : " at " + getPomLocation() ) );
}
-
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java?rev=587596&r1=587595&r2=587596&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java Tue Oct 23 11:36:50 2007
@@ -198,11 +198,11 @@
}
catch ( IOException e )
{
- throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, pomFile.getAbsolutePath(), e );
+ throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, pomFile, e );
}
catch ( XmlPullParserException e )
{
- throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, pomFile.getAbsolutePath(), e );
+ throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, pomFile, e );
}
finally
{
@@ -251,7 +251,7 @@
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( model.getId(), "Failed to create ArtifactRepository list for: "
- + pomFile, pomFile.getAbsolutePath(), e );
+ + pomFile, pomFile, e );
}
}