package org.codehaus.mojo.gwt;

/*
 * 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.
 */

import java.io.File;
import java.io.IOException;
import java.util.Collection;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.FileUtils;

/**
 * Copy GWT java source code and module descriptor as resources in the build
 * outputDirectory. Alternative to declaring a &lt;resource&gt; in the POM with finer
 * filtering as the module descriptor is read to detect sources to be copied.
 * 
 * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
 * @goal resources
 * @phase process-resources
 */
public class GwtResourcesMojo extends GwtResourcesBaseMojo {
    /**
     * @parameter expression="${project.build.outputDirectory}"
     * @required
     * @readonly
     */
    private File outputDirectory;

    /**
     * {@inheritDoc}
     * 
     * @see org.apache.maven.plugin.Mojo#execute()
     */
    public void execute() throws MojoExecutionException, MojoFailureException {
        Collection<ResourceFile> files = getAllResourceFiles();
        for (ResourceFile file : files) {
            File f = new File(file.basedir, file.fileRelativeName);
            File target = new File(outputDirectory, file.fileRelativeName);
            try {
                getLog().debug("copy " + f + " to outputDirectory");
                if (!target.getParentFile().mkdirs()) {
                    throw new MojoExecutionException("Failed to create destination directory " + target.getParentFile());
                }
                FileUtils.copyFile(f, target);
            } catch (IOException e) {
                throw new MojoExecutionException("Failed to copy GWT source " + f, e);
            }
        }
    }
}
@@ -1461,16 +1461,20 @@
 rcesMojo
+%0A   
  extends
@@ -1494,17 +1494,17 @@
 BaseMojo
- 
+%0A
 %7B%0A    /*
@@ -1767,16 +1767,24 @@
 xecute()
+%0A       
  throws 
@@ -1827,16 +1827,20 @@
 xception
+%0A   
  %7B%0A     
@@ -1911,16 +1911,17 @@
    for (
+ 
 Resource
@@ -1937,17 +1937,26 @@
  : files
-)
+ )%0A       
  %7B%0A     
@@ -1980,16 +1980,17 @@
 ew File(
+ 
 file.bas
@@ -2008,32 +2008,33 @@
 fileRelativeName
+ 
 );%0A            F
@@ -2055,16 +2055,17 @@
 ew File(
+ 
 outputDi
@@ -2094,16 +2094,17 @@
 tiveName
+ 
 );%0A     
@@ -2113,16 +2113,28 @@
      try
+%0A           
  %7B%0A     
@@ -2159,16 +2159,17 @@
 ).debug(
+ 
 %22copy %22 
@@ -2195,16 +2195,17 @@
 rectory%22
+ 
 );%0A     
@@ -2219,16 +2219,17 @@
     if (
+ 
 !target.
@@ -2252,17 +2252,34 @@
 mkdirs()
-)
+ )%0A               
  %7B%0A     
@@ -2318,32 +2318,33 @@
 cutionException(
+ 
 %22Failed to creat
@@ -2368,16 +2368,40 @@
 ectory %22
+%0A                       
  + targe
@@ -2417,16 +2417,17 @@
 ntFile()
+ 
 );%0A     
@@ -2474,16 +2474,17 @@
 opyFile(
+ 
 f, targe
@@ -2484,16 +2484,17 @@
 , target
+ 
 );%0A     
@@ -2505,16 +2505,28 @@
    %7D
+%0A           
  catch (
 IOEx
@@ -2521,16 +2521,17 @@
  catch (
+ 
 IOExcept
@@ -2535,17 +2535,30 @@
 eption e
-)
+ )%0A           
  %7B%0A     
@@ -2601,16 +2601,17 @@
 ception(
+ 
 %22Failed 
@@ -2637,16 +2637,17 @@
 %22 + f, e
+ 
 );%0A     

format code : no change !