How to do input task in maven antrun plugin

a 夏天 提交于 2019-12-05 21:50:14

EITHER

Set environment variable ANT_HOME, add a property to you Maven: <property name="ant.home" value="${env.ANT_HOME}" /> and add a parameter vmlauncher="true" to your Ant Exec part.

OR

Exec ksh instead of script name with a script as a parameter. I mean:

<exec dir="${project.basedir}" executable="ksh" failonerror="true">
<arg value="${project.basedir}/livraison/outils/0_init_livraison.ksh">
</exec>

I tried to use Exec ksh instead of script name with a script as a parameterthose but it didn't work. I tried to set ANT_HOME variable but it didn't work.

But i changed my way of thinking : Having a build that depends on the console is extremely problematic, most integration tools around Maven will not work with it because they assume autonomous runs. This kind of maven project would encounter problems with Jenkins , Netbeans,... They cannot wait for manual answer.

The best way is to set an option and run a command with a parameter :

mvn clean packge -Dforcer=oui or mvn release:prepare -Darguments=-Dforcer=oui

Here a part of my pom.xml :

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.8</version>
  <executions>
    <execution>
      <id>initialisation</id>
      <phase>initialize</phase>
      <configuration>
        <tasks>
          <exec executable="${outilsLivraison}/0_init_livraison.ksh" failonerror="false" resultproperty="codeRetour">
            <redirector errorproperty="message.redirector.err" />
          </exec>
          <fail message=" ARRET DE LA PROCEDURE ! VOUS POUVEZ FORCER LA PROCEDURE AVEC '-Dforcer=oui' (ou '-Darguments=-Dforcer=oui' pour une release).">
            <condition>
              <and>
                <equals arg1="${message.redirector.err}" arg2="warning" />
                <not><equals arg1="${forcer}" arg2="oui" /></not>
              </and>
            </condition>
          </fail>
          <fail message=" Erreur">
            <condition>
              <equals arg1="${codeRetour}" arg2="1" />
            </condition>
          </fail>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Here a function which is called in my 0_init_livraison.ksh script when a problem is detected :

fonc_warning(){
  echo "warning" 1>&2
}

So my problem is solved.

Anyway, thank's for your suggestions :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!