Author: olamy
Date: Fri Sep 12 14:36:44 2008
New Revision: 694813

URL: http://svn.apache.org/viewvc?rev=694813&view=rev
Log:
[MRESOURCES-8] maven-resources-plugin ignores configuration/resources property 
(add a new mojo to copy resources)


Added:
    
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
   (with props)
    
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
   (with props)
    maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
   (with props)
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filtered-files/
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/
    
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
   (with props)
Modified:
    
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java

Added: 
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java?rev=694813&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
 (added)
+++ 
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
 Fri Sep 12 14:36:44 2008
@@ -0,0 +1,82 @@
+package org.apache.maven.plugin.resources;
+
+import java.io.File;
+import java.util.List;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">olamy</a>
+ * @since 2.3
+ * @version $Id$
+ * @goal copy-resources
+ */
+public class CopyResourcesMojo
+    extends ResourcesMojo
+{
+    
+    /**
+     * The output directory into which to copy the resources.
+     *
+     * @parameter 
+     * @required
+     */
+    private File outputDirectory;
+
+    /**
+     * The list of resources we want to transfer.
+     *
+     * @parameter 
+     * @required
+     */
+    private List resources;
+
+
+    public File getOutputDirectory()
+    {
+        return outputDirectory;
+    }
+
+    public void setOutputDirectory( File outputDirectory )
+    {
+        this.outputDirectory = outputDirectory;
+    }
+
+    public List getResources()
+    {
+        return resources;
+    }
+
+    public void setResources( List resources )
+    {
+        this.resources = resources;
+    }
+
+    public List getFilters()
+    {
+        return filters;
+    }
+
+    public void setFilters( List filters )
+    {
+        this.filters = filters;
+    }    
+
+}

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/CopyResourcesMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Revision Id

Added: 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java?rev=694813&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
 (added)
+++ 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
 Fri Sep 12 14:36:44 2008
@@ -0,0 +1,79 @@
+package org.apache.maven.plugin.resources;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">olamy</a>
+ * @version $Id$
+ */
+public class CopyResourcesMojoTest
+    extends AbstractMojoTestCase
+{
+
+    protected final static String defaultPomFilePath = 
"/target/test-classes/unit/resources-test/plugin-config.xml";
+
+    File outputDirectory = new File( getBasedir(), 
"/target/copyResourcesTests" );
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        if ( !outputDirectory.exists() )
+        {
+            outputDirectory.mkdirs();
+        }
+        else
+        {
+            FileUtils.cleanDirectory( outputDirectory );
+        }
+    }
+
+    public void testCopyWithoutFiltering()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), defaultPomFilePath );
+        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom 
);
+
+        mojo.setOutputDirectory( outputDirectory );
+
+        Resource resource = new Resource();
+        resource.setDirectory( getBasedir() + 
"/src/test/unit-files/copy-resources-test/no-filter" );
+        resource.setFiltering( false );
+
+        mojo.setResources( Collections.singletonList( resource ) );
+
+        MavenProjectResourcesStub project = new MavenProjectResourcesStub( 
"CopyResourcesMojoTest" );
+        File targetFile =  new File( getBasedir(), 
"/target/copyResourcesTests" );
+        project.setBaseDir( targetFile );
+        setVariableValueToObject( mojo, "project", project );
+        mojo.execute();
+
+        assertTrue( new File( targetFile, "config.properties" ).exists() );
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/CopyResourcesMojoTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Revision Id

Modified: 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java?rev=694813&r1=694812&r2=694813&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java
 (original)
+++ 
maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectResourcesStub.java
 Fri Sep 12 14:36:44 2008
@@ -19,11 +19,15 @@
  * under the License.
  */
 
+import java.io.File;
+
 import org.apache.maven.model.Resource;
 
 public class MavenProjectResourcesStub
     extends MavenProjectBuildStub
 {
+    
+    private File baseDir;
 
     public MavenProjectResourcesStub( String id )
         throws Exception
@@ -108,4 +112,14 @@
         resource.setTargetPath( null );
         build.addTestResource( resource );
     }
+
+    public File getBaseDir()
+    {
+        return baseDir == null ? super.getBasedir() : baseDir;
+    }
+
+    public void setBaseDir( File baseDir )
+    {
+        this.baseDir = baseDir;
+    }
 }

Added: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt?rev=694813&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
 (added)
+++ 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
 Fri Sep 12 14:36:44 2008
@@ -0,0 +1 @@
+foo=bar
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/filter-files/filter.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties?rev=694813&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
 (added)
+++ 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
 Fri Sep 12 14:36:44 2008
@@ -0,0 +1 @@
+config=zorglub
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-resources-plugin/src/test/unit-files/copy-resources-test/no-filter/config.properties
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to