Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从ANT任务执行bower更新_Java_Javascript_Bash_Ant_Bower - Fatal编程技术网

Java 从ANT任务执行bower更新

Java 从ANT任务执行bower更新,java,javascript,bash,ant,bower,Java,Javascript,Bash,Ant,Bower,我想创建一个ANT任务,允许在我的项目中执行bower更新 我写了这个目标: <target name="update-static-web-dependecy" description="Update static web dependency"> <exec dir="${static-web.dir}" executable="/usr/local/bin/bower"

我想创建一个ANT任务,允许在我的项目中执行bower更新

我写了这个目标:

    <target name="update-static-web-dependecy" description="Update static web dependency">
        <exec dir="${static-web.dir}" executable="/usr/local/bin/bower">
            <arg  value="update"/>
        </exec>
    </target>

但当我要运行它时,我会得到以下错误:

env:node:没有这样的文件或目录

结果:127

在我的操作系统中,Bower与arg-g一起正确安装,如果我从shell启动它,它会工作得很好

有人能帮我吗

问候,,
Lorenzo

我猜您可以通过在
exec
块的
env
元素中指定节点的路径来解决这个问题。像这样的

<property name="node.dir" value="/usr/local/bin"/>

<exec dir="${static-web.dir}" executable="/usr/local/bin/bower">
    <env key="PATH" value="${env.PATH}:${node.dir}"/>
    <arg value="update"/>
</exec>

对于任何想在Phing中实现这一点的人来说,这稍微少了一点,但是Ant的答案可能会让你感到困惑。如果您知道鲍尔在哪里,您可以一次完成这一切:

<exec command="/usr/bin/bower install" dir="${dirs.httpdocs}" />

如果您正在执行一些通用的操作,可以首先检查bower.json是否存在:

<!-- bower exists -->
<property name="bowerExists" value="false" />
<exec command="if [ -f '${dirs.httpdocs}/bower.json' ]; then echo 'true'; else echo 'false'; fi;" 
      outputProperty="bowerExists" />
<if>
    <equals arg1="${bowerExists}" arg2="true" />
    <then>
        <echo>Installing Bower Packages</echo>
        <exec command="/usr/bin/bower install" dir="${dirs.httpdocs}" />
    </then>
</if>

安装Bower软件包

来源:

如果您遇到问题,请设置exec的
outputProperty
属性,并在之后回显它(我就是这样解决的)。