protected Assembly readAssembly( final Reader reader, final String locationDescription, final File assemblyDir,
final AssemblerConfigurationSource configSource )
throws AssemblyReadException, InvalidAssemblerConfigurationException
{
Assembly assembly;
final File basedir = configSource.getBasedir();
final MavenProject project = configSource.getProject();
try
{
final Map<String, String> context = new HashMap<String, String>();
final MavenSession session = configSource.getMavenSession();
Properties commandLineProperties = System.getProperties();
if ( session != null )
{
commandLineProperties = new Properties();
if ( session.getExecutionProperties() != null )
{
commandLineProperties.putAll( session.getExecutionProperties() );
}
if ( session.getUserProperties() != null )
{
commandLineProperties.putAll( session.getUserProperties() );
}
}
for ( final Enumeration<Object> e = commandLineProperties.keys(); e.hasMoreElements(); )
{
final String key = (String) e.nextElement();
if ( key == null || key.trim().length() < 1 )
{
continue;
}
context.put( key, commandLineProperties.getProperty( key ) );
}
context.put( "basedir", basedir.getAbsolutePath() );
final AssemblyXpp3Reader r = new AssemblyXpp3Reader();
assembly = r.read( reader );
mergeComponentsWithMainAssembly( assembly, assemblyDir, configSource );
debugPrintAssembly( "Before assembly is interpolated:", assembly );
assembly = new AssemblyInterpolator().interpolate( assembly, project, configSource );
debugPrintAssembly( "After assembly is interpolated:", assembly );
}
catch ( final IOException e )
{
throw new AssemblyReadException(
"Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
e );
}
catch ( final XmlPullParserException e )
{
throw new AssemblyReadException(
"Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
e );
}
catch ( final AssemblyInterpolationException e )
{
throw new AssemblyReadException(
"Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
e );
}
finally
{
IOUtil.close( reader );
}
if ( configSource.isSiteIncluded() || assembly.isIncludeSiteDirectory() )
{
includeSiteInAssembly( assembly, configSource );
}
return assembly;