【问题标题】:How do I troubleshoot an ANT "exec" command line error message?如何对 ANT“exec”命令行错误消息进行故障排除?
【发布时间】:2016-02-05 18:10:05
【问题描述】:

使用 Ant 脚本,我正在尝试构建 bar 文件以部署在 IIB Server 中。但我面临如下错误:

BIP0960E 提供给 mqsicreatebar 的“-a”、“-l”、“-p”或“-o”参数不正确

请告诉我如何解决这个错误。

谢谢。

我正在使用以下 ant 脚本:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Test" default="Create_bar" basedir=".">
    <property file="ucd.properties"></property>
     <taskdef resource="net/sf/antcontrib/antlib.xml">
          <classpath>
              <pathelement location="C:\apache-ant-1.9.6\lib\antcontrib.jar"/>
          </classpath>
     </taskdef>  

     <!-- Making Windows command environment  -->
     <target name="mqsiprofile.cmd">
     <exec executable="${broker.mqsi.path}\mqsiprofile.cmd" />
     </target>
//  <!-- Creating a bar file -->
        <target name="Create_bar">
            <for list="${project_name}" delimiter="," param="pName">
                <sequential>
                <echo message="@{pName}"/>
                <exec executable="${toolkit.home}\mqsicreatebar.exe" spawn="false" vmlauncher="false" failonerror="true">
                //  <!-- project's workspace-->
                    <arg value="-data" />
                    <arg value="${workspaces.dir}" />
                    <!--barfile generated path-->
                    <arg value="-b" />
                    <arg value="${bar.loc}\@{pName}.msgflow.generated.bar" />
                    <!--project Name-->
                    <arg value="-p" />
                    <arg value="@{pName}" />
                    <!--Message flows for its corresponding projects which has given in cvsCheckout.properties-->
                    <arg value="-o" />
                    <arg line="@{bar.loc}\${@{pName}.flow_name}" />
                    <arg line="@{bar.loc}\IAM_Demo_Compute.esql" />
                <arg value="-deployAsSource" />
                </exec> 
                </sequential>
            </for>
        </target>

    </project>

我放置了所有必要的组件来构建 bar 文件。

【问题讨论】:

    标签: java deployment ant continuous-integration ant-contrib


    【解决方案1】:

    上面的BIP0960 错误消息表明您已将不正确的参数传递给您在脚本中运行的可执行文件。您需要对传递给可执行文件的参数字符串进行故障排除。

    以您构建它们的方式调试 ANT execstatements 可能很困难。

    调试 ANT 脚本的一个好方法是为命令行参数字符串创建一个属性,然后将这些参数回显到控制台以确认它们的构造。使用此参数字符串输出来查看、测试、修改和重新运行命令及其参数,直到它们起作用。

    为此,重构您的 exec 语句,使其引用单个参数字符串,称为 ${myParams}:

    <!-- create the command parameters -->
    <property name="myParams" value="-data ${workspaces.dir} -b ${bar.loc}\@{pName}.msgflow.generated.bar -p @{pName -o @{bar.loc}\${@{pName}.flow_name} @{bar.loc}\IAM_Demo_Compute.esql -deployAsSource" />       
    <!-- echo myParams -->
    <echo message="myParams: ${myParams}" />
    <!-- pass myParams to the executable -->
    <exec executable="${toolkit.home}\mqsicreatebar.exe" spawn="false" vmlauncher="false" failonerror="true">
      <arg line="${myParams}" />
    </exec> 
    

    echo 语句将显示扩展的属性变量。将其复制并粘贴到命令行,然后重试。当您拥有正确的参数时,将其复制并粘贴回您的脚本中,用正确的变量替换静态值。

    同样,将命令行的更改作为一个属性而不是多个 arg 值来管理更容易。

    使用这种结构,您可以轻松解决任何 exec 命令问题。

    【讨论】:

      猜你喜欢
      • 2018-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      相关资源
      最近更新 更多