Post Build Actions in Flex Builder - apache-flex

How do I add post-build actions in Flex Builder? For example, I'd like my build to work as normal, and execute from the bin folder; but I'd also like a copy of the final SWF to be copied to another folder automatically (I'm sick of doing it myself).
Thanks!

I know this post has been answered, but I found something simpler. I'm sure the Ant solutions are the way to go, but I didn't feel like messing with ant for my small project. All I really want is to have my html files and swf files in different directories. I guess that's a lot to ask.
I'm building on windows, so I created a simple batch file that performs my post-build steps (namely some move commands). I then created a new builder in flex using windows cmd.exe. I just told it to call the batch file using the /C option. It works perfectly and was very simple to set up. I tried adding screen shots, but I guess I'm too new to the site.

You can extend or replace the builder used by Flex Builder 3 with extenal programs - ant is a good choice.
If you run "Flex Builder 3 standalone" (which is a minimalist Eclipse version + the Flex builder plugin) as opposed to the Flex builder plugin in a standard Eclipse, you first need to install ant support. I didn't find ant separately packaged, so I just selected the Java build environment from Help / Software Updates.
Now you can go to your project properties (Right-Click on your Project, Properties) and chose Builders. You'll notice there is a Flex Builder per default, which you cannot remove nor change. However, you can deselect it and you can add other builders.
So in your case: "add" a new builder, ant builder, select a build.xml (can be named differently), preferably from within your project folder, and set the correct targets. This will continue to use the internal IDE builder while running your ant task just before or afterwards. The ordering on the screen will be the build order, which you can change using the arrow buttons.
I used this to copy required libraries into my /lib folder, compile the Flex sources using the IDE build (which has Eclipse-integration with error messages, which a pure ant-based commandline build would miss), and copy the result to a common deploy directory, renaming the wrapper html file in this process.
For details of how to write an ant file, please refer to the ant documentation.

I would also recommend using ant.
I posted a big article on how to get it set up for flexbuilder here http://dispatchevent.org/mims/ant-for-flex-part-1/ I think there is even an example in my build script of copying files from one place to another after compiling.
Good luck!

You'll have to create a custom build script. For whatever reason, the included, default 'builder' is not editable through the interface, so you'll have to replicate a lot of its functionality. Luckily, (or maybe not) Flex Builder uses Apache Ant for its build scripts, so this may or may not be a familiar way to do this for you.
To create a custom build script:
In the Flex Navigator view, select a project and then right-click (Control-click on Macintosh) to display the context menu and select Properties.
Select the Builders properties page. If you're using other Eclipse plug-ins, there may be more than one builder listed. Flex Builder provides a builder named Flex, which you cannot modify.
Select New.
In the Choose Configuration Type dialog box, select the appropriate configuration type. Flex Builder supports the program type. Select it and click OK to continue. From the new builder properties page you define the builder properties and reference the Ant script (an XML file).
Click OK to apply it to the project.
Flex builder is based on Eclipse 3.1, so documentation for Ant integration for that release is relevant here.
Note: Ant support must be enabled in Flex Builder first. I usually use Flex Builder as a plugin, rather than the standalone version, and the standalone version doesn't come with it out of the box. Here's a tutorial on how to do this.

Steve,
If you want use Ant in Flex Builder, you may see:http://www.peterelst.com/blog/2006/09/03/flex-builder-2-ant-support/
but I am not sure this is work in flex builder 3 or not.

Steve,
Here is a bit more detail on the post build script. It will be a simple bat file. For instance add the below line to a simple text file postbuild.bat (name doesn't matter).
copy bin/*.* 'someother location'
This would copy everything in the bin folder to another folder, just change the 'someother location'.

The least elegant solution but it will work on linux.
Create cron task to be executed every minute.
Use cp command with "-u" option.
From "man cp".
-u, --update
copy only when the SOURCE file is newer than the destination
file or when the destination file is missing
In crontab -e add
* * * * * cp -u /path/to/bin-debug/*.swf /path/to/destination/
For more elegant solution - Ant the way to go.

Related

How to make a Flex Builder project to work on an existing Flex non-project with ant build?

I want to do some development on a Flex project that uses Ant: http://svn.openstreetmap.org/applications/editors/potlatch2/ . I can build it from the command line but now want to use Flex Builder 3.0.2 to build, debug, etc.
I can see a few different paths to follow, but nothing that screams out "this is the right way":
create new project, SVN checkout in there (but then the directory structures won't match, and not sure how to tell FB to build using the existing build.xml)
create new project, create external source links to another directory with the files in it
Surely people do this all the time? (Never done Flash development before...)
Ok, here's what ended up working for me. It turns out I didn't need to use ant to build the project after all. This is for the specific project (Potlatch2) but lots of the principles are probably common.
File | New Flex Project (no server), save it somewhere, eg "c:\pot"
SVN checkout the potlatch2 files inside, so you have c:\pot\potlatch2\potlatch2.mxml etc...
Rename version.as.template to version.as and make up some stuff inside
Remove the "..." line from potlatch2-config.xml. Don't ask me why.
Set Flex SDK version - configure it to point to SDK 3.5
Project | Properties | Flex Build Path:
set source folder to potlatch2
set output folder to potlatch2\resources
set library path to potlatch2\lib
Update Flash global security settings to allow access to c:\pot\potlatch2\resources (otherwise you get 1. SWF security errors)[1]
Update browser settings (Window | Preferences...) to use a browser that has Flash Debug Player installed (ie, not Chrome).
Under debug settings (click the bug drop down, Other...): Turn off "Use defaults", make debug (and possibly run and profile) point to an HTML host file that passes the right settings to potlatch2.swf, passing lat/long coordinates of a place you want to edit.

"Make" system for Actionscript?

In working on larger Actionscript/Flash projects, I've started to really feel the need for some kind of "make" system, but I haven't found it yet. Does anyone know if it exists?
Required features:
Ability to associate SWCs with their source code and/or FLAs i.e. "this swc is compiled from this source"
Ability to mark my current project as depending on these SWCs (either as compile-time or runtime libraries)
A single, big shiny button, that when pressed does the following:
Checks to see if any of the source files have changed, and if so, recompiles their associated SWCs
Recompiles and relinks the main .swf, if necessary
Runs the main .swf
Have yet to find a way to get something like FlashDevelop to do this (but I don't know it well enough to be sure). Support for both code and FLA sources is preferred.
You are looking for http://projectsprouts.org/ which is based on Rake the Ruby version of Make. It can do all of that stuff and much more.
If you have Ruby and RubiGems installed which I think are installed by default on Macs you can install it by typing this into your command line.
sudo gem install Sprout
It will take a while because it installs many things. After this is all set you can create a project like this.
sprout -n as3 ProjectName
and then build it with this,
rake deploy
It manges things based on the runtime they are created for, this project was created for as3 but all of the other types of projects also. The build scripts are all writen in Ruby and can be modified to involve more complex multi-step compiles pretty simply. It also has a bunch of generators so that classes automaticly have unit test that are associated with them and many other features.
Might be a stupid suggestion, but if you want make, why not just use "make"? You can use it for any language by defining the right rules.
Apart from that, I've seen a lot of Flex/Actionscript projects use Apache ant, an XML based build system.
As said by wump; why not use Make?
There are some ANT scripts included in the Flex SDK, so you could explore and expand those. I've also spoken to people who use Maven and Cruise Control for automated build process.
Here is some info on Maven Flex: http://code.google.com/p/flex-mojos/
And some info on Cruise Control w/ Flex: http://www.eyefodder.com/blog/2006/05/continuous_integration_with_fl_5.shtml
Well, there are several options. One I would recommend is the Maven plugin for Flex flex-mojos, now maintained on the Sonotype site. If Maven isn't your cup of tea, they do have an Ant plugin, I don't know if NAnt can call Java Ant tasks directly or not. The third is the most complicated, but Adobe does include an OEM version of the compiler, I believe it comes by default with the SDK download. This is the one I used in the Maven plugin I developed for my company. The reason we didn't use the flex-mojos one basically boils down to a...disagreement about the "Maven way" of one project = one artifact. Their interpretation is that 1 SWF file is one artifact, so is one Maven project. My definition for my project is that all 80+ modules, each a SWF file, are no different than JSPs, all bundled in the same WAR file. So I've got one project with a LOT of modules and 1 maven pom.
You could check out Antpile which according to said link "is a collection of Ant Scripts which cover everything from building a SWF, SWC, AIR, Android and even Unit Testing."

Custom project in Adobe Flex Builder 3?

Is it possible to create a custom project type using Adobe Flex Builder 3? I'd like to create my own custom project template that creates certain directories, sets Source Path and Library Path values, etc. so that I don't have to do it manually.
I'm using the standalone version of Flex Builder, which is running on Eclipse 3.3.
Thanks!
Flex Builder 3 can't do anything like that :/. I've created a set of custom generators in ruby, that work just the way Ruby on Rails generators work: Define a bunch of template files and directories, run a single command with project name and I get a new Flex project completely customized and ready to go.
What Flex Builder 4 REALLY Should Include...
I just have a project 'template' that I create a copy of and import when I need it.
But I guess you could theoretically write a plugin but that's total overkill.

Customizing newly created projects in Aptana

I need to define a model for newly created projects in Aptana.
Basically, I want, anytime, when I create a new project, it adds some defined directories/files (not existing files, but new ones) to this project.
I'm not even sure it's possible.
Aptana doesn't appear to support that.
Maybe you can just create a small external sript to do it for you? Not the ideal solution, but better then none.
This might be a longshot, but it is worth mentioning. Since Aptana is based on Eclipse, you might be able to see how Eclipse would handle custom project templates. It appears that the easiest way to go about this is to actually create an Eclipse plugin that has a Template Wizard. IBM has a nice guide on how to use PDE to create a Custom Template. I am not sure if you will be able use PDE from within Aptana (you might be able to), otherwise, you might need to download a stock version of Eclipse, create the Plugin, then install it in Aptana.
Aptana is based on eclipse, so you could use a combination of Maven Archetypes and the Maven eclipse plugin to achieve this really easily.
Download and install maven
Create a basic maven project using the quickstart archetype, Archetypes are project templates used to rubber stamp new project structures. The quickstart is a very basic project template
mvn archetype:generate
generate the eclipse project files using the eclipse plugin. This will create the standard
mvn eclipse:eclipse
tweak the pom until and re-run step 3 until you're satisfied with the layout etc. You'll no doubt have to add configuration the eclipse plugin to add the correct build spec and project nature. If you open an existing .project file it will contain the values you need. you can see here how to add them.
once the project is set up to your liking you can create your own archetype out of it and use this to rubber stamp new projects in the future.
mvn:archetype:create-from-project
now you can run the generate again and can select your archetype from the list. If its not there, you may need to run this first to update the list of archetypes
mvn archetype:crawl
Open Source your archetype for others to use ;)
It's very simple in Studio 3. Try the following: http://wiki.appcelerator.org/display/tis/Creating+a+new+template#Creatinganewtemplate-Creatinganewprojecttemplate
Basically you create a .zip file of the project content, and then write a few lines of Ruby code to reference it.
Aptana uses (as I'm sure you know) its own 'new rails' project that gives you a variety of options.
I don't think it's beyond Will (the RadRails maintainer) to add a simple text field to that Wizard that would allow you to enter a command-line option parameter. He's always been very responsive with my previous bug and feature requests.
If you want to give that a try, and that works, then I would HIGHLY and STRONGLY recommend that you look into one of the new Rails features 'templates' in which you could make a generic template, then call it through the new input box. We use templates at my current job and they save us about 4 hours of work on each project. They are very easy to use...def...definitely.
If you can't wait for the input box, then you could always write the template then call it from within the command line (see
http://m.onkey.org/2008/12/4/rails-templates
for info about templates)
Unless RadRails three is light-years ahead of the latest release, though, you'll be missing out on a lot of very handy advantages of using a more community-supported solution such as VIM or TextMate. (I switched to VIM from RadRails about 4 months ago and have never looked back).
Eclipse has a Plugin Development Environment. If I'm not mistaken, you can also create project templates with it. Please try: http://www.ibm.com/developerworks/library/os-eclipse-pde/

How do you enforce dependencies among java folders in Netbeans?

I am new to Netbeans. I am wondering if someone can help me with project setup in netbeans. I am moving half million lines of Java code from a different IDE to Netbeans. I was able to get the code build and run in Netbeans easily. I have a project with many folders with dependencies among those folders. They have to be built in specific order. This is to enforce layering so that a module in lower layer cannot call into higher layers. I couldn't get that configured in Netbeans. Below is how my project looks like
project/
libA/
libB/
libC/
libD/
libE/
appA/
...
I have one project that builds all the libs and appA. The project build xml is stored under project/ folder. But the libs have dependencies among them. libB should be built after libA. libC after libA. libE depends on libD and libB etc.
I tried to change the order of source folders for libs in project properties. That didn't seem to make any difference. Even if I move libA after libB, it was building everything fine. I expected it to fail because libA didn't build yet.
Iam lost. Just wondering what the trick is to enforce this kind of dependencies. I created my project using "Java project using existing sources" wizard.
I appreciate your help
Thanks
Video guy.
Even though it would be a pain, you could just write your own ant build script and then just have Netbeans use that.
Basically:
write the custom ant build file
install the Ant plugin
create an Ant build file
right click the build file
run the selected target.
This would enable you to enforce whatever you need to do, but, if Netbeans is figuring out the correct order then why not just use it.
Does something break when you just compile and run in Netbeans?
Well! Lets say a team member added piece of code in lower level package that calls into higher layer code. It should fail because it breaks the layering. Because Netbeans seem to compile all the files in one javac invocation, the build compiles just fine. I want Netbeans to break the build in this case.
Writing my own ant script is another way of enforcing it. The whole point in using an IDE is to save yourself from writing your own make files (or ant scripts). This is something any IDE was able to accomplish 10 years back out of the box. I am wondering if I am missing something here.
Thanks
Video Guy

Resources