如何在Flash Builder中设置FLEX_HOME环境变量

时间:2013-01-11 11:45:53

标签: ant flash-builder

当我尝试在Flash Builder中运行Ant构建脚本时会生成错误。所以我将export FLEX_HOME=/Applications/Adobe\ Flash\ Builder\ 4.7/sdks/4.6.0/放在我的.zshrc中。这在命令行中工作正常,但在FB中不起作用。

的build.xml

<?xml version="1.0"?>
<project name="helloworld" basedir="../" default="compile">
    <!-- Set up prefix for all environment variables -->
    <property environment="env" />
    <fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
    <!-- Load user properties to overrride defaults -->
    <property file="${basedir}/build/build.properties" />
    <!-- System environment must contain FLEX_HOME variable that points to Flex SDK -->
    <property name="FLEX_HOME" location="${env.FLEX_HOME}" />
    <!-- Set up Flex tasks in Ant -->
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />

    <!-- Create directories needed for the build process -->
    <target name="init" description="Initializes project and destination folders.">
        <echo message="Project: ${ant.project.name}" />
        <echo message="Flex SDK: ${FLEX_HOME}" />
        <echo message="Flex home is ${env.FLEX_HOME}" />
        <delete dir="${bin.dir}" />
        <mkdir dir="${bin.dir}" />
    </target>

    <target name="compile" depends="init" description="Compiles the application.">
        <mxmlc file="${src.dir}/${application.name}.as" output="${bin.dir}/${application.name}.swf">
            <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />

            <source-path path-element="${src.dir}" />

        </mxmlc>    
        <echo message="The ${application.name}.swf has been created in ${bin.dir}" />
    </target>

</project>

错误

Buildfile: /Users/gadzimari/Documents/Adobe Flash Builder 4.7/helloworld/build/build.xml

BUILD FAILED
/Users/gadzimari/Documents/Adobe Flash Builder 4.7/helloworld/build/build.xml:5: FLEX_HOME needs to be defined as an environment variable or in the Ant build.

Total time: 302 milliseconds

3 个答案:

答案 0 :(得分:0)

在黑暗中拍摄......

是否应使用value属性设置FLEX_HOME属性的声明,如下所示?

<property name="FLEX_HOME" value="${env.FLEX_HOME}" />

答案 1 :(得分:0)

您需要像设置JAVA_HOME一样设置FLEX_HOME。

转到您的Users / {username}文件夹,找到“.bash_profile”。如果那里没有bash配置文件,请将空文件作为.txt文件,保存,然后将其从“.bash_profile.txt”重命名为“.bash_profile”。

然后将以下内容添加到您的bash配置文件中:

export FLEX_HOME=/{flex install path}

用您系统的实际Flex安装路径替换括号部分,然后保存。要验证它,请打开一个新命令行并使用命令“echo $ FLEX_HOME”。如果它以/ {flex install path}响应,则表示设置正确。

答案 2 :(得分:0)

自从多年前试图挑选一个超级老项目之后,今天就自己动手了。 Haven并没有在这台机器上安装Flex(错误... Flash Builder)。

最终需要使用以下内容更改build.properties文件:

FLEX_HOME=/Applications/Adobe\ Flash\ Builder\ 4.7/sdks/3.5.0
 FLEX_FW_VERSION = framework_3.5.0.12683

这对我有用。