One way to attach this to (say) the process-resources phase is:

            <plugin>
                <groupId>org.codehaus.groovy.maven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.0-rc-3</version>
                <executions>
                    <execution>

<phase>generate-sources</phase>
                        <goals>

<goal>execute</goal>
                        </goals>
                                                <configuration>
                                                  <source>
                                                  <![CDATA[
def target = new File( "target" , "newdata" );
target.mkdirs();
def source = new File( "src/main/data" );
source.eachFile( )  { file ->
  def process = "cmd /c copy ${file} ${target}".execute();
  println "result: ${process.text}";
}
                                                  ]]>
                                                  </source>
                                                </configuration>
                    </execution>
                </executions>
            </plugin>

Of course, replace the text of the process command line by the command
of your choice, an ant exec task, or just invoke the java class directly
providing that a suitable jar is in the plugin dependency list.

Stan.

-----Original Message-----
From: janszm [mailto:me...@jansz.com]
Sent: Tuesday, May 26, 2009 9:25 AM
To: users@maven.apache.org
Subject: How to run Exec Maven plugin for each file in a directory?


I have a java program which takes an input-file and output-file as
parameters. I need to run this for a set of files in a directory.

How can I best achieve this with Maven? I have looked at the Exec Maven
plugin and as per http://mojo.codehaus.org/exec-maven-plugin/usage.html
I
can use this to run once. How do I use Maven to run this multiple times
for
all the files in a directory?

I have googled but cant find any info on how to do this, apart from some
posts about using Jelly, but this seems to be no longer supported in the
latest Maven version.

Help appreciated.

Cheers,
Menno
--
View this message in context:
http://www.nabble.com/How-to-run-Exec-Maven-plugin-for-each-file-in-a-di
rectory--tp23722927p23722927.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to