views:

990

answers:

5

Is there a way to add entries to FlexBuilder's build path that are relative?

I'm going to have multiple projects that will use a shared codebase, but I'm having trouble getting them to reference that shared code. I can do it with absolute paths, but that isn't going to work well. This code (and the projects) are going into sourcecontrol, and other people on my team probably don't have the repositories in the same place on their harddrive as I do. So, while the paths defined may work on my machine, it won't on the other developers' machines.

FlexBuilder's UI wouldn't let me input a relative path. I tried modifying the .project and .actionScriptProperties files manually to add the relative paths, but then the project fails to open.

A: 

Have you tried Import Project option?

dirkgently
Not sure how that would help. Importing a project won't be able to set the paths properly for anything that's not a subdirectory of the project itself.
Herms
A: 

I'd personally set up an svn external in my libs folder of the flex project root. Then I'd add a reference to the source path by going to {ROOT_PROJECT_FOLDER}>Properties>Flex Build Path>Source Path> Add Folder - then add the libs folder (which should then be relative to your project). Hopefully then on every new checkout you should get the external library and have the correct references for the project. It is a bit fiddly to get this right but you get there in the end.

James Hay
Unfortunately we're using TFS here, not svn, so I can't do any kind of aliasing tricks. Even then, that would require everyone working on the project to set it up, which is what I'm trying to avoid (though I don't see any way to).
Herms
A: 

What I ended up doing was to create the project normally, but then rename the project files to add a "-template" to the end of them. I checked those in along with a readme.txt detailing the changes that needed to be made to the template files to make them usable as project files.

So, the first time a user gets latest on that project they'll have to create the FlexBuilder project from the template, but hopefully after that they won't need to touch it.

One thing I had to be careful of was project references. Originally my project referenced another FlexBuilder project. I found it was easier to reverence the SWC itself instead of the project.

Not nearly the optimal solution, but it was the best I could come up with given that FlexBuilder can't handle relative paths.

Herms
A: 

If I understand what you are wanting, one of the two approaches might work (I'm using Flex builder 3):

Option #1 - create a flex build "Flex Library Project" to hold your shared source. In the consuming project's Properties > Flex Build Path > Library Path, add the "shared" project as a reference.

Option #2 - add directory to project's Properties > Flex Build Path > Source Path. As you noted, builder uses a fully qualified path. I saved the project, exited Flex Builder and edited .actionScriptProperties - the magic seems to be to use the name of one of the projects in your workspace as if it was fully qualified: Try changing: to

A: 

I've had a lot of luck simply hand-editing .actionScriptProperties and adding the relative paths myself:

<compilerSourcePathEntry kind="1" linkType="1" path="../utils/src"/>
...
<libraryPathEntry kind="1" linkType="1" path="../utils/libs"/>

However, this does have the drawback that FlexBuilder isn't smart enough to realize when the linked source is changed; that is handled by .project (isn't FlexBuilder wonderful?).

To deal with that, I've committed .project_skel files to source control which developers copy into place, fixing the absolute paths, before importing the project into FlexBuilder.

David Wolever