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.tar.TarArchiver;
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.introspection.ReflectionValueExtractor;
import java.io.File;
import java.io.FileOutputStream;
@ -55,11 +55,13 @@
import java.util.regex.Pattern;
/**
* Assemble an application bundle or distribution.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
* @goal assembly
* @requiresDependencyResolution test
* @description assemble an application bundle or distribution
* @execute phase="package"
*/
public class AssemblyMojo
extends AbstractMojo
@ -67,10 +69,10 @@ public class AssemblyMojo
private static final String[] EMPTY_STRING_ARRAY = {};
/**
* @parameter expression="${basedir}"
* @required
* @readonly
*/
* @parameter expression="${basedir}"
* @required
* @readonly
*/
private String basedir;
/**
@ -242,7 +244,8 @@ else if ( artifact.getFile().lastModified() > tempLocation.lastModified() )
}
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
Pattern pat = Pattern.compile( "^(.*)\\$\\{([^\\}]+)\\}(.*)$" );
Matcher mat = pat.matcher(expression);
Matcher mat = pat.matcher( expression );
String left,right;
Object middle;
if ( mat.matches() )
{
left = evaluateFileNameMapping( mat.group(1), artifact );
middle = ReflectionValueExtractor.evaluate( "dep." + mat.group(2), artifact );
right = mat.group(3);
left = evaluateFileNameMapping( mat.group( 1 ), artifact );
middle = ReflectionValueExtractor.evaluate( "dep." + mat.group( 2 ), artifact );
right = mat.group( 3 );
if ( middle == null )
{
// TODO: There should be a more generic way dealing with that. Having magic words is not good at all.
// 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();
}
else
{
middle = "${" + mat.group(2) + "}";
middle = "${" + mat.group( 2 ) + "}";
}
}