*/
public static Project getNonJellyProject( File projectDescriptor, MavenJellyContext parentContext,
boolean useParentPom ) throws MavenException, IOException
{
// 1)
Project project = null;
try
{
project = new Project( projectDescriptor.toURL() );
}
catch ( Exception e )
{
throw new MavenException( "Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'", e );
}
// 2)
MavenJellyContext context =
MavenUtils.createContextNoDefaults( projectDescriptor.getParentFile(), parentContext );
// 3)
String pomToExtend = project.getExtend();
if ( ( pomToExtend != null ) && useParentPom )
{
// We must look in the <extend/> element for expressions that may be present as
//
// <extend>../project.xml</extend>
Expression e = JellyUtils.decomposeExpression( pomToExtend, context );
pomToExtend = e.evaluateAsString( context );
pomToExtend = MavenUtils.makeAbsolutePath( projectDescriptor.getParentFile(), pomToExtend );
project.setExtend( pomToExtend );
File parentPom = new File( pomToExtend );
parentPom = parentPom.getCanonicalFile();
if ( !parentPom.exists() )
{
throw new FileNotFoundException( "Parent POM not found: " + parentPom );
}
String parentPomPath = parentPom.getPath();
if ( parentPomPath.equals( projectDescriptor.getCanonicalPath() ) )
{
throw new MavenException( "Parent POM is equal to the current POM" );
}
Project parent = (Project) parentPoms.get( parentPomPath );
if ( parent == null )
{
parent = getNonJellyProject( parentPom, parentContext, true );
parent.setFile( parentPom );
parentPoms.put( parentPom.getCanonicalPath(), parent );
context.setParent( parent.getContext() );
}
// Map in the parent context which already has the properties loaded
integrateMapInContext( parent.getContext().getVariables(), context );
project.mergeParent( parent );
}
project.resolveIds();