(Merged from 386445.)

From the original revision log:
--------------------------------------

o Fixed formatting of lines in DefaultMaven to ensure that the output:

[INFO] ----------------------------------------------------------------------

doesn't exceed 80 columns, for readability.

o Fixed error reporting when building a POM's parent, in cases where:

  - relativePath refers to a directory, but there is no pom.xml in that directory...in
    this case, simply set the parentDescriptor == null, and allow repository resolution
    to proceed.

  - attempt to resolve parent POM from repository fails...in this case, we need to tell
    the user which project specified the missing parent.

Neither of these had any impact on existing tests, and should only improve the user
experience. I don't believe they introduce any ambiguous behavior.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@386447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2006-03-16 20:06:21 +00:00
parent a6983a59ab
commit 43e640244e
2 changed files with 38 additions and 12 deletions

View File

@ -382,7 +382,7 @@ public class DefaultMaven
messageBuffer.append( name );
int dotCount = 55;
int dotCount = 54;
dotCount -= name.length();
@ -760,9 +760,9 @@ public class DefaultMaven
protected void line()
{
getLogger().info( "----------------------------------------------------------------------------" );
getLogger().info( "------------------------------------------------------------------------" );
}
protected static String formatTime( long ms )
{
long secs = ms / MS_PER_SEC;

View File

@ -1024,6 +1024,11 @@ public class DefaultMavenProjectBuilder
if ( model == null && projectDir != null && StringUtils.isNotEmpty( parentRelativePath ) )
{
parentDescriptor = new File( projectDir, parentRelativePath );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Searching for parent-POM: " + parentModel.getId() + " of project: " + project.getId() + " in relative path: " + parentRelativePath );
}
if ( parentDescriptor.isDirectory() )
{
@ -1037,8 +1042,12 @@ public class DefaultMavenProjectBuilder
if ( !parentDescriptor.exists() )
{
throw new ProjectBuildingException( projectId, "missing parent project descriptor: " +
parentDescriptor.getAbsolutePath() );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Parent-POM: " + parentModel.getId() + " for project: " + project.getId() + " cannot be loaded from relative path: " + parentDescriptor + "; path does not exist." );
}
parentDescriptor = null;
}
}
@ -1085,6 +1094,10 @@ public class DefaultMavenProjectBuilder
"\n Specified: " + parentModel.getId() + "\n Found: " + candidateParent.getId() );
}
}
else if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Parent-POM: " + parentModel.getId() + " not found in relative path: " + parentRelativePath );
}
}
Artifact parentArtifact = null;
@ -1101,17 +1114,30 @@ public class DefaultMavenProjectBuilder
// as we go in order to do this.
// ----------------------------------------------------------------------
getLogger().debug( "Retrieving parent-POM from the repository for project: " + project.getId() );
parentArtifact = artifactFactory.createParentArtifact( parentModel.getGroupId(),
parentModel.getArtifactId(),
parentModel.getVersion() );
// we must add the repository this POM was found in too, by chance it may be located where the parent is
// we can't query the parent to ask where it is :)
List remoteRepositories = new ArrayList( aggregatedRemoteWagonRepositories );
remoteRepositories.addAll( parentSearchRepositories );
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository, false );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug(
"Retrieving parent-POM: " + parentModel.getId() + " for project: "
+ project.getId() + " from the repository." );
}
parentArtifact = artifactFactory.createParentArtifact( parentModel.getGroupId(),
parentModel.getArtifactId(),
parentModel.getVersion() );
try
{
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository, false );
}
catch( ProjectBuildingException e )
{
throw new ProjectBuildingException( project.getId(), "Cannot find parent: " + e.getProjectId() + " for project: " + project.getId(), e );
}
}
if ( model != null && !"pom".equals( model.getPackaging() ) )