You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Tawfik, Sameh E" <Sa...@fairisaac.com> on 2008/03/12 01:45:41 UTC

How to run a script from a pom.xml file?

How to run a perl or batch file at the beginning of the build? 

Is there is a command or a plugin I can use to run an external process
then come back to the build when this process is complete?

I'm using:

Maven version: 2.0.7
Java version: 1.6.0_02-ea
OS name: "windows xp" version: "5.1" arch: "x86"

 Thanks,

   Sameh
This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


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


RE: How to run a script from a pom.xml file?

Posted by "Tawfik, Sameh E" <Sa...@fairisaac.com>.
Thanks Olivier.

  Sameh

-----Original Message-----
From: Olivier Dehon [mailto:odndev@gmail.com] 
Sent: Tuesday, March 11, 2008 6:03 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

Look for the exec plugin.

-Olivier

On Tue, 2008-03-11 at 19:45 -0500, Tawfik, Sameh E wrote:
> How to run a perl or batch file at the beginning of the build? 
> 
> Is there is a command or a plugin I can use to run an external process
> then come back to the build when this process is complete?
> 
> I'm using:
> 
> Maven version: 2.0.7
> Java version: 1.6.0_02-ea
> OS name: "windows xp" version: "5.1" arch: "x86"
> 
>  Thanks,
> 
>    Sameh
> This email and any files transmitted with it are confidential,
proprietary
> and intended solely for the individual or entity to whom they are
addressed.
> If you have received this email in error please delete it immediately.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


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


RE: How to run a script from a pom.xml file?

Posted by "Tawfik, Sameh E" <Sa...@fairisaac.com>.
Brian,

Thanks again, using the -N worked.

  Sameh


-----Original Message-----
From: Brian E. Fox [mailto:brianf@reply.infinity.nu] 
Sent: Thursday, March 13, 2008 3:50 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?

Are you running this from the command line? If so, then the inherited
might not apply...that's usually for inheriting the bound config. You
will want to add -N to your command line to tell maven not to recurse.

-----Original Message-----
From: Tawfik, Sameh E [mailto:SamehTawfik@fairisaac.com] 
Sent: Thursday, March 13, 2008 4:19 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?







I specified the inherited element in different places in the plugin body
in the parent pom.xml, but no matter where I set it, it is still running
more than once! It is running for all the children modules? 

Should not setting the inherited element to false suppress Maven from
passing this execution onto its children?

Here are some of the variations I tried:

(1)
            <plugin>
		    <inherited>false</inherited>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>

(2)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
		    <inherited>false</inherited>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(3)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <inherited>false</inherited>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(4)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
		      <inherited>false</inherited>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>


-----Original Message-----
From: Brian E. Fox [mailto:brianf@reply.infinity.nu] 
Sent: Wednesday, March 12, 2008 5:02 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?

Fyi, the inherited in the execution block does not work, but it does
work in the plugin block.

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com] 
Sent: Wednesday, March 12, 2008 7:55 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

On Wed, Mar 12, 2008 at 4:25 PM, Tawfik, Sameh E
<Sa...@fairisaac.com> wrote:

>  I tried the exe plugin and it did what I was looking for, but I
noticed
>  it repeated the execution few times and not just one time as needed!
...
>  Is there is a way where I can restrict the execution of this exe to
just
>  one time?

To have it run just once for the parent, use:
<inherited>false</inherited>

 * http://maven.apache.org/ref/2.0.8/maven-model/maven.html

(You should also add an <id> for the execution.)

-- 
Wendy

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


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

This email and any files transmitted with it are confidential,
proprietary
and intended solely for the individual or entity to whom they are
addressed.
If you have received this email in error please delete it immediately.



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


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

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


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


RE: How to run a script from a pom.xml file?

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Are you running this from the command line? If so, then the inherited
might not apply...that's usually for inheriting the bound config. You
will want to add -N to your command line to tell maven not to recurse.

-----Original Message-----
From: Tawfik, Sameh E [mailto:SamehTawfik@fairisaac.com] 
Sent: Thursday, March 13, 2008 4:19 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?







I specified the inherited element in different places in the plugin body
in the parent pom.xml, but no matter where I set it, it is still running
more than once! It is running for all the children modules? 

Should not setting the inherited element to false suppress Maven from
passing this execution onto its children?

Here are some of the variations I tried:

(1)
            <plugin>
		    <inherited>false</inherited>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>

(2)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
		    <inherited>false</inherited>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(3)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <inherited>false</inherited>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(4)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
		      <inherited>false</inherited>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>


-----Original Message-----
From: Brian E. Fox [mailto:brianf@reply.infinity.nu] 
Sent: Wednesday, March 12, 2008 5:02 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?

Fyi, the inherited in the execution block does not work, but it does
work in the plugin block.

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com] 
Sent: Wednesday, March 12, 2008 7:55 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

On Wed, Mar 12, 2008 at 4:25 PM, Tawfik, Sameh E
<Sa...@fairisaac.com> wrote:

>  I tried the exe plugin and it did what I was looking for, but I
noticed
>  it repeated the execution few times and not just one time as needed!
...
>  Is there is a way where I can restrict the execution of this exe to
just
>  one time?

To have it run just once for the parent, use:
<inherited>false</inherited>

 * http://maven.apache.org/ref/2.0.8/maven-model/maven.html

(You should also add an <id> for the execution.)

-- 
Wendy

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


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

This email and any files transmitted with it are confidential,
proprietary
and intended solely for the individual or entity to whom they are
addressed.
If you have received this email in error please delete it immediately.



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


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


RE: How to run a script from a pom.xml file?

Posted by "Tawfik, Sameh E" <Sa...@fairisaac.com>.





I specified the inherited element in different places in the plugin body
in the parent pom.xml, but no matter where I set it, it is still running
more than once! It is running for all the children modules? 

Should not setting the inherited element to false suppress Maven from
passing this execution onto its children?

Here are some of the variations I tried:

(1)
            <plugin>
		    <inherited>false</inherited>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>

(2)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
		    <inherited>false</inherited>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(3)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <inherited>false</inherited>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>
(4)

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
		      <inherited>false</inherited>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin>


-----Original Message-----
From: Brian E. Fox [mailto:brianf@reply.infinity.nu] 
Sent: Wednesday, March 12, 2008 5:02 PM
To: Maven Users List
Subject: RE: How to run a script from a pom.xml file?

Fyi, the inherited in the execution block does not work, but it does
work in the plugin block.

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com] 
Sent: Wednesday, March 12, 2008 7:55 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

On Wed, Mar 12, 2008 at 4:25 PM, Tawfik, Sameh E
<Sa...@fairisaac.com> wrote:

>  I tried the exe plugin and it did what I was looking for, but I
noticed
>  it repeated the execution few times and not just one time as needed!
...
>  Is there is a way where I can restrict the execution of this exe to
just
>  one time?

To have it run just once for the parent, use:
<inherited>false</inherited>

 * http://maven.apache.org/ref/2.0.8/maven-model/maven.html

(You should also add an <id> for the execution.)

-- 
Wendy

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


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

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


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


RE: How to run a script from a pom.xml file?

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Fyi, the inherited in the execution block does not work, but it does
work in the plugin block.

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com] 
Sent: Wednesday, March 12, 2008 7:55 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

On Wed, Mar 12, 2008 at 4:25 PM, Tawfik, Sameh E
<Sa...@fairisaac.com> wrote:

>  I tried the exe plugin and it did what I was looking for, but I
noticed
>  it repeated the execution few times and not just one time as needed!
...
>  Is there is a way where I can restrict the execution of this exe to
just
>  one time?

To have it run just once for the parent, use:
<inherited>false</inherited>

 * http://maven.apache.org/ref/2.0.8/maven-model/maven.html

(You should also add an <id> for the execution.)

-- 
Wendy

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


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


Re: How to run a script from a pom.xml file?

Posted by Wendy Smoak <ws...@gmail.com>.
On Wed, Mar 12, 2008 at 4:25 PM, Tawfik, Sameh E
<Sa...@fairisaac.com> wrote:

>  I tried the exe plugin and it did what I was looking for, but I noticed
>  it repeated the execution few times and not just one time as needed!
...
>  Is there is a way where I can restrict the execution of this exe to just
>  one time?

To have it run just once for the parent, use:  <inherited>false</inherited>

 * http://maven.apache.org/ref/2.0.8/maven-model/maven.html

(You should also add an <id> for the execution.)

-- 
Wendy

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


RE: How to run a script from a pom.xml file?

Posted by "Tawfik, Sameh E" <Sa...@fairisaac.com>.
Thanks Wayne.

I tried the exe plugin and it did what I was looking for, but I noticed
it repeated the execution few times and not just one time as needed! 

I've a Maven project that consists of a number of Maven modules, and I
put the following code in the <build> block of the Parent pom.xml:

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <executable>Process_Files.cmd</executable>
              </configuration>
            </plugin> 

To execute the above code, I run the following command from a DOS
window:

mvn exec:exec -Dexec.executable="Process_Files.cmd"

So, it run this file a number of times equal the number of the Maven
modules specified in the parent pom.xml file.

Is there is a way where I can restrict the execution of this exe to just
one time?

   Thanks,

      Sameh

-----Original Message-----
From: Wayne Fay [mailto:waynefay@gmail.com] 
Sent: Tuesday, March 11, 2008 10:00 PM
To: Maven Users List
Subject: Re: How to run a script from a pom.xml file?

Alternatively, if you're on Windows, you can add a file
mavenrc_pre.bat and mavenrc_post.bat to your user home directory and
Maven will run them before/after running the Maven build process.

But this runs for all builds (not just a specific project) and
requires that you distribute these batch/shell script files to every
developer and every server where you are executing Maven, so it is far
from ideal.

Yet another option is to modify the mvn.bat or mvn files themselves.
This also requires you to distribute the modified shell script.

The exec plugin, as previously mentioned, is a good option as well.
Assuming the binaries are the same on all your platforms (or you can
tweak with profiles) and you figure out which phase you want to invoke
it in, it should work.

What you choose really depends on what you're trying to do and why.
More details about your specific use case might produce better
comments.

Wayne

On 3/11/08, Olivier Dehon <od...@gmail.com> wrote:
> Look for the exec plugin.
>
> -Olivier
>
> On Tue, 2008-03-11 at 19:45 -0500, Tawfik, Sameh E wrote:
> > How to run a perl or batch file at the beginning of the build?
> >
> > Is there is a command or a plugin I can use to run an external
process
> > then come back to the build when this process is complete?
> >
> > I'm using:
> >
> > Maven version: 2.0.7
> > Java version: 1.6.0_02-ea
> > OS name: "windows xp" version: "5.1" arch: "x86"
> >
> >  Thanks,
> >
> >    Sameh
> > This email and any files transmitted with it are confidential,
proprietary
> > and intended solely for the individual or entity to whom they are
addressed.
> > If you have received this email in error please delete it
immediately.
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


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


Re: How to run a script from a pom.xml file?

Posted by Wayne Fay <wa...@gmail.com>.
Alternatively, if you're on Windows, you can add a file
mavenrc_pre.bat and mavenrc_post.bat to your user home directory and
Maven will run them before/after running the Maven build process.

But this runs for all builds (not just a specific project) and
requires that you distribute these batch/shell script files to every
developer and every server where you are executing Maven, so it is far
from ideal.

Yet another option is to modify the mvn.bat or mvn files themselves.
This also requires you to distribute the modified shell script.

The exec plugin, as previously mentioned, is a good option as well.
Assuming the binaries are the same on all your platforms (or you can
tweak with profiles) and you figure out which phase you want to invoke
it in, it should work.

What you choose really depends on what you're trying to do and why.
More details about your specific use case might produce better
comments.

Wayne

On 3/11/08, Olivier Dehon <od...@gmail.com> wrote:
> Look for the exec plugin.
>
> -Olivier
>
> On Tue, 2008-03-11 at 19:45 -0500, Tawfik, Sameh E wrote:
> > How to run a perl or batch file at the beginning of the build?
> >
> > Is there is a command or a plugin I can use to run an external process
> > then come back to the build when this process is complete?
> >
> > I'm using:
> >
> > Maven version: 2.0.7
> > Java version: 1.6.0_02-ea
> > OS name: "windows xp" version: "5.1" arch: "x86"
> >
> >  Thanks,
> >
> >    Sameh
> > This email and any files transmitted with it are confidential, proprietary
> > and intended solely for the individual or entity to whom they are addressed.
> > If you have received this email in error please delete it immediately.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: How to run a script from a pom.xml file?

Posted by Olivier Dehon <od...@gmail.com>.
Look for the exec plugin.

-Olivier

On Tue, 2008-03-11 at 19:45 -0500, Tawfik, Sameh E wrote:
> How to run a perl or batch file at the beginning of the build? 
> 
> Is there is a command or a plugin I can use to run an external process
> then come back to the build when this process is complete?
> 
> I'm using:
> 
> Maven version: 2.0.7
> Java version: 1.6.0_02-ea
> OS name: "windows xp" version: "5.1" arch: "x86"
> 
>  Thanks,
> 
>    Sameh
> This email and any files transmitted with it are confidential, proprietary
> and intended solely for the individual or entity to whom they are addressed.
> If you have received this email in error please delete it immediately.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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