mirror of https://github.com/apache/maven.git
Resolving: MNG-163
Use MavenProject.addResource(..) and .addTestResource(..) to perform this function. I've built a BuildOverlay to insulate the interpolated, initialized Model's Build instance from runtime changes to these, in a similar fashion to addCompileSourceRoots(..), because I wanted to preserve some compat with plugins using ${project.build.resources}. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@230920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
daba7dca27
commit
09ebb0f615
|
@ -62,7 +62,7 @@ public class ResourcesMojo
|
|||
/**
|
||||
* The list of resources we want to transfer.
|
||||
*
|
||||
* @parameter expression="${project.build.resources}"
|
||||
* @parameter expression="${project.resources}"
|
||||
* @required
|
||||
*/
|
||||
private List resources;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TestResourcesMojo
|
|||
/**
|
||||
* The list of resources we want to transfer.
|
||||
*
|
||||
* @parameter expression="${project.build.testResources}"
|
||||
* @parameter expression="${project.testResources}"
|
||||
* @required
|
||||
*/
|
||||
private List resources;
|
||||
|
|
|
@ -43,9 +43,11 @@ import org.apache.maven.model.Prerequesites;
|
|||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.overlay.BuildOverlay;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -132,6 +134,8 @@ public class MavenProject
|
|||
|
||||
private Map projectReferences = new HashMap();
|
||||
|
||||
private Build buildOverlay;
|
||||
|
||||
public MavenProject( Model model )
|
||||
{
|
||||
this.model = model;
|
||||
|
@ -798,12 +802,39 @@ public class MavenProject
|
|||
|
||||
public void setBuild( Build build )
|
||||
{
|
||||
this.buildOverlay = new BuildOverlay( build );
|
||||
|
||||
model.setBuild( build );
|
||||
}
|
||||
|
||||
public Build getBuild()
|
||||
{
|
||||
return model.getBuild();
|
||||
if ( buildOverlay == null )
|
||||
{
|
||||
buildOverlay = new BuildOverlay( model.getBuild() );
|
||||
}
|
||||
|
||||
return buildOverlay;
|
||||
}
|
||||
|
||||
public List getResources()
|
||||
{
|
||||
return getBuild().getResources();
|
||||
}
|
||||
|
||||
public List getTestResources()
|
||||
{
|
||||
return getBuild().getTestResources();
|
||||
}
|
||||
|
||||
public void addResource( Resource resource )
|
||||
{
|
||||
getBuild().addResource( resource );
|
||||
}
|
||||
|
||||
public void addTestResource( Resource testResource )
|
||||
{
|
||||
getBuild().addTestResource( testResource );
|
||||
}
|
||||
|
||||
public void setReporting( Reporting reporting )
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
package org.apache.maven.project.overlay;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.Resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BuildOverlay
|
||||
extends Build
|
||||
{
|
||||
|
||||
private final Build build;
|
||||
|
||||
private List resources;
|
||||
private List testResources;
|
||||
|
||||
public BuildOverlay( Build build )
|
||||
{
|
||||
if ( build == null )
|
||||
{
|
||||
this.build = new Build();
|
||||
|
||||
this.resources = new ArrayList();
|
||||
|
||||
this.testResources = new ArrayList();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.build = build;
|
||||
|
||||
this.resources = new ArrayList( build.getResources() );
|
||||
|
||||
this.testResources = new ArrayList( build.getTestResources() );
|
||||
}
|
||||
}
|
||||
|
||||
public void addExtension( Extension extension )
|
||||
{
|
||||
build.addExtension( extension );
|
||||
}
|
||||
|
||||
public void addPlugin( Plugin plugin )
|
||||
{
|
||||
build.addPlugin( plugin );
|
||||
}
|
||||
|
||||
public void addResource( Resource resource )
|
||||
{
|
||||
resources.add( resource );
|
||||
}
|
||||
|
||||
public void addTestResource( Resource resource )
|
||||
{
|
||||
testResources.add( resource );
|
||||
}
|
||||
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
return build.equals( obj );
|
||||
}
|
||||
|
||||
public void flushPluginMap()
|
||||
{
|
||||
build.flushPluginMap();
|
||||
}
|
||||
|
||||
public String getDefaultGoal()
|
||||
{
|
||||
return build.getDefaultGoal();
|
||||
}
|
||||
|
||||
public String getDirectory()
|
||||
{
|
||||
return build.getDirectory();
|
||||
}
|
||||
|
||||
public List getExtensions()
|
||||
{
|
||||
return build.getExtensions();
|
||||
}
|
||||
|
||||
public String getFinalName()
|
||||
{
|
||||
return build.getFinalName();
|
||||
}
|
||||
|
||||
public String getOutputDirectory()
|
||||
{
|
||||
return build.getOutputDirectory();
|
||||
}
|
||||
|
||||
public PluginManagement getPluginManagement()
|
||||
{
|
||||
return build.getPluginManagement();
|
||||
}
|
||||
|
||||
public List getPlugins()
|
||||
{
|
||||
return build.getPlugins();
|
||||
}
|
||||
|
||||
public Map getPluginsAsMap()
|
||||
{
|
||||
return build.getPluginsAsMap();
|
||||
}
|
||||
|
||||
public List getResources()
|
||||
{
|
||||
return resources;
|
||||
}
|
||||
|
||||
public String getScriptSourceDirectory()
|
||||
{
|
||||
return build.getScriptSourceDirectory();
|
||||
}
|
||||
|
||||
public String getSourceDirectory()
|
||||
{
|
||||
return build.getSourceDirectory();
|
||||
}
|
||||
|
||||
public String getTestOutputDirectory()
|
||||
{
|
||||
return build.getTestOutputDirectory();
|
||||
}
|
||||
|
||||
public List getTestResources()
|
||||
{
|
||||
return testResources;
|
||||
}
|
||||
|
||||
public String getTestSourceDirectory()
|
||||
{
|
||||
return build.getTestSourceDirectory();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return build.hashCode();
|
||||
}
|
||||
|
||||
public void removeExtension( Extension extension )
|
||||
{
|
||||
build.removeExtension( extension );
|
||||
}
|
||||
|
||||
public void removePlugin( Plugin plugin )
|
||||
{
|
||||
build.removePlugin( plugin );
|
||||
}
|
||||
|
||||
public void removeResource( Resource resource )
|
||||
{
|
||||
resources.remove( resource );
|
||||
}
|
||||
|
||||
public void removeTestResource( Resource resource )
|
||||
{
|
||||
testResources.remove( resource );
|
||||
}
|
||||
|
||||
public void setDefaultGoal( String defaultGoal )
|
||||
{
|
||||
build.setDefaultGoal( defaultGoal );
|
||||
}
|
||||
|
||||
public void setDirectory( String directory )
|
||||
{
|
||||
build.setDirectory( directory );
|
||||
}
|
||||
|
||||
public void setExtensions( List extensions )
|
||||
{
|
||||
build.setExtensions( extensions );
|
||||
}
|
||||
|
||||
public void setFinalName( String finalName )
|
||||
{
|
||||
build.setFinalName( finalName );
|
||||
}
|
||||
|
||||
public void setOutputDirectory( String outputDirectory )
|
||||
{
|
||||
build.setOutputDirectory( outputDirectory );
|
||||
}
|
||||
|
||||
public void setPluginManagement( PluginManagement pluginManagement )
|
||||
{
|
||||
build.setPluginManagement( pluginManagement );
|
||||
}
|
||||
|
||||
public void setPlugins( List plugins )
|
||||
{
|
||||
build.setPlugins( plugins );
|
||||
}
|
||||
|
||||
public void setResources( List resources )
|
||||
{
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
public void setScriptSourceDirectory( String scriptSourceDirectory )
|
||||
{
|
||||
build.setScriptSourceDirectory( scriptSourceDirectory );
|
||||
}
|
||||
|
||||
public void setSourceDirectory( String sourceDirectory )
|
||||
{
|
||||
build.setSourceDirectory( sourceDirectory );
|
||||
}
|
||||
|
||||
public void setTestOutputDirectory( String testOutputDirectory )
|
||||
{
|
||||
build.setTestOutputDirectory( testOutputDirectory );
|
||||
}
|
||||
|
||||
public void setTestResources( List testResources )
|
||||
{
|
||||
this.testResources = testResources;
|
||||
}
|
||||
|
||||
public void setTestSourceDirectory( String testSourceDirectory )
|
||||
{
|
||||
build.setTestSourceDirectory( testSourceDirectory );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue