How do you set up your Flex project?
I've spoken to a bunch of people who are not sure how to organize their Flex project files when using Flex Builder, especially when version control comes into the picture. After a few different people asked me questions, I decided to blog about my approach.
First, I want to let you know that there are really three different directories in play when you create a Flex Project in Flex Builder:
- Eclipse Project Root: This is your Project Root. It contains eclipse related folders and files, such as a .settings folder, and .project file, a .flexProperties file and a .actionScriptProperties file. The html-templates will also show up here.
- Source Directory: The source directory contains the source of your application. In Flex Builder 2, the default location of this is the same as your project root. It can cause a lot of problems if you accidentally start committing project files to a repository and other developers working with you update them, thus corrupting their local platform. Flex Builder 3, Beta 2 has made the source directory a subdirectory of the Project Root by default. It's a step in the right direction.
- Bin Directory: The bin directory contains the compiled swf, and other related assets. It is, by default, a subdirectory of the Eclipse Project Root. There is a setting ( by default ) that will copy all files from the Source to the bin. I haven't decided if keeping this checked is a good thing or not.
Those are the three directories that we're worried about in relation to a Flex project. I'm not a fan of the default setup, and was partially inspired to change it by Nat Papovich's post over at the Webapper blog. A lot of what I write here is based on his post. I keep my Eclipse Project folders as a subdirectory of the Eclipse Workspace. The source folder will go in a non-web accessible client directory elsewhere on my machine. The bin directory will go under the web root. These are three isolated directories scattered around on my machine.
How do I set this up? This is my procedure:
- Launch Eclipse, and go File --> New Project --> Flex Project. Click Next.
- You can fill in the relevant server information as you see fit. Click Next.
- Enter the Project Name. I usually use the default location for the workspace, but you can change that if you want. Click Next.
- Now you are at the project properties screen. For the bin folder, you can choose any folder on your hard drive. Change the name of the main app, specify the URL, and add libraries at your leisure. For some reason you can only choose a source path that is a subdirectory of the Eclipse Project Root, not something outside of it at this stage. Click Finish.
- Now you need to create a source folder that is outside of your current root. From within the project, select File --> New --> Folder.
- The name of the folder (I use src) and click advanced. On the advanced screen click "Link to a folder in the File System". You can then choose a path anywhere on your system.
- Now you've created your source path pointed to the appropriate location, but you haven't told Flex Builder to use it as the main source location yet.
- Open up the Project Properties using Project à Properties à Flex Builder Path. Select "Browse" next to main source folder and select your src directory. Click okay.
- You might receive a warning that "src/Main.mxml" does not exist. That is fine. Just click and drag the Main.mxml file from the project root to your new source root (src). The warning should go away on its' own, but if not you can right click the file and "set as Default Application"
You should be all set on Flex Builder 3 (Beta 1) or Flex Builder 2. The procedure has changed a bit in Flex Builder 3 Beta 2; all the same stuff is there, just in slightly different spots.
Personally, I only keep the source directory under version control, but I can see valid reasons for keeping the bin directory under version control if that is what you want. I find this apparoch much cleaner than trying to set up Subversion to ignore project and bin files.
I thought it might be beneficial to note that most of my applications are made up of multiple projects. I put all of the generic Flex functionality inside a Flex Library project. I use a Flex, or AIR, project as a 'wrapper' to the Flex Library to allow for easy deployment in either environment. Backend components go in another Eclipse Projects (often with CFEclipse).
Each section of the application will have a separate repository directory with its' own trunk, branches, and tags. The whole purpose of encapsulation is that you change the implementation details without changing the interface; so it is entirely possible that I'll change a backend component without changing the Front end. Making each project a separate repository allows me to do this easily. You're more than welcome to tell me that it is rare you change one piece without changing all the other pieces. I understand that idealology and reality are not always on the same point in life.
What do you think?





When I try it, the linked source file is not automatically added to the class path, and the classes in the linked folder (src) are not recognized. If you add the src folder to the build path, however, it says invalid path. So far my hackish workaround is to add the folder ABOVE it to the build path. I get a "overlapping source paths" warning. Maybe I am doing this incorrectly.
For some reason I haven't been able to post a response. I'm not sure why
Yes this works for me. I think these instructions were written on Flex Builder 2. I actually demo how to do this w/ Flex Builder 3 on The Flex Show's Fifteen Minute With Flex. It is episode 1.
[and I'm sending this w/o the link this time to see if it actually posts]
com.myURL.myApp (view, controller, model)
com.myURL.myApp.MyApp
Because Flex Builder does not allow you to specify the executable, it has to be in the root folder, but if you link directly to folder myApp, the package addressing is thrown off.
It'd be nice src folders could plug right into my repository! I'll try again (and listen to your broadcast) next time I start a project. Thanks!
We're a year in on the start of this topic, and I was wondering if and how your perspective on this flex workflow has changed. Your name pops up a lot when googling the subject of handling Flex projects and SVN, so I'd be interested in your experiences since October 2007.
Cheers,
Eric-Paul.
I don't have a quick answer to share with you. I'm thinking about this a bit; and will try to devote some time to it in a future post. It probably won't be until after Max, though.
I also am interested to hear how your attitude on this procedure developed, over the course of time you were practicing it..
It's been a while again, I of course don't expect anything, still i will bookmark this and have a look every now and then :)
Thanks alot anyway, and I should also go drop a line at Nat papovichs site, since he started this thing off.
This helped me really alot, since I have to get into effecient Flex workflow in almost no time myself.
The only problem I've found is that the linked / mapped src directories interfere with your ability to export / import Flex Project Archives. The files and src directory are exported properly; however some settings retain the mapping information so things need tweaking after the project archive import.
This Friday at my live demo / Q&A, I'll be talking a bit about project structure; but it'll be more focused on SVN. This happens a 1pm EST
More info on that is here: http://www.jeffryhouser.com/index.cfm?mode=entry&a...
Time Zone calculator is here:
http://www.timeanddate.com/worldclock/fixedtime.ht...
I would use linked source files with my cfeclipse projects. When it comes to upload I actually use an FTP Client.
For better, or worse, I haven't done too much with automated build scripts or similar.