From d0de5773b3f97a69319d15d775c118b048b5c0ec Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 22 Mar 2005 13:33:29 +0000 Subject: [PATCH] convert resources mojo to new execute(). git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163661 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/resources/ResourcesMojo.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java b/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java index cb6f5d846b..5079b763b3 100644 --- a/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java +++ b/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java @@ -19,8 +19,7 @@ import org.apache.maven.model.Resource; import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.plugin.PluginExecutionRequest; -import org.apache.maven.plugin.PluginExecutionResponse; +import org.apache.maven.plugin.PluginExecutionException; import org.codehaus.plexus.util.FileUtils; import java.io.ByteArrayOutputStream; @@ -54,33 +53,33 @@ public class ResourcesMojo extends AbstractPlugin { - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) - throws Exception + private String outputDirectory; + + private List resources; + + public void execute() + throws PluginExecutionException { - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - String outputDirectory = (String) request.getParameter( "outputDirectory" ); - - List resources = (List) request.getParameter( "resources" ); - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - for ( Iterator i = getJarResources( resources ).iterator(); i.hasNext(); ) + try { - ResourceEntry resourceEntry = (ResourceEntry) i.next(); - - File destinationFile = new File( outputDirectory, resourceEntry.getDestination() ); - - if ( !destinationFile.getParentFile().exists() ) + for ( Iterator i = getJarResources( resources ).iterator(); i.hasNext(); ) { - destinationFile.getParentFile().mkdirs(); - } + ResourceEntry resourceEntry = (ResourceEntry) i.next(); - fileCopy( resourceEntry.getSource(), destinationFile.getPath() ); + File destinationFile = new File( outputDirectory, resourceEntry.getDestination() ); + + if ( !destinationFile.getParentFile().exists() ) + { + destinationFile.getParentFile().mkdirs(); + } + + fileCopy( resourceEntry.getSource(), destinationFile.getPath() ); + } + } + catch ( Exception e ) + { + // TODO: handle exception + throw new PluginExecutionException( "Error copying resources", e ); } }