title: maven calls external script on both Linux and Windows platforms
body: <p>I need to run an external script on both Linux and MS-Windows platforms.</p>
  
  <ol>
  <li>Do I use the right plugin <code>exec-maven-plugin</code>?</li>
  <li>Is there a more suitable plugin? </li>
  <li><p>What filename should I put in <code>&lt;executable&gt;....&lt;/executable&gt;</code>?</p>
  
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;compile-jni&lt;/id&gt;
              &lt;phase&gt;compile&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;exec&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;executable&gt;./compile-jni&lt;/executable&gt;
                  &lt;workingDirectory&gt;${basedir}/src/main/cpp&lt;/workingDirectory&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre></li>
  </ol>
  
  <p>I use the same <code>Makefile</code> for both platforms Linux/MS-Windows</p>
  
  <p><strong>My script <code>compile-jni.bat</code>:</strong></p>
  
  <pre><code>call "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
  bash -c "make" 
  </code></pre>
  
  <p><strong>My script <code>compile-jni.sh</code>:</strong></p>
  
  <pre><code>#!/bin/sh
  make
  </code></pre>
  
  <h2>UPDATE:</h2>
  
  <p>Two colleagues have suggested alternatives:</p>
  
  <ol>
  <li><p>Use a variable <code>script.extension</code>
  change <code>&lt;executable&gt;./compile-jni${script.extension}&lt;/executable&gt;</code> in the <code>pom.xml</code>
  and append the variable within the command line <code>mvn compile -Dscript.extention=.bat</code> </p></li>
  <li><p>or set the Visual Studio environment variables before calling maven:</p>
  
  <pre><code>call "C:\%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
  mvn compile #(the same script 'bash -c "make"' works on both platforms)
  </code></pre></li>
  </ol>
  
  <p>But on both solutions, Eclipse users may be stucked... I am still looking for an automatic and elegant solution...</p>