Author: jdcasey
Date: Fri Sep 12 15:12:41 2008
New Revision: 694818

URL: http://svn.apache.org/viewvc?rev=694818&view=rev
Log:
[MASSEMBLY-351] Realign assembly-descriptor interpolation with 
outputDirectory/outputFileNameMapping interpolation, and use reflective 
interpolator instead of model serialization/deserialization (based on 2.1.0-M1 
work, but generalized into plexus-interpolation). This fixes project.xxx 
expression interpolation. Also including an integration test.

Added:
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project1.file
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project2.file
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project3.file
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java
   (with props)
    
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java
   (with props)
Modified:
    maven/plugins/trunk/maven-assembly-plugin/pom.xml
    
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
    
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
    
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java
    
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
    
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java

Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/pom.xml?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Fri Sep 12 15:12:41 2008
@@ -54,6 +54,11 @@
 
   <dependencies>
     <dependency>
+       <groupId>org.codehaus.plexus</groupId>
+       <artifactId>plexus-interpolation</artifactId>
+       <version>1.6-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
       <version>1.0-alpha-10</version>
@@ -187,11 +192,6 @@
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-       <groupId>org.codehaus.plexus</groupId>
-       <artifactId>plexus-interpolation</artifactId>
-       <version>1.5</version>
-    </dependency>
   </dependencies>
 
   <repositories>

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,2 @@
+clean
+org.apache.maven.plugins:maven-assembly-plugin:${testVersion}:attached

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.plugin.assembly.test</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <artifactId>project</artifactId>
+  <packaging>pom</packaging>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src/main/assembly/myassembly.xml</descriptor>
+          </descriptors>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<assembly>
+    <id>myassembly</id>
+    <formats>
+        <format>dir</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>src/main/files</directory>
+            <outputDirectory>/files</outputDirectory>
+            <includes>
+              <include>${artifactId}1.file</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/files</directory>
+            <outputDirectory>/files</outputDirectory>
+            <includes>
+              <include>${pom.artifactId}2.file</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/files</directory>
+            <outputDirectory>/files</outputDirectory>
+            <includes>
+              <include>${project.artifactId}3.file</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+</assembly>

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/assembly/myassembly.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project1.file
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project1.file?rev=694818&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project1.file
------------------------------------------------------------------------------
    svn:executable = *

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project2.file
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project2.file?rev=694818&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project2.file
------------------------------------------------------------------------------
    svn:executable = *

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project3.file
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project3.file?rev=694818&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/src/main/files/project3.file
------------------------------------------------------------------------------
    svn:executable = *

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,25 @@
+import java.io.*;
+
+File f = new File( basedir, 
"target/project-1-myassembly.dir/files/project1.file" );
+File f2 = new File( basedir, 
"target/project-1-myassembly.dir/files/project2.file" );
+File f3 = new File( basedir, 
"target/project-1-myassembly.dir/files/project3.file" );
+
+boolean fOK = f.exists() && f.isFile();
+if ( !fOK )
+{
+       System.out.println( "File: " + f + " doesn't exist, or isn't a file." );
+}
+
+boolean f2OK = f2.exists() && f2.isFile();
+if ( !f2OK )
+{
+       System.out.println( "File: " + f2 + " doesn't exist, or isn't a file." 
);
+}
+
+boolean f3OK = f3.exists() && f3.isFile();
+if ( !f3OK )
+{
+       System.out.println( "File: " + f3 + " doesn't exist, or isn't a file." 
);
+}
+
+return fOK && f2OK;

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/basic-features/massembly-351-projectPrefixInterp/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
 (original)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
 Fri Sep 12 15:12:41 2008
@@ -19,27 +19,33 @@
  * under the License.
  */
 
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
 import org.apache.maven.plugin.assembly.model.Assembly;
-import org.apache.maven.plugin.assembly.model.io.xpp3.AssemblyXpp3Reader;
-import org.apache.maven.plugin.assembly.model.io.xpp3.AssemblyXpp3Writer;
 import org.apache.maven.plugin.assembly.utils.CommandLineUtils;
+import org.apache.maven.plugin.assembly.utils.InterpolationConstants;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
+import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
+import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+import org.codehaus.plexus.interpolation.RecursionInterceptor;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.interpolation.object.FieldBasedObjectInterpolator;
+import org.codehaus.plexus.interpolation.object.ObjectInterpolationWarning;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * @version $Id$
@@ -47,10 +53,6 @@
 public class AssemblyInterpolator
     extends AbstractLogEnabled
 {
-    private static final Pattern ELEMENT_PATTERN = Pattern.compile( "\\<([^> 
]+)[^>]*>([^<]+)" );
-
-    private static final Pattern EXPRESSION_PATTERN = Pattern.compile( 
"\\$\\{(pom\\.|project\\.|env\\.)?([^}]+)\\}" );
-
     private static final Set INTERPOLATION_BLACKLIST;
 
     static
@@ -77,143 +79,107 @@
         envars = CommandLineUtils.getSystemEnvVars( false );
     }
 
-    public Assembly interpolate( Assembly assembly, MavenProject project, Map 
context )
+    public Assembly interpolate( Assembly assembly, MavenProject project, 
AssemblerConfigurationSource configSource )
         throws AssemblyInterpolationException
     {
-        return interpolate( assembly, project, context, true );
-    }
+        Set blacklistFields = new HashSet( 
FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
+        blacklistFields.addAll( INTERPOLATION_BLACKLIST );
 
-    public Assembly interpolate( Assembly assembly, MavenProject project, Map 
context, boolean strict )
-        throws AssemblyInterpolationException
-    {
-        StringWriter sWriter = new StringWriter();
+        Set blacklistPkgs = 
FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_PACKAGE_PREFIXES;
 
-        AssemblyXpp3Writer writer = new AssemblyXpp3Writer();
+        FieldBasedObjectInterpolator objectInterpolator =
+            new FieldBasedObjectInterpolator( blacklistFields, blacklistPkgs );
+        Interpolator interpolator = buildInterpolator( project, configSource );
+
+        // TODO: Will this adequately detect cycles between prefixed property 
references and prefixed project
+        // references??
+        RecursionInterceptor interceptor =
+            new PrefixAwareRecursionInterceptor( 
InterpolationConstants.PROJECT_PREFIXES, true );
 
         try
         {
-            writer.write( sWriter, assembly );
+            objectInterpolator.interpolate( assembly, interpolator, 
interceptor );
         }
-        catch ( IOException e )
+        catch ( InterpolationException e )
         {
-            throw new AssemblyInterpolationException( "Cannot serialize 
assembly descriptor for interpolation.", e );
+            throw new AssemblyInterpolationException( "Failed to interpolate 
assembly with ID: " + assembly.getId()
+                + ". Reason: " + e.getMessage(), e );
         }
 
-        String serializedAssembly = sWriter.toString();
-
-        serializedAssembly = interpolateInternal( serializedAssembly, 
assembly, project, context );
-
-        StringReader sReader = new StringReader( serializedAssembly );
-
-        AssemblyXpp3Reader assemblyReader = new AssemblyXpp3Reader();
-        try
+        if ( objectInterpolator.hasWarnings() && getLogger().isDebugEnabled() )
         {
-            assembly = assemblyReader.read( sReader );
-        }
-        catch ( IOException e )
-        {
-            throw new AssemblyInterpolationException(
-                "Cannot read assembly descriptor from interpolating filter of 
serialized version.", e );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new AssemblyInterpolationException(
-                "Cannot read assembly descriptor from interpolating filter of 
serialized version.", e );
-        }
-
-        return assembly;
-    }
+            StringBuffer sb = new StringBuffer();
 
-    private String interpolateInternal( String src, Assembly assembly, 
MavenProject project, Map context )
-        throws AssemblyInterpolationException
-    {
-        String result = src;
+            sb.append( "One or more minor errors occurred while interpolating 
the assembly with ID: "
+                + assembly.getId() + ":\n" );
 
-        Matcher elementMatcher = ELEMENT_PATTERN.matcher( result );
+            List warnings = objectInterpolator.getWarnings();
+            for ( Iterator it = warnings.iterator(); it.hasNext(); )
+            {
+                ObjectInterpolationWarning warning = 
(ObjectInterpolationWarning) it.next();
 
-        while ( elementMatcher.find() )
-        {
-            String element = elementMatcher.group( 0 );
+                sb.append( '\n' ).append( warning );
+            }
 
-            String elementName = elementMatcher.group( 1 );
-            String value = elementMatcher.group( 2 );
+            sb.append( "\n\nThese values were SKIPPED, but the assembly 
process will continue.\n" );
 
-            // only attempt to interpolate if the following is met:
-            // 1. the element is not in the interpolation blacklist.
-            // 2. the value is not empty (otherwise there's nothing to 
interpolate)
-            // 3. the value contains a "${" (a pretty good clue that there's 
an expression in it)
-            if ( StringUtils.isNotEmpty( value ) && ( value.indexOf( "${" ) > 
-1 ) )
-            {
-                if ( !INTERPOLATION_BLACKLIST.contains( elementName ) )
-                {
-                    String interpolatedValue =
-                        interpolateElementValue( value, assembly, project, 
context );
-
-                    String modifiedElement = StringUtils.replace( element, 
value, interpolatedValue );
-                    result = StringUtils.replace( result, element, 
modifiedElement );
-                }
-            }
+            getLogger().debug( sb.toString() );
         }
 
-        return result;
+        return assembly;
     }
 
-    private String interpolateElementValue( String src, Assembly assembly, 
MavenProject project, Map context )
-        throws AssemblyInterpolationException
+    private Interpolator buildInterpolator( MavenProject project, 
AssemblerConfigurationSource configSource )
     {
-        String result = src;
-
-        Matcher matcher = EXPRESSION_PATTERN.matcher( result );
-        while ( matcher.find() )
-        {
-            String wholeExpr = matcher.group( 0 );
-            String realExpr = matcher.group( 2 );
+        StringSearchInterpolator interpolator = new StringSearchInterpolator();
 
-            Object value = context.get( realExpr );
+        MavenSession session = configSource.getMavenSession();
 
-            if ( value == null )
+        if ( session != null )
+        {
+            Properties userProperties = null;
+            try
             {
-                value = project.getProperties().getProperty( realExpr );
+                userProperties = session.getExecutionProperties();
             }
-
-            if ( value == null )
+            catch ( NoSuchMethodError nsmer )
             {
-                try
-                {
-                    value = ReflectionValueExtractor.evaluate( realExpr, 
project, false );
-                }
-                catch ( Exception e )
-                {
-                    Logger logger = getLogger();
-                    if ( logger.isDebugEnabled() )
-                    {
-                        logger.debug( "Assembly descriptor interpolation 
cannot proceed with expression: " + wholeExpr +
-                            ". Skipping...", e );
-                    }
-                }
+                // OK, so user is using Maven <= 2.0.8. No big deal.
             }
 
-            if ( value == null )
+            if ( userProperties != null )
             {
-                value = envars.getProperty( realExpr );
+                // 4
+                interpolator.addValueSource( new PropertiesBasedValueSource( 
userProperties ) );
             }
+        }
 
-            // if the expression refers to itself, skip it.
-            if ( wholeExpr.equals( value ) )
-            {
-                throw new AssemblyInterpolationException( wholeExpr, 
assembly.getId() + " references itself." );
-            }
+        interpolator.addValueSource( new PrefixedPropertiesValueSource(
+                                                                        
InterpolationConstants.PROJECT_PROPERTIES_PREFIXES,
+                                                                        
project.getProperties(), true ) );
+        interpolator.addValueSource( new PrefixedObjectValueSource( 
InterpolationConstants.PROJECT_PREFIXES, project,
+                                                                    true ) );
 
-            if ( value != null )
+        Properties commandLineProperties = System.getProperties();
+        try
+        {
+            if ( session != null )
             {
-                result = StringUtils.replace( result, wholeExpr, 
String.valueOf( value ) );
-                // could use:
-                // result = matcher.replaceFirst( stringValue );
-                // but this could result in multiple lookups of stringValue, 
and replaceAll is not correct behaviour
-                matcher.reset( result );
+                commandLineProperties = session.getExecutionProperties();
             }
+
+        }
+        catch ( NoSuchMethodError nsmer )
+        {
+            // OK, so user is using Maven <= 2.0.8. No big deal.
         }
-        return result;
+
+        // 7
+        interpolator.addValueSource( new PropertiesBasedValueSource( 
commandLineProperties ) );
+        interpolator.addValueSource( new PrefixedPropertiesValueSource( 
Collections.singletonList( "env." ), envars,
+                                                                        true ) 
);
+
+        return interpolator;
     }
 
     protected Logger getLogger()

Modified: 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
 (original)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
 Fri Sep 12 15:12:41 2008
@@ -367,7 +367,7 @@
 
             debugPrintAssembly( "Before assembly is interpolated:", assembly );
 
-            assembly = new AssemblyInterpolator().interpolate( assembly, 
project, context );
+            assembly = new AssemblyInterpolator().interpolate( assembly, 
project, configSource );
 
             debugPrintAssembly( "After assembly is interpolated:", assembly );
         }

Modified: 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java
 (original)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java
 Fri Sep 12 15:12:41 2008
@@ -20,9 +20,7 @@
  */
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
@@ -44,26 +42,6 @@
 public final class AssemblyFormatUtils
 {
     
-    private static final List PROJECT_PREFIXES;
-    
-    private static final List PROJECT_PROPERTIES_PREFIXES;
-    
-    static
-    {
-        List projectPrefixes = new ArrayList();
-        projectPrefixes.add( "pom." );
-        projectPrefixes.add( "project." );
-        
-        PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
-        
-        List projectPropertiesPrefixes = new ArrayList();
-        
-        projectPropertiesPrefixes.add( "pom.properties." );
-        projectPropertiesPrefixes.add( "project.properties." );
-        
-        PROJECT_PROPERTIES_PREFIXES = Collections.unmodifiableList( 
projectPropertiesPrefixes );
-    }
-
     private AssemblyFormatUtils()
     {
     }
@@ -189,10 +167,10 @@
         if ( mainProject != null )
         {
             // 5
-            interpolator.addValueSource( new PrefixedObjectValueSource( 
PROJECT_PREFIXES, mainProject, true ) );
+            interpolator.addValueSource( new PrefixedObjectValueSource( 
InterpolationConstants.PROJECT_PREFIXES, mainProject, true ) );
             
             // 6
-            interpolator.addValueSource( new PrefixedPropertiesValueSource( 
PROJECT_PROPERTIES_PREFIXES, mainProject.getProperties(), true ) );
+            interpolator.addValueSource( new PrefixedPropertiesValueSource( 
InterpolationConstants.PROJECT_PROPERTIES_PREFIXES, 
mainProject.getProperties(), true ) );
         }
 
         Properties commandLineProperties = System.getProperties();
@@ -336,7 +314,7 @@
         {
             // 3
             // 4
-            interpolator.addValueSource( new PrefixedObjectValueSource( 
PROJECT_PREFIXES, mainProject, true ) );
+            interpolator.addValueSource( new PrefixedObjectValueSource( 
InterpolationConstants.PROJECT_PREFIXES, mainProject, true ) );
         }
 
         Properties specialRules = new Properties();
@@ -380,7 +358,7 @@
         if ( mainProject != null )
         {
             // 7
-            interpolator.addValueSource( new PrefixedPropertiesValueSource( 
PROJECT_PROPERTIES_PREFIXES, mainProject.getProperties(), true ) );
+            interpolator.addValueSource( new PrefixedPropertiesValueSource( 
InterpolationConstants.PROJECT_PROPERTIES_PREFIXES, 
mainProject.getProperties(), true ) );
         }
 
         Properties commandLineProperties = System.getProperties();

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,34 @@
+package org.apache.maven.plugin.assembly.utils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public final class InterpolationConstants
+{
+    
+    public static final List PROJECT_PREFIXES;
+    
+    public static final List PROJECT_PROPERTIES_PREFIXES;
+    
+    static
+    {
+        List projectPrefixes = new ArrayList();
+        projectPrefixes.add( "pom." );
+        projectPrefixes.add( "project." );
+        
+        PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
+        
+        List projectPropertiesPrefixes = new ArrayList();
+        
+        projectPropertiesPrefixes.add( "pom.properties." );
+        projectPropertiesPrefixes.add( "project.properties." );
+        
+        PROJECT_PROPERTIES_PREFIXES = Collections.unmodifiableList( 
projectPropertiesPrefixes );
+    }
+
+    private InterpolationConstants()
+    {
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/InterpolationConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
 (original)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
 Fri Sep 12 15:12:41 2008
@@ -19,26 +19,33 @@
  * under the License.
  */
 
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Model;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
 import org.apache.maven.plugin.assembly.model.Assembly;
 import org.apache.maven.plugin.assembly.model.DependencySet;
+import org.apache.maven.plugin.assembly.testutils.ConfigSourceStub;
+import org.apache.maven.plugin.assembly.testutils.MockManager;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
 
 public class AssemblyInterpolatorTest
     extends TestCase
 {
 
     private AssemblyInterpolator interpolator;
+    
+    private AssemblerConfigurationSource configSourceStub = new 
ConfigSourceStub();
 
     public void setUp()
         throws IOException
@@ -69,7 +76,7 @@
 
         assembly.addDependencySet( set );
 
-        Assembly outputAssembly = interpolator.interpolate( assembly, project, 
Collections.EMPTY_MAP );
+        Assembly outputAssembly = interpolator.interpolate( assembly, project, 
configSourceStub );
 
         List outputDependencySets = outputAssembly.getDependencySets();
         assertEquals( 1, outputDependencySets.size() );
@@ -97,7 +104,7 @@
 
         assembly.addDependencySet( set );
 
-        Assembly outputAssembly = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.EMPTY_MAP );
+        Assembly outputAssembly = interpolator.interpolate( assembly, new 
MavenProject( model ), configSourceStub );
 
         List outputDependencySets = outputAssembly.getDependencySets();
         assertEquals( 1, outputDependencySets.size() );
@@ -120,7 +127,7 @@
 
         assembly.setId( "assembly.${groupId}" );
 
-        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.EMPTY_MAP );
+        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), configSourceStub );
 
         assertEquals( "assembly.group.id", result.getId() );
     }
@@ -143,7 +150,7 @@
 
         assembly.setId( "assembly.${groupId}" );
 
-        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.EMPTY_MAP );
+        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), configSourceStub );
 
         assertEquals( "assembly.other.id", result.getId() );
     }
@@ -165,11 +172,36 @@
         Assembly assembly = new Assembly();
 
         assembly.setId( "assembly.${groupId}" );
+        
+        MockManager mm = new MockManager();
+        
+        MockControl sessionControl = MockClassControl.createControl( 
MavenSession.class );
+        MavenSession session = (MavenSession) sessionControl.getMock();
+        
+        mm.add( sessionControl );
+        
+        Properties execProps = new Properties();
+        execProps.setProperty( "groupId", "still.another.id" );
+        
+        session.getExecutionProperties();
+        sessionControl.setReturnValue( execProps, MockControl.ZERO_OR_MORE );
+        
+        MockControl csControl = MockControl.createControl( 
AssemblerConfigurationSource.class );
+        AssemblerConfigurationSource cs = (AssemblerConfigurationSource) 
csControl.getMock();
+        
+        mm.add( csControl );
+        
+        cs.getMavenSession();
+        csControl.setReturnValue( session, MockControl.ZERO_OR_MORE );
+        
+        mm.replayAll();
 
-        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.singletonMap( "groupId",
-            "still.another.id" ) );
+        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), cs );
 
         assertEquals( "assembly.still.another.id", result.getId() );
+        
+        mm.verifyAll();
+        mm.clear();
     }
 
     public void testShouldNotTouchUnresolvedExpression()
@@ -185,7 +217,7 @@
 
         assembly.setId( "assembly.${unresolved}" );
 
-        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.EMPTY_MAP );
+        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), configSourceStub );
 
         assertEquals( "assembly.${unresolved}", result.getId() );
     }
@@ -203,9 +235,10 @@
 
         assembly.setId( "assembly.${project.build.finalName}" );
 
-        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), Collections.EMPTY_MAP );
+        Assembly result = interpolator.interpolate( assembly, new 
MavenProject( model ), configSourceStub );
 
         assertEquals( "assembly.final-name", result.getId() );
     }
+    
 
 }

Modified: 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java?rev=694818&r1=694817&r2=694818&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
 (original)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
 Fri Sep 12 15:12:41 2008
@@ -19,6 +19,20 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Model;
@@ -39,20 +53,6 @@
 import org.codehaus.plexus.util.IOUtil;
 import org.easymock.MockControl;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
 public class DefaultAssemblyReaderTest
     extends TestCase
 {
@@ -85,6 +85,9 @@
 
         configSource.getRemoteRepositories();
         configSourceControl.setReturnValue( Collections.EMPTY_LIST, 
MockControl.ZERO_OR_MORE );
+        
+        configSource.getMavenSession();
+        configSourceControl.setReturnValue( null, MockControl.ZERO_OR_MORE );
     }
 
     public void tearDown()

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java?rev=694818&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java
 Fri Sep 12 15:12:41 2008
@@ -0,0 +1,146 @@
+package org.apache.maven.plugin.assembly.testutils;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
+import org.apache.maven.project.MavenProject;
+
+public class ConfigSourceStub
+    implements AssemblerConfigurationSource
+{
+
+    public File getArchiveBaseDirectory()
+    {
+        return null;
+    }
+
+    public File getBasedir()
+    {
+        return null;
+    }
+
+    public String getClassifier()
+    {
+        return null;
+    }
+
+    public String getDescriptor()
+    {
+        return null;
+    }
+
+    public String getDescriptorId()
+    {
+        return null;
+    }
+
+    public String[] getDescriptorReferences()
+    {
+        return null;
+    }
+
+    public File getDescriptorSourceDirectory()
+    {
+        return null;
+    }
+
+    public String[] getDescriptors()
+    {
+        return null;
+    }
+
+    public List getFilters()
+    {
+        return null;
+    }
+
+    public String getFinalName()
+    {
+        return null;
+    }
+
+    public MavenArchiveConfiguration getJarArchiveConfiguration()
+    {
+        return null;
+    }
+
+    public ArtifactRepository getLocalRepository()
+    {
+        return null;
+    }
+
+    public MavenSession getMavenSession()
+    {
+        return null;
+    }
+
+    public File getOutputDirectory()
+    {
+        return null;
+    }
+
+    public MavenProject getProject()
+    {
+        return null;
+    }
+
+    public List getReactorProjects()
+    {
+        return null;
+    }
+
+    public List getRemoteRepositories()
+    {
+        return null;
+    }
+
+    public File getSiteDirectory()
+    {
+        return null;
+    }
+
+    public String getTarLongFileMode()
+    {
+        return null;
+    }
+
+    public File getTemporaryRootDirectory()
+    {
+        return null;
+    }
+
+    public File getWorkingDirectory()
+    {
+        return null;
+    }
+
+    public boolean isAssemblyIdAppended()
+    {
+        return false;
+    }
+
+    public boolean isDryRun()
+    {
+        return false;
+    }
+
+    public boolean isIgnoreDirFormatExtensions()
+    {
+        return false;
+    }
+
+    public boolean isIgnoreMissingDescriptor()
+    {
+        return false;
+    }
+
+    public boolean isSiteIncluded()
+    {
+        return false;
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/testutils/ConfigSourceStub.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to