问题
When I try to run Ant build script in Flash Builder error will generate. So I put export FLEX_HOME=/Applications/Adobe\ Flash\ Builder\ 4.7/sdks/4.6.0/
in my .zshrc
. This works fine in command line, but doesn't in 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>
And the error
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
回答1:
Shot in the dark...
Should the declaration of the FLEX_HOME property be set using a value attribute as follows?
<property name="FLEX_HOME" value="${env.FLEX_HOME}" />
回答2:
You need to set your FLEX_HOME similarly to how you set JAVA_HOME.
Go to your Users/{username} folder and find your ".bash_profile". If no bash profile exists there, make an empty one as a .txt file, save it, and then rename it from ".bash_profile.txt" to ".bash_profile".
Then add the following to your bash profile:
export FLEX_HOME=/{flex install path}
Replace the bracketed portion with the actual flex install path for your system, then save. To verify it, open a new command line and use the command "echo $FLEX_HOME". If it responds with /{flex install path}, then it is set properly.
回答3:
Ran into this myself today after trying to pickup a super old project from years back. Haven't had Flex (errr... Flash Builder) installed on this machine in ages.
End up needing to alter the build.properties
file with the following:
FLEX_HOME=/Applications/Adobe\ Flash\ Builder\ 4.7/sdks/3.5.0
FLEX_FW_VERSION = framework_3.5.0.12683
That did the trick for me.
来源:https://stackoverflow.com/questions/14277539/how-do-i-set-up-a-flex-home-environment-variable-in-flash-builder