Features

Importing Flexmojos Projects to IntelliJ IDEA 8.1.3

IntelliJ IDEA 8.1.3 includes initial support for importing Flex projects that are set up using Flexmojos Maven plugin.

To start the import we need to have a compilable Flexmojos project that generates Flex compiler configuration file during compilation. Let’s take a Flexmojos application sample from the book Maven: The Definitive Guide, chapter 17 Developing with Flexmojos,  section 17.3.2. Creating a Flex Application.

  • Generate a Flexmojos project from the archetype as described in the book.
  • Configure it. IntelliJ IDEA will need a Flex compiler configuration file so we have to configure Flexmojos to save a configuration report. Debugging capabilities may also be configured if required. To achieve it we change project configuration a little bit (edit pom.xml file, added lines are highlighted with bold font):
    ...
    <plugin>
       <configuration>
          <configurationReport>true</configurationReport>
          <debug>true</debug>
       </configuration>
       <groupId>org.sonatype.flexmojos</groupId>
       <artifactId>flexmojos-maven-plugin</artifactId>
       <version>3.2.0</version>
       <extensions>true</extensions>
    </plugin>
    ...
  • Compile project using Maven (just type mvn compile in the command line): target directory is then generated. It contains compiled *.swf file, *-config-report.xml file and auxilary files in the classes sub-directory.

    We are ready to import the project to IntelliJ IDEA. The easiest way for that is to open pom.xml as if it was a native IntelliJ IDEA project file — click Open Project on the File menu and select this pom.xml.

    In order highlighting, completion and other coding assistance features to work properly, IntelliJ IDEA needs a configured Flex SDK. So, you must download an SDK of the same version that is used by Flexmojos compiler (3.2.0.3958 by default), add Flex SDK in the JDKs section of Project Structure dialog (Ctrl+Alt+Shift+S), and then set this SDK for the Flex facet that has been automatically created during import of Maven pom.xml.

    Note that configuration report created by Flexmojos is used in IntelliJ IDEA as a custom compiler configuration file. That’s why clicking Make Project, or pressing Ctrl+F9 creates sample-application-1.0-SNAPSHOT.swf file in the same way as Flexmojos compiler does.

    Now you can edit, compile, run and debug your Flex application right from IntelliJ IDEA.

    P.S. Flexmojos support is under active development for IntelliJ IDEA 9 (Maia) and is getting smarter and easier, so keep in touch with the latest EAP builds to see new and improved features.

image description

Discover more