package before assembly

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@220222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-22 00:46:15 +00:00
parent bc2211c160
commit 229118d4a1
1 changed files with 24 additions and 21 deletions

View File

@ -34,8 +34,8 @@
import org.codehaus.plexus.archiver.jar.JarArchiver; import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.tar.TarArchiver; import org.codehaus.plexus.archiver.tar.TarArchiver;
import org.codehaus.plexus.archiver.zip.ZipArchiver; import org.codehaus.plexus.archiver.zip.ZipArchiver;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -55,11 +55,13 @@
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* Assemble an application bundle or distribution.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$ * @version $Id$
* @goal assembly * @goal assembly
* @requiresDependencyResolution test * @requiresDependencyResolution test
* @description assemble an application bundle or distribution * @execute phase="package"
*/ */
public class AssemblyMojo public class AssemblyMojo
extends AbstractMojo extends AbstractMojo
@ -242,7 +244,8 @@ else if ( artifact.getFile().lastModified() > tempLocation.lastModified() )
} }
else else
{ {
archiver.addFile( artifact.getFile(), output + evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact )); archiver.addFile( artifact.getFile(), output +
evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact ) );
} }
} }
} }
@ -254,29 +257,29 @@ private String evaluateFileNameMapping( String expression, Artifact artifact )
{ {
// this matches the last ${...} string // this matches the last ${...} string
Pattern pat = Pattern.compile( "^(.*)\\$\\{([^\\}]+)\\}(.*)$" ); Pattern pat = Pattern.compile( "^(.*)\\$\\{([^\\}]+)\\}(.*)$" );
Matcher mat = pat.matcher(expression); Matcher mat = pat.matcher( expression );
String left,right; String left,right;
Object middle; Object middle;
if ( mat.matches() ) if ( mat.matches() )
{ {
left = evaluateFileNameMapping( mat.group(1), artifact ); left = evaluateFileNameMapping( mat.group( 1 ), artifact );
middle = ReflectionValueExtractor.evaluate( "dep." + mat.group(2), artifact ); middle = ReflectionValueExtractor.evaluate( "dep." + mat.group( 2 ), artifact );
right = mat.group(3); right = mat.group( 3 );
if ( middle == null ) if ( middle == null )
{ {
// TODO: There should be a more generic way dealing with that. Having magic words is not good at all. // TODO: There should be a more generic way dealing with that. Having magic words is not good at all.
// probe for magic word // probe for magic word
if ( mat.group(2).trim().equals( "extension" )) if ( mat.group( 2 ).trim().equals( "extension" ) )
{ {
ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() ); ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() );
middle = artifactHandler.getExtension(); middle = artifactHandler.getExtension();
} }
else else
{ {
middle = "${" + mat.group(2) + "}"; middle = "${" + mat.group( 2 ) + "}";
} }
} }