mirror of https://github.com/apache/maven.git
PR: MNG-788
bring back the "filtering" attribute in resources from m1 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@263841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ef6cc7f50
commit
7a8c848b01
|
@ -1935,7 +1935,7 @@
|
|||
</field>
|
||||
<field>
|
||||
<name>filtering</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.0+</version>
|
||||
<description><![CDATA[Boolean. Describe if resources are filtered or not.]]></description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>false</defaultValue>
|
||||
|
|
|
@ -97,40 +97,14 @@ public class ResourcesMojo
|
|||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
initializeFiltering();
|
||||
copyResources( resources, outputDirectory );
|
||||
}
|
||||
|
||||
protected void copyResources( List resources, String outputDirectory )
|
||||
throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
for ( Iterator i = getJarResources( resources ).entrySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
File source = (File) entry.getKey();
|
||||
String destination = (String) entry.getValue();
|
||||
initializeFiltering();
|
||||
|
||||
File destinationFile = new File( outputDirectory, destination );
|
||||
|
||||
if ( !destinationFile.getParentFile().exists() )
|
||||
{
|
||||
destinationFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
copyFile( source, destinationFile );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// TODO: handle exception
|
||||
throw new MojoExecutionException( "Error copying resources", e );
|
||||
}
|
||||
}
|
||||
|
||||
private Map getJarResources( List resources )
|
||||
{
|
||||
Map resourceEntries = new TreeMap();
|
||||
|
||||
for ( Iterator i = resources.iterator(); i.hasNext(); )
|
||||
|
@ -170,18 +144,32 @@ public class ResourcesMojo
|
|||
{
|
||||
String name = (String) j.next();
|
||||
|
||||
String entryName = name;
|
||||
String destination = name;
|
||||
|
||||
if ( targetPath != null )
|
||||
{
|
||||
entryName = targetPath + "/" + name;
|
||||
destination = targetPath + "/" + name;
|
||||
}
|
||||
|
||||
resourceEntries.put( new File( resource.getDirectory(), name ), entryName );
|
||||
File source = new File( resource.getDirectory(), name );
|
||||
|
||||
File destinationFile = new File( outputDirectory, destination );
|
||||
|
||||
if ( !destinationFile.getParentFile().exists() )
|
||||
{
|
||||
destinationFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
copyFile( source, destinationFile, resource.isFiltering() && filtering );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error copying resources", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resourceEntries;
|
||||
}
|
||||
|
||||
private void initializeFiltering()
|
||||
|
@ -200,7 +188,7 @@ public class ResourcesMojo
|
|||
}
|
||||
}
|
||||
|
||||
private void copyFile( File from, File to )
|
||||
private void copyFile( File from, File to, boolean filtering )
|
||||
throws IOException
|
||||
{
|
||||
if ( !filtering )
|
||||
|
|
Loading…
Reference in New Issue