mirror of https://github.com/apache/maven.git
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:
parent
bc2211c160
commit
229118d4a1
|
@ -34,8 +34,8 @@ import org.codehaus.plexus.archiver.ArchiverException;
|
||||||
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.Matcher;
|
||||||
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
|
||||||
|
@ -67,10 +69,10 @@ public class AssemblyMojo
|
||||||
private static final String[] EMPTY_STRING_ARRAY = {};
|
private static final String[] EMPTY_STRING_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${basedir}"
|
* @parameter expression="${basedir}"
|
||||||
* @required
|
* @required
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
private String basedir;
|
private String basedir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,9 +103,9 @@ public class AssemblyMojo
|
||||||
*/
|
*/
|
||||||
private Set dependencies;
|
private Set dependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory to unpack JARs into if needed
|
* Directory to unpack JARs into if needed
|
||||||
*
|
*
|
||||||
* @parameter expression="${project.build.directory}/assembly/work"
|
* @parameter expression="${project.build.directory}/assembly/work"
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
|
@ -116,7 +118,7 @@ public class AssemblyMojo
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
private ArtifactHandlerManager artifactHandlerManager;
|
private ArtifactHandlerManager artifactHandlerManager;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
@ -242,44 +244,45 @@ public class AssemblyMojo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
archiver.addFile( artifact.getFile(), output + evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact ));
|
archiver.addFile( artifact.getFile(), output +
|
||||||
}
|
evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String evaluateFileNameMapping( String expression, Artifact artifact )
|
private String evaluateFileNameMapping( String expression, Artifact artifact )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// 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 ) + "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return left + middle + right;
|
return left + middle + right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue