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 6b4196b705..40c18523dc 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 @@ -78,8 +78,6 @@ import java.io.FileNotFoundException; 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; @@ -211,8 +209,7 @@ public class DefaultMavenProjectBuilder Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository ); - return buildInternal( artifact.getFile(), model, localRepository, remoteArtifactRepositories, null, null, - false, false ); + return buildInternal( "Artifact [" + artifact + "]", model, localRepository, remoteArtifactRepositories, null, null, false, false ); } private MavenProject superProject; @@ -292,7 +289,7 @@ public class DefaultMavenProjectBuilder { throw new ProjectBuildingException( projectId, "Unable to build project due to an invalid dependency version: " + - e.getMessage(), projectDescriptor, e ); + e.getMessage(), projectDescriptor.getAbsolutePath(), e ); } ArtifactResolutionRequest request = new ArtifactResolutionRequest() @@ -374,7 +371,7 @@ public class DefaultMavenProjectBuilder catch ( InvalidVersionSpecificationException e ) { throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() + - "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), pomFile, e ); + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), pomFile.getAbsolutePath(), e ); } } } @@ -400,7 +397,7 @@ public class DefaultMavenProjectBuilder Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING ); - MavenProject project = buildInternal( projectDescriptor, + MavenProject project = buildInternal( projectDescriptor.getAbsolutePath(), model, localRepository, buildArtifactRepositories( getSuperModel() ), @@ -529,7 +526,7 @@ public class DefaultMavenProjectBuilder // 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( File pomLocation, + private MavenProject buildInternal( String pomLocation, Model model, ArtifactRepository localRepository, List parentSearchRepositories, @@ -557,7 +554,7 @@ public class DefaultMavenProjectBuilder } catch ( ProfileActivationException e ) { - throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor, e ); + throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor.getAbsolutePath(), e ); } explicitlyActive = externalProfileManager.getExplicitlyActivatedIds(); @@ -648,11 +645,11 @@ public class DefaultMavenProjectBuilder } catch ( ModelInterpolationException e ) { - throw new InvalidProjectModelException( projectId, e.getMessage(), pomLocation, e ); + throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e ); } catch ( InvalidRepositoryException e ) { - throw new InvalidProjectModelException( projectId, e.getMessage(), pomLocation, e ); + throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e ); } ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager ); @@ -801,7 +798,7 @@ public class DefaultMavenProjectBuilder * 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( File pomLocation, + private MavenProject processProjectLogic( String pomLocation, MavenProject project, File pomFile, boolean strict ) @@ -885,7 +882,7 @@ public class DefaultMavenProjectBuilder if ( validationResult.getMessageCount() > 0 ) { - throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomLocation, + throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM", validationResult ); } @@ -1001,17 +998,17 @@ public class DefaultMavenProjectBuilder try { reader = ReaderFactory.newXmlReader( file ); - return readModel( projectId, file.toURI(), reader, strict ); + return readModel( projectId, file.getAbsolutePath(), reader, strict ); } catch ( FileNotFoundException e ) { throw new ProjectBuildingException( projectId, - "Could not find the model file '" + file.getAbsolutePath() + "'.", file, e ); + "Could not find the model file '" + file.getAbsolutePath() + "'.", file.getAbsolutePath(), e ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed to build model from file '" + - file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file, e ); + file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file.getAbsolutePath(), e ); } finally { @@ -1020,7 +1017,7 @@ public class DefaultMavenProjectBuilder } private Model readModel( String projectId, - URI pomLocation, + String pomLocation, Reader reader, boolean strict ) throws IOException, InvalidProjectModelException @@ -1029,7 +1026,7 @@ public class DefaultMavenProjectBuilder if ( modelSource.indexOf( "" + MAVEN_MODEL_VERSION ) < 0 ) { - throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", pomLocation ); + throw new InvalidProjectModelException( projectId, pomLocation, "Not a v" + MAVEN_MODEL_VERSION + " POM." ); } StringReader sReader = new StringReader( modelSource ); @@ -1040,8 +1037,8 @@ public class DefaultMavenProjectBuilder } catch ( XmlPullParserException e ) { - throw new InvalidProjectModelException( projectId, "Parse error reading POM. Reason: " + e.getMessage(), - pomLocation, e ); + throw new InvalidProjectModelException( projectId, pomLocation, + "Parse error reading POM. Reason: " + e.getMessage(), e ); } } @@ -1051,22 +1048,15 @@ public class DefaultMavenProjectBuilder throws ProjectBuildingException { Reader reader = null; - URI uri = null; try { - uri = url.toURI(); reader = ReaderFactory.newXmlReader( url.openStream() ); - return readModel( projectId, uri, reader, strict ); + return readModel( projectId, url.toExternalForm(), reader, strict ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() + - "\'\nError: \'" + e.getLocalizedMessage() + "\'", uri, e ); - } - catch ( URISyntaxException e ) - { - throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() - + "\'\nError: \'" + e.getLocalizedMessage() + "\'", e ); + "\'\nError: \'" + e.getLocalizedMessage() + "\'", url.toExternalForm(), e ); } finally { @@ -1074,32 +1064,9 @@ public class DefaultMavenProjectBuilder } } - /** - * @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(); @@ -1139,24 +1106,9 @@ public class DefaultMavenProjectBuilder return pluginArtifacts; } - /** - * @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 ) + List reports, String pomLocation ) throws ProjectBuildingException { Set pluginArtifacts = new HashSet(); @@ -1200,24 +1152,9 @@ public class DefaultMavenProjectBuilder return pluginArtifacts; } - /** - * @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 ) + List extensions, String pomLocation ) throws ProjectBuildingException { Set extensionArtifacts = new HashSet(); diff --git a/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java b/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java index 501992ff52..06da819852 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java +++ b/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java @@ -36,25 +36,6 @@ public class DuplicateProjectException private final File conflictingProjectFile; - /** - * @deprecated use {@link #DuplicateProjectException(String, File, File, String)} - */ - public DuplicateProjectException( String message ) - { - this( null, null, null, message ); - } - - /** - * @deprecated use {@link #DuplicateProjectException(String, File, File, String)} - */ - public DuplicateProjectException( String message, Exception e ) - { - super( message, e ); - this.projectId = null; - this.existingProjectFile = null; - this.conflictingProjectFile = null; - } - public DuplicateProjectException( String projectId, File existingProjectFile, File conflictingProjectFile, 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 3826e4ee24..ddb14d3124 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 @@ -19,117 +19,55 @@ package org.apache.maven.project; * under the License. */ -import java.io.File; -import java.net.URI; - +import org.apache.maven.artifact.InvalidRepositoryException; +import org.apache.maven.project.interpolation.ModelInterpolationException; import org.apache.maven.project.validation.ModelValidationResult; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; public class InvalidProjectModelException extends ProjectBuildingException { private ModelValidationResult validationResult; - /** - * - * @param projectId - * @param message - * @param pomFile pom file - * @param cause - */ public InvalidProjectModelException( String projectId, + String pomLocation, String message, - File pomFile, - Throwable cause ) - { - super( projectId, message, pomFile, cause ); - } - - /** - * - * @param projectId - * @param message - * @param pomLocation pom location - * @param cause - */ - public InvalidProjectModelException( String projectId, - String message, - URI pomLocation, - Throwable cause ) + ModelInterpolationException cause ) { super( projectId, message, pomLocation, cause ); } - /** - * - * @param projectId - * @param message - * @param pomLocation pom location - */ public InvalidProjectModelException( String projectId, + String pomLocation, String message, - URI pomLocation ) + InvalidRepositoryException cause ) + { + super( projectId, message, pomLocation, cause ); + } + + public InvalidProjectModelException( String projectId, + String pomLocation, + String message, + ModelValidationResult validationResult ) { super( projectId, message, pomLocation ); - } - - /** - * @deprecated use {@link #InvalidProjectModelException(String, String, File, Throwable)} - * @param projectId - * @param pomLocation absolute path of the pom file - * @param message - * @param cause - */ - public InvalidProjectModelException( String projectId, - String pomLocation, - String message, - Throwable cause ) - { - super( projectId, message, new File( pomLocation ), cause ); - } - - /** - * @deprecated use {@link #InvalidProjectModelException(String, String, File, ModelValidationResult)} - * @param projectId - * @param pomLocation absolute path of the pom file - * @param message - * @param validationResult - */ - public InvalidProjectModelException( String projectId, - String pomLocation, - String message, - ModelValidationResult validationResult ) - { - this( projectId, message, new File( pomLocation ), validationResult ); - } - - public InvalidProjectModelException( String projectId, - String message, - File pomFile, - ModelValidationResult validationResult ) - { - super( projectId, message, pomFile ); this.validationResult = validationResult; } public InvalidProjectModelException( String projectId, - String message, - File pomLocation ) + String pomLocation, + String message ) { super( projectId, message, pomLocation ); } - /** - * @deprecated use {@link #InvalidProjectModelException(String, String, File)} - * @param projectId - * @param pomLocation absolute path of the pom file - * @param message - */ public InvalidProjectModelException( String projectId, String pomLocation, - String message ) + String message, + XmlPullParserException cause ) { - super( projectId, message, new File( pomLocation ) ); + super( projectId, message, pomLocation, cause ); } public final ModelValidationResult getValidationResult() diff --git a/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java b/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java index c72d754d8d..a0246e989d 100644 --- a/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java +++ b/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java @@ -1,7 +1,15 @@ package org.apache.maven.project; -import java.io.File; -import java.net.URI; +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; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -31,106 +39,149 @@ public class ProjectBuildingException { private final String projectId; - private URI pomUri; + private String pomLocation; - public ProjectBuildingException( String projectId, String message ) + public ProjectBuildingException( String projectId, + String message ) { - this( message, projectId, (File) null ); + super( message ); + this.projectId = projectId; } - /** - * @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 ) + protected ProjectBuildingException( String projectId, + String message, + String pomLocation ) { - this( projectId, message, pomLocation, null ); + super( message ); + this.projectId = projectId; + this.pomLocation = pomLocation; } - /** - * @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 ) - { - this( projectId, message, new File( pomLocation ), null ); - } - - /** - * - * @param projectId - * @param message - * @param pomFile pom file location - */ - public ProjectBuildingException( String projectId, String message, File pomFile ) - { - this( projectId, message, pomFile, null ); - } - - /** - * - * @param projectId - * @param message - * @param cause - */ - public ProjectBuildingException( String projectId, String message, Throwable cause ) - { - this( projectId, message, (URI) null, cause ); - } - - /** - * @param projectId - * @param message - * @param pomFile pom file location - * @param cause - */ - public ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause ) - { - this( projectId, message, pomFile.toURI(), cause ); - } - - /** - * Equivalent to new ProjectBuildingException(projectId, message, pomUri, null) - * @see #ProjectBuildingException(String, String, URI, Throwable) - */ - public ProjectBuildingException( String projectId, String message, URI pomUri ) - { - this( projectId, message, pomUri, null ); - } - - /** - * @param projectId - * @param message - * @param pomUri location of the pom - * @param cause - */ - public ProjectBuildingException( String projectId, String message, URI pomUri, Throwable cause ) + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + ProfileActivationException cause ) { super( message, cause ); this.projectId = projectId; - this.pomUri = pomUri; + this.pomLocation = pomLocation; } - public URI getPomUri() + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + IOException cause ) { - return pomUri; + 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; + } + + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + InvalidRepositoryException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; + } + + public ProjectBuildingException( String projectId, + String message, + InvalidRepositoryException cause ) + { + super( message, cause ); + this.projectId = projectId; + } + + public ProjectBuildingException( String projectId, + String message, + ArtifactResolutionException cause ) + { + super( message, cause ); + this.projectId = projectId; + } + + public ProjectBuildingException( String projectId, + String message, + ArtifactNotFoundException cause ) + { + super( message, cause ); + this.projectId = projectId; + } + + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + ArtifactResolutionException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; + } + + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + ArtifactNotFoundException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; + } + + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + InvalidVersionSpecificationException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; + } + + public ProjectBuildingException( String projectId, + String message, + String pomLocation, + InvalidDependencyVersionException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; + } + + protected ProjectBuildingException( String projectId, + String message, + String pomLocation, + ModelInterpolationException cause ) + { + super( message, cause ); + this.projectId = projectId; + this.pomLocation = pomLocation; } - /** - * @deprecated use {@link #getPomUri()} - */ public String getPomLocation() { - if ( "file".equals( getPomUri().getScheme() ) ) - { - return new File( getPomUri() ).getAbsolutePath(); - } - return getPomUri().toString(); + return pomLocation; } public String getProjectId() @@ -141,6 +192,7 @@ public class ProjectBuildingException public String getMessage() { return super.getMessage() + " for project " + projectId - + ( ( getPomUri() == null ? "" : " at " + getPomLocation() ) ); + + ( ( pomLocation == null ? "" : " at " + pomLocation ) ); } + } diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java b/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java index 08983736f9..f118b4e604 100644 --- a/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java +++ b/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java @@ -34,12 +34,4 @@ public class InvalidDependencyVersionException { super( message, cause ); } - - /** - * @deprecated use {@link #InvalidDependencyVersionException(String, InvalidVersionSpecificationException)} - */ - public InvalidDependencyVersionException( String message, Exception cause ) - { - super( message, cause ); - } } diff --git a/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java b/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java index c9f8a0cc27..808fc40221 100644 --- a/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java @@ -198,11 +198,11 @@ public class DefaultModelLineageBuilder } catch ( IOException e ) { - throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, pomFile, e ); + throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, pomFile.getAbsolutePath(), e ); } catch ( XmlPullParserException e ) { - throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, pomFile, e ); + throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, pomFile.getAbsolutePath(), e ); } finally { @@ -251,7 +251,7 @@ public class DefaultModelLineageBuilder catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( model.getId(), "Failed to create ArtifactRepository list for: " - + pomFile, pomFile, e ); + + pomFile, pomFile.getAbsolutePath(), e ); } }