相关疑难解决方法(0)

覆盖忽略属性

Content of Build.xml File


<?xml version="1.0"?>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="ant-contrib-0.6.jar"/>
<taskdef classpath="orangevolt-ant-tasks-1.3.2.jar" resource="com/orangevolt/tools/ant/taskdefs.properties"/>               
<project name="initinstaller" default="all" basedir="." >       
<target name="configure-server-types-module">       
    <property file="./installation.conf"/>  
    <echo message="${client.server.types}"/>
    <if>
        <not>               
            <contains string="${client.server.types}" substring="tomcat" />
        </not>
    <then>
        <replaceregexp file="./installation.conf"
                match="client.server.types=(.*)" 
                replace="client.server.types=\1tomcat,"
                byline="true">
        </replaceregexp>
    </then>
    </if>       
</target>

<target name="all" depends="configure-server-types-module">     
    <property file="./installation.conf"/>  
    <echo message="${client.server.types}"/>
    <if>
        <not>               
            <contains string="${client.server.types}" substring="tomcat" />
        </not>
    <then>
        <replaceregexp file="./installation.conf"
                match="client.server.types=(.*)" 
                replace="client.server.types=\1tomcat,"
                byline="true">
        </replaceregexp>
    </then>
    </if>       
</target>
Run Code Online (Sandbox Code Playgroud)

Content of installation.conf : client.server.types=jboss,
Run Code Online (Sandbox Code Playgroud)

详细输出:

Apache Ant version 1.8.1 compiled on April 30 2010
Trying …
Run Code Online (Sandbox Code Playgroud)

ant

5
推荐指数
1
解决办法
9864
查看次数

将exec'd批处理文件中的退出代码传播回ant

我需要从蚂蚁那里打电话给sbt.我正在使用"exec"任务执行此操作,如下所示:

  <target name="publish-jar">
    <exec executable="sbt.bat" failonerror="true">
      <arg value="publish"/>
    </exec>
  </target>
Run Code Online (Sandbox Code Playgroud)

如果sbt任务失败,我需要ant任务"失败",这就是使用的原因failonerror="true".但是,这不起作用.当sbt任务失败时,ant不会报告失败的构建.

这看起来像这里讨论的问题: Ant exec resultproperty不起作用.建议的解决方法是从中删除"/ B" sbt.bat.换句话说,改变:

exit /B %ERROR_CODE%
Run Code Online (Sandbox Code Playgroud)

exit %ERROR_CODE%
Run Code Online (Sandbox Code Playgroud)

但是,正如一位评论者所说:

这样做的缺点是,如果直接运行批处理文件进行测试,它将终止你的shell.您可以在批处理文件中使用if和arg来选择\ b,当ant调用它时,正常退出时不选择.

问题: 当发生故障时是否有修复:(1)不终止调用者的shell和(2)将退出代码传播给ant?

更新

这是运行我的ant任务的输出.实际错误在这里并不重要(我故意不配置存储库来发布,强制错误):

C:\dev\la\sdf3\modules\test>ant publish-jar
Buildfile: C:\dev\la\sdf3\modules\test\build.xml

publish-jar:
     [exec] [info] Loading global plugins from C:\Users\jn\.sbt\0.13\plugins
     [exec] [info] Set current project to test (in build file:/C:/dev/la/sdf3/modules/test/)
     [exec] :: loading settings :: file = C:\dev\la\sdf3\modules\ivysettings.xml

     [exec] [info] :: delivering :: com.jn#test;SNAPSHOT ::
SNAPSHOT :: integration :: Fri Mar 14 08:45:58 HST …
Run Code Online (Sandbox Code Playgroud)

windows ant batch-file exit-code sbt

5
推荐指数
1
解决办法
1638
查看次数

标签 统计

ant ×2

batch-file ×1

exit-code ×1

sbt ×1

windows ×1