Import Flexmojos Projects to IntelliJ IDEA 9

Posted on by Alexander Doroshko

Integration with Flex projects that are set up using Flexmojos Maven plugin is very much improved in IntelliJ IDEA 9 (Maia).

Note: before starting please make sure that Maven Integration Extension plugin is enabled at Settings (Ctrl+Alt+S), Plugins page.

If you are using Flexmojos version 3.4 or higher, then the only thing you need to do to import your Flexmojos project to IntelliJ IDEA is to click New Project on the File menu and select your pom.xml file.

That’s all! Right after that you have full coding assistance, ability to compile your project in the same way as Maven does, and to run and debug your application in IntelliJ IDEA.

Note: get more information about configuring Flex SDK sources and documentation for Flexmojos projects.

How does this work? When importing Flexmojos project, IntelliJ IDEA:

  1. Creates special type of SDK — Flexmojos SDK with name compiler-XXX.pom that contains information required to launch Flex compiler and debugger. In SDK configuration dialog you may increase Flex compiler heap (if your project is huge) and configure AIR paths (if you want to run/debug AIR applications):
  2. Creates modules with Flex facets.
  3. Generates compiler configuration file for each facet (target/XXX-config-report.xml). This feature is new in Flexmojos 3.4; instructions for previous Flexmojos versions project are below. IntelliJ IDEA uses these files as custom compiler configuration for Flex compilation:

Troubleshooting

If something goes wrong and you have red code in editor or you have problems with compiling project or launching tests in IDEA then you should make sure that Flex compiler configuration files (target/XXX-config-report.xml) and some other auxiliary files (target/classes/config-XXX) are up-to-date. To do that please run following from command line for your root project:

mvn compile -DconfigurationReport=true

Note that it is important to use compile because in this case dependencies between projects will be resolved as files from target folders whereas install will generate references to local maven repository that is incorrect for development purpose.

-DconfigurationReport=true flag means the same as <configurationReport>true<configurationReport> option in pom.xml but using command line flag is better because you need to skip configuration report generation when executing install goal.

Comments below can no longer be edited.

11 Responses to Import Flexmojos Projects to IntelliJ IDEA 9

  1. Tech Per says:

    September 29, 2009

    Cool! I tried it and it seems to work nicely.

    One problem though. In my pom files, I have a maven-antrun-plugin execution defined and hooked up to the install phase, that copies the compiled .swf file into another maven module target dir (a webapp module, that is to serve the .swf to the client).

    Any ideas on how to integrate this into the IDEA build? I guess I would like that antrun execution to run on each make inside IDEA.

  2. Alexander Doroshko says:

    October 1, 2009

    I guess you have a Web facet in your ‘webapp module’. If so – add dependency of ‘webapp module’ on ‘flex module’ and then at ‘Web Settings’ tab of Web facet configuration click ‘Add…’ at ‘Modules and Libraries to Package’ panel and select Flex module compile output.
    Note: you’ll probably need to set Flex module compiler output path to …/flex_module/target/ (see ‘Paths’ tab of the Flex module configuration)

  3. Anton Makeev says:

    October 2, 2009

    Hi,

    If you want some specific Maven goal to be executed on each make, you can right-click a project in the Maven Projects tool window and select ‘Execute Before/After Make’ or you can go to any Run Configuration and set ‘Before Make’ task.

    Thanks,
    Anton Makeev

  4. Christian says:

    November 26, 2009

    Hi,

    I’ve got a pretty large project here and was experimenting with IntelliJ9 Beta and the improved flex/maven support. The project is basically made up of a java server part and flex client. The project is defined using maven + flexmojos 3.4.

    I imported the project fairly quickly and got it compiling after some minor tweaks.
    However, when Making the project, all flex facets are always recompiled, even if nothing changed. Compiling the 10+ flex facets takes about 5 minutes so you can see why it’s a problem. Is that expected behavior? If not, what could be the problem?

    Thanks,
    Christian

  5. Alexander Doroshko says:

    November 27, 2009

    Christian,
    please try following:
    – increase memory of Flex compiler (-Xmx parameter at 2nd screenshot).
    – try latest EAP (http://www.jetbrains.net/confluence/display/IDEADEV/Maia+EAP). A workaround for Flex compiler problem is implemented there (http://youtrack.jetbrains.net/issue/IDEADEV-39903)

    Please write if it resolves your problem.

  6. Christian says:

    November 27, 2009

    That seems to work! Thanks.

    I’ve got another question I’d like to ask though. Our flex swf’s are compiled in both debug and non-debug mode.
    For this, our maven structure for a flex app is as follows:

    – pom.xml (aggregate pom)
    – src/
    – config/
    – pom.xml (contains src path, flexmojos config, dependencies)
    – release/
    – pom.xml (sets flexmojos debug flag to false)
    – debug/
    – pom.xml (sets flexmojos debug flag to true)

    The debug and release pom’s have the config pom as parent.

    When importing this structure, sources for this app are not bound to any module. I guess that is because IntelliJ does not support having 2 modules sharing the same sources?
    After adding the sources manually to the aggregate module, code still shows up red because dependencies are set on the debug & release modules only.
    So there is quite some manual tweaking to do for this to work.

    I was wondering if there is a known maven structure we could use so that IntelliJ can import this without headaches?

    Christian

  7. Anton Makeev says:

    November 27, 2009

    Hi, Christian,

    Have you considered to use Maven profiles? You could have one pom and configure it according to enable debug features only if some profile is activated; IDEA allows you to choose what profile to use.

    Thanks,
    Anton Makeev

  8. Christian says:

    November 30, 2009

    The thing is that the team wants both debug and non-debug versions in the same build. I tried all kinds maven structures to make this compatible with intellij, without success though. Any other suggestions?

  9. Anton Makeev says:

    November 30, 2009

    You may configure Maven Run Configuration for specific profile and be able to run both debug and non-debug goals from IDEA for the same project.

  10. Christian says:

    November 30, 2009

    It has to work outside IntelliJ also. We use TeamCity as buildserver, and there we’d like to keep 1 build configuration that generates both debug and non-debug swf’s.

  11. Anton Makeev says:

    November 30, 2009

    I see, the problem is that it is not possible to import such configuration into IDEA – only one module can use some directory as a ‘source folder’, it cannot be shared.

    Try playing with plugin executions: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Subscribe

Subscribe for updates