You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sathyanarayanan Nagarajan <sa...@gmail.com> on 2009/02/11 00:12:56 UTC

How can i execute multiple shell command in maven

Hi,

I have a reqmt to execute start, stop tomcat through its shell script. How
can i do this in maven? In Ant, we have exec command and i can configure
targets for stop and start.I read through the usage of  Exec maven plugin
and configured this

        <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>startup.bat</executable>
          <!-- optional -->
          <workingDirectory>D:\apache-tomcat-6.0.16\bin</workingDirectory>
          <arguments/>
        </configuration>

While i'm able to do a tomcat start, i'm not sure how i can do a tomcat stop
as the xml configuration doesn't seem to support multile exec commands.

Rgds,
Sathya

Re: How can i execute multiple shell command in maven

Posted by "David C. Hicks" <dh...@i-hicks.org>.
I can't imagine why it would matter if you start and stop Tomcat through 
its own shell script.  If you're doing so for integration testing 
purposes, you're probably better off using the Cargo plugin to wrap the 
Tomcat container.

However, you can probably configure the Exec plugin to do what you want 
to do by binding the executions to a couple of different phases in the 
build lifecycle.  For instance:

<executions>
   <execution>
      <id>startTomcat</id>
      <phase>pre-integration-test</phase>
      <goals>
         <goal>exec</exec>
      </goals>
      <configuration>
         <executable>startup.bat</executable>
         ...
      </configuration>
   </execution>
   <execution>
      <id>stopTomcat</id>
      <phase>post-integration-test</phase>
      <goals>
         <goal>exec</exec>
      </goals>
      <configuration>
         <executable>shutdown.bat</executable>
         ...
      </configuration>
   </execution>
</executions>

One really good reason to avoid using the method you're trying to use is 
that it's not portable.  Try to execute that on any Unix system, and 
it's going to choke all over itself - unless you start modifying the 
names of the Tomcat execution scripts.  You're also depending on the 
scripts to be on the execution path, which is a dangerous assumption.

Good luck!
Dave


Sathyanarayanan Nagarajan wrote:
> Hi,
>
> I have a reqmt to execute start, stop tomcat through its shell script. How
> can i do this in maven? In Ant, we have exec command and i can configure
> targets for stop and start.I read through the usage of  Exec maven plugin
> and configured this
>
>         <execution>
>             <goals>
>               <goal>exec</goal>
>             </goals>
>           </execution>
>         </executions>
>         <configuration>
>           <executable>startup.bat</executable>
>           <!-- optional -->
>           <workingDirectory>D:\apache-tomcat-6.0.16\bin</workingDirectory>
>           <arguments/>
>         </configuration>
>
> While i'm able to do a tomcat start, i'm not sure how i can do a tomcat stop
> as the xml configuration doesn't seem to support multile exec commands.
>
> Rgds,
> Sathya
>
>   

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