Flash Builder/Flex Builder – No Support for Relative Paths

You can’t enter a relative source path in Flex/Flash builder. For example, if I want the Flash authoring environment to find a class or classes on my system, I can tell it to look here: “../../libs” and it will go up 2 directories, go to libs and look in every directory under that until it finds the class. This allows me to check-in the FLA file and everyone on the team is going to be able to build it.

However, Flex/Flash Builder is built on Eclipse, and from what I’ve been a able to gather, relative paths are not accepted for source paths, which is a real pain. Unless everyone on your team stores code under “${DOCUMENTS}/everyone/uses/the/same/dev/path”, which in that case you could use the built in Linked Resources that Builder defines. But if you work on a framework or a public API, or just a dev team where people want choice over where they place their source code, this sucks.

I complained to one of the guys on the Builder team at Adobe about this and he told me this was a limitation of Eclipse and there is nothing they can do about it. But, he gave me a nice workaround and it occurred to me today, while showing this trick to a co-worker, that I should post this because others may not know about it.

Here’s the problem:

You create a new project in Flex/Flash builder and you want to reference the classes in another project. If that other project is a library, and you don’t want to reference the SWC, but the actual project source, you can simply hit “Add Project…” and select the project from the window that pops up and you are good to go, no relative paths required, Builder knows where everything is:

However, if you want to reference another project that is not a library project, such as an OSMF plugin (a project that creates a SWF, not a SWC), you need to use the “Source path” tab on this dialog and click the “Add Folder…” button:


Here’s the trick:

Don’t use the Browse button on the window that pops-up when you click “Add Folder…” above. Just type a slash (‘/’) followed by the project name.

Of course the project needs to be present in Builder (i.e., you either created it in Builder or imported it into Builder). The problem occurs when you use the browse button to locate the project because the entire path, which is specific to your system, will show up in the project files and no one except you is going to be able to build the project.  But if you just type a slash followed by the project name, builder will find the project and everyone will be able to build it.

In the image just above is what you should see on this tab, not the full path to the projects.

And your .actionScriptProperties file will have entries like this:

<compilerSourcePath>

<compilerSourcePathEntry kind=”1″ linkType=”1″ path=”/AkamaiAdvancedStreamingPlugin”/>

<compilerSourcePathEntry kind=”1″ linkType=”1″ path=”/AkamaiBasicStreamingPlugin”/>

</compilerSourcePath>

Notice the full path is not there.

One more thing:

You need to do one more thing before checking your code into a repository (SVN, Perforce, etc.):
Check your .project file and delete the <linkedResources> tag:
<linkedResources>
<link>
<name>[source path] AkamaiAdvancedStreamingPlugin</name>
<type>2</type>
<location>/Users/cnewman/Documents/Akamai/p4/projects/flash-client-dev/osmf/plugins/advanced-streaming-    plugin/trunk/AkamaiAdvancedStreamingPlugin</location>
</link>
</linkedResources>
Notice the full system path is in there. Builder doesn’t need this tag to build your project, it’s only for the Eclipse GUI, so just remove it from the file so no one gets errors importing your project.

I realize there are Linked Resources at the General->Workspace level for builder such as ${DOCUMENTS}. But this is not a great solution if you work on a project that a lot of people are going to need to be able to build, such as a public framework or API.  Everyone who wants to build your project is going to need to setup your required Linked Resource before they can build. But with the trick above, all they need to do is import your Builder project and go.