Ant构建执行Haxe代码时失败

时间:2015-03-04 11:21:09

标签: javascript ant haxe haxelib

您好我是Haxe的新手,并尝试构建执行Haxe文件到Js文件的ANT脚本。贝娄是我的build.xml文件,请纠正我,如果我错过了什么,错误说它无法找到Haxe类" HelloWorld"。 HelloWorld.hx位于aha /文件夹中,我已将其包含在" Sourcefiles"

<?xml version="1.0" ?>

<project name="AHA" default="main" basedir=".">
    <description>
        Simple example build file
    </description>
    <property name="buildDir" value="./buildFiles"/>

  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location="./tools/ant/ant-contrib-0.3.jar" />
    </classpath>
  </taskdef>

    <target name="clean" description="Remove all generated files.">
        <delete dir="${buildDir}/" />
    </target>

    <target name="main" depends="clean">
        <!-- <property name="debug.target.app" value="app.js" /> -->
        <mkdir dir="${buildDir}" />
    <outofdate>
        <sourcefiles>
        <fileset dir="./aha/">
          <include name="**/*.hx" />
        </fileset>
    </sourcefiles>
    <targetfiles path="${buildDir}/*.js" />
    <sequential>
        <exec failonerror="true" executable="haxe">
          <!-- arg line="-lib polygonal-core -lib createjs" /-->
          <arg value="-js" />
          <arg file="${buildDir}" />
          <arg line="HelloWorld" />
    </exec>
    </sequential>
  </outofdate>
  </target>

</project>

当我运行ant命令行时,我得到错误

C:\Users\vishwanath.kolkar\Desktop\ahaproject>ant
Buildfile: C:\Users\vishwanath.kolkar\Desktop\ahaproject\build.xml

clean:
   [delete] Deleting directory C:\Users\vishwanath.kolkar\Desktop\ahaproject\bui
ldFiles

main:
    [mkdir] Created dir: C:\Users\vishwanath.kolkar\Desktop\ahaproject\buildFile
s
     [exec] Class not found : HelloWorld

BUILD FAILED
C:\Users\vishwanath.kolkar\Desktop\ahaproject\build.xml:30: exec returned: 1

Total time: 0 seconds

1 个答案:

答案 0 :(得分:0)

<exec failonerror="true" executable="haxe">
          <!-- arg line="-lib polygonal-core -lib createjs" /-->
          <arg value="-js" />
          <arg line="-cp aha/" />
          <arg file="${buildDir}" />
          <arg line="HelloWorld" />
    </exec>

这将找到我试图访问的类,我忘了添加类路径,即-cp aha /这个aha /文件夹包含我的HelloWorld.hx,类名是HelloWorld。