Flex Library project?

Ok, so in Flex Builder we have this idea of a Library project, which for those who don't know, is a project that compiles to a SWC, which is a Flash/Flex Component Library.

One can have a number of library projects all linked to help keep your code seperated and organized, as well as reusable by other parties, but when you make changes , it will automatically update the SWC in the Flex projects it's linked to.

I would love to see this kind of functionality in IDEA, where I can write my components, manifest.xml, specify the manifest XML and namespace in the project settings and compile to the SWC without having to create an ant script and essentially do it manually. This has really been my only sticking factor for not dumping Flex Builder 3 and using IDEA for all my Flex development, because my job often requires me to write a library that other developers in our organization will be using, but shouldn't be able to modify.

20 comments
Comment actions Permalink

     Nick, I don't see any limitations in IDEA concerning Flex libraries development.
     Just create separate Flex module (or separate Java module with Flex facet) for each Flex library and configure module dependencies. For example your application module should depend on your library module (but not on SWC that is produced by library module) - thus you'll always have correct code assist and compilation will be done in correct order: SWC's first, dependant modules later.
     To build a SWC instead of SWF - select 'Library' output type at Flex Compiler Settings tab.
     To setup components (i.e. namespaces and manifests) - press 'Manage Namespaces and Manifest Files' button at Flex Compiler Settings tab. Or use custom compiler config file and write respective tags manually.

Do you use latest IDEA 9 EAP?
I see no problems in Flex libraries development so please ask if you need any help.

0
Comment actions Permalink

Nick,

This same behavior works very well in IDEA.  We have ported our entire project portfolio over to IDEA from Flex Builder, some of which have 10+ SWCs being built and all dependencies between them being resolved correctly.  I ran through a pretty extensive project feature comparison between Flex Builder 3 and IDEA and raised any issues I had compiling and setting up library projects that werre working in Eclipse.  Alexander has been very timely about addressing these issues.

We are using custom flex-config.xml files for about half the libraries...



Matt

0
Comment actions Permalink

This is not an answer to the original question, but is related to it enough for me to borrow the same topic. I have an actionscript project with tens of modules, most of them libraries. When I compile the project in 9.0M1, everything works fine except the build takes about 5 minutes to complete. This would be fine, as long as the next build would be much faster. Unfortunately it isn't. I don't even need to make any changes to the project - every time I run "Make Project", IDEA goes through all the modules which takes ages. Am I missing something here? Is this a bug or a "feature"? Why can't IDEA compile only the modules which have changes in them?

0
Comment actions Permalink

Markus, the problem with incremental Flex compilation is fixed, please try latest Maia EAP (http://www.jetbrains.net/confluence/display/IDEADEV/Maia+EAP).
For large projects increasing of Flex compiler memory might be needed. Increase the value of -Xmx parameter (java.args property) in the  <Flex SDK>/bin/jvm.config file.

0
Comment actions Permalink

Alexander, it still doesn't seem to work on #10666. I've set the maximum memory to 700m. I run "Make Project" and IDEA will generate tens of swf and swc files in about 3-4 minutes. After that, I run "Make Project" again, and IDEA will indeed regenerate the files. It takes just as long and the timestamp of all the swf and swc files is updated. What am I missing?

0
Comment actions Permalink

That's strange. IDEA uses fcsh (flex compiler shell) to compile Flex. First time IDEA uses commands "mxmlc +=load-config=..." and "compc +=load-config=...". At second compilation IDEA uses incremental commands "compile N". Fcsh is restarted (and thus incremental compilation is lost) only in following cases:

  • when anything is changed in Project Structure or Flex Compiler Settings
  • when custom compiler config file is used and changes are made in it
  • when fcsh gets out of memory
  • when you select 'Rebuild project'

Also incrementality is reset for particular module if its compilation fails. But when all is built OK, second compilation must be momentary without SWFs/SWCs rebuild.
Please look at the 'Messages' toolwindow just after first and second compilation. Rebuild reason is probably written there. Is it true that at first time there are "mxmlc" and "compc" commands and second time - "compile"? If you don't detect a solution please attach all compilation output from 'Messages' in both compilations.

0
Comment actions Permalink

Ok, here are some things I've noticed:
* At least on OS X, the Messages window vanishes (i.e. not only hidden as a tab) as soon as the Flex compilation is over. This makes it hard for me to see the log or provide details about it to you.
* If I build a module individually using "Compile Module X", IDEA does use the "Compile" command tries to check if the module has changed or not. However when a module is compiled by the "Make Project", compc and mxmlc are used. Perhaps the "Make Project" does fail somehow but as I said, I can't see the logs.
* Even for the modules I have compiled manually, the change detection doesn't seem to be 100% reliable. One module said "Nothing has changed since the last compile. Skip..." as expected. Another one said "Detected configuration changes. Recompile..." even though I have done nothing in between. In that case it says e.g. "Files changed: 0 Files affected: 5"

0
Comment actions Permalink

About hidden Messages toolwindow - yep, there's a request http://www.jetbrains.net/jira/browse/IDEA-22172
But if there's at least one error or at least warning and 'Hide warnings' button is not enabled - Messages will be available. So please deselect 'Hide warnings' button when you see Messages toolwindow during compilation. If you don't have warnings at all (though I hardly believe ) - as a workaround you may add a line "var o:Object;" and you'll get a warning about variable visibility and thus willl have full build log.

As for detected configuration changes when there were none of them - that's probably fsch bug. You may file it to Adobe issue tracker: http://bugs.adobe.com/

0
Comment actions Permalink

I managed to get the "Make Project" to pass by increasing the maximum memory to 2000 megabytes. When the compilation finished the following process..

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java -Dapplication.home=/Applications/Adobe Flex Builder 3/sdks/3.2.0 -Xmx2000m -Dsun.io.useCanonCaches=false -Duser.language=en -Duser.region=en -classpath /Applications/Maia-10666.app/plugins/flex/lib/idea-fcsh-fix.jar:/Applications/Adobe Flex Builder 3/sdks/3.2.0/lib/fcsh.jar com.intellij.flex.FcshLauncher

.. was consuming 1.8GB of real memory. After that, the "Make Project" worked as you descibed. Unfortunately my machine was painfully slow at that point, because all the memory was consumed by that application.

Please let me know how I can help you find out what is consuming all that memory. Alternatively, isn't there any other way for you guys to store information on whether a recompilation is needed or not? I would be happy even with a quick-n-dirty solution that would simply track whether a given module needs to be recompiled or not. (Basically: If I modify any file in a given module, recompile it on next build. Otherwise use the swf or swc file we have created the last time). I simply cannot afford to wait 5 minutes every time I want to start my application, and compiling each module manually every time I make a change seems very cumbersome and error-prone.

0
Comment actions Permalink

Yep, unfortunately fsch is known to be full of memory leaks.
What can we do? Fcsh is open-source. We may report issues to Adobe. We may fix problems ourselves and send patches to Adobe. But I noticed that they are rather slow in fixing customer bugs and even in applying customer patches. If you look at Flex compiler sources - you'll see that it requires fundamental architectural improvements. And even if you find a lot of free time to perform it - I'm afraid Adobe will not apply your fix.

0
Comment actions Permalink

While that is true, at least it would be "fixed" in your product, making it better.

0
Comment actions Permalink

What about my quick-n-dirty suggestion? Would it be an option for you guys? It should be really straightforward to implement and would solve my biggest problem even if the "dirty" modules would always be built from the scratch.

0
Comment actions Permalink

Your suggestion looks reasonable.
Please create an issue for that.

0
Comment actions Permalink

Hey,

Just re-opening this thread as it seems specific at the start to my query.  What I am trying to clarify is the usage of library modules in a project space.  I have built a new flex module, I have my library of classes setup and through the module settings ensured export as swc, cool so far.  
I then create a new Flex Module in the same project space which I want to utilise this Library Module, so I go into the new Flex Modules settings and set its dependencies, now this is where I am unsure of which of the below is correct:

a) Setup a Project Library using the Library Module as the source for Attach Classes/Sources?
b) Setup a Module Dependency using the Library Module as the target?

Neither seem to be producing code completion?

Also is it essential I have to compile the Library Module to a swc to get the code completion?

Cheers,

Simon

0
Comment actions Permalink

Hi, Simon,
Correct is to configure module dependency. Application module depends on Library module. Code completion should work, swc doesn't have to be built.
Sample project attached.



Attachment(s):
LibAndApp.zip
0
Comment actions Permalink

Awesome will check it out, thanks very much Alexander!

0
Comment actions Permalink

Hi Alexander,

Thanks again that helped clear things up a treat, I have blogged a simple step by step for my or others future reference:

http://www.newtriks.com/?p=747

Cheers,

Simon

0
Comment actions Permalink

One more comment.
The project structure that you have described (and which is in my example) is for those cases when you develop both flex library and application.
If you develop only application which uses some third-party libraries then you do not need to create modules for these libraries. You create only one module for application and then manage its dependencies. Either press 'Add' button, then 'Single-Entry Module Library...' and choose required SWCs. Or Add Module/Project/Global Library and then press 'Attach Classes' to select SWCs, 'Attach Sources' to select library sources (ASdoc will be parsed from sources as well if present), 'Attach Documentation' to select respective ASdoc.

0
Comment actions Permalink

Thanks Alexander yep that scenario I had got sorted in my head, in fact blogged that route also http://www.newtriks.com/?p=710 Cheers for your rapid replies!

Simon

0

Please sign in to leave a comment.