📜 ⬆️ ⬇️

Flex Development in IntellliJ IDEA using maven

When developing in ActionScript, as in any other language, there are two questions: “What should I write?” And “What should I collect?”. If you are an advanced developer, you probably already use IntelliJ IDEA as IDE and maven as a build tool . This article shows the optimality of this solution and describes the process of setting up the working environment. If you do not like beer (and do not understand the meaning of this phrase and to whom I have just nodded) and do not consider yourself a lazy cattle, you can not waste your time.

The article is more like a spark than a step-by-step tutorial, especially as it is dedicated to EAP, so if you’re a really lazy brute without a drop of risk, then wait for the release :)


')
I note that the installation will be considered in Windows, but all software cross-platform - Unix, Mac and Windows (I myself only recently crawled to M $ Vista with openSUSE due to AIR). My machine configuration: ThinkPad T61, Intel Core 2 Duo T9300 (2.5 GHz), 2 GB RAM, Windows Vista SP1. On the storage server (you hardly need it) FreeBSD 6.3, nginx 0.6.32.

IDE Feature Overview


Until recently, there was no less realistic alternative to Flex Builder . But in the upcoming version of IntelliJ IDEA called Diana, a debugger appeared and Flex support was acceptable. What is IntelliJ IDEA and what can it do? Easier to say that she can not. She does not know how to make coffee (only indirectly, through IDE Talk ). Because of this, comparing it with the Flex Builder is equivalent to comparing the capabilities of a pedestrian with a race car in the context of passing a speed course.

Objectively:

Here you can write a very long list. She is really quite intelligent. You just try it (especially, of course, those who are working on large and complex projects will appreciate it). Flex Builder has only one advantage - profiling. Here in the comments the doubts went , so I’ll add a couple more possibilities that I should have listed first: Generate and Refactor .

Subjectively:

Assembly tool overview


Why is it needed at all if the IDE already supports compilation? If this is not obvious to you, I recommend reading the article in Wikipedia . Why maven , but not ant ? Because maven is a declarative, not an imperative assembly . A good selection of links about maven in Agahov's blog . At the moment, there is no real alternative to the flex-mojos plugin plugin that provides spells for Flex.

IDE installation


So. Now it's time to install it. We download the latest EAP (at the time of this writing, the last EAP is 8940, I recommend not saving a few MB and downloading an installer with a weight of 111 MB) and installing it. When you first start it asks about the settings, licenses, plugins, that is, it will make the initial configuration.
By the way, about the price . For open source projects it is free . For those involved in education, it is also free or offered at a significant discount. For personal use only costs $ 249. And Flex Builder 3 Standard is several times more expensive - as much as $ 249. Feel the difference. Therefore, I did not raise my hand in due time to buy it, but I paid for IntelliJ IDEA without hesitation even having the opportunity to get a free license.

When choosing the installed plugins, put only what you need, as this, of course, will reduce resource consumption (and also remove the excess from the interface). Subsequently, you can remove / add plugins in File -> Settings -> Plugins


After installation, I recommend immediately increasing the memory allocation for IDEA - open bin / idea.exe.vmoptions in its root folder: -Xms256m -Xmx512m -XX:MaxPermSize=128m
It may seem strange to you in the initial setting of the editor. But everything is customizable, the following describes a part of what I did not like and solutions:

If you use the maven, which is not advertised here by me, but the built-in IDE Builder, then to solve the problem of compiler error output in Russian (you also have a brain aversion to the Russian language in this context, yes?), Open bin / jvm.config in the Flex SDK and add the parameters -Duser.language=en -Duser.country=US (since IDE Builder uses fcsh), when building something else, change the JVM parameters in the appropriate place. If you use maven, read below.

Everything. Installed and opened. Remember, this is an EAP.


Installation tool assembly.


It does not need to be put. Maven is built into IDEA (but you can also specify to use external). But I still recommend setting it up. To eradicate the Russian language, set the environment variable MAVEN_OPTS = -Duser.language=en -Duser.country=US ). If you install it separately, I recommend changing the memory settings -Xms256m -Xmx512m -XX:MaxPermSize=128m (I separately installed from ports in FreeBSD - the installation went without problems).

Creating a project


Consider the development of the simplest project HelloWorld.

  1. File -> New Project
  2. At this step, you can change nothing and just click Finish. At the moment there are archetypes for flex-projects , but in order not to complicate things, we will not use the archetype.

After that the project will be open.


To compile the project, you do not need to manually download anything, but for the IDEA to work properly, it needs the source code of the Flex SDK. Download the latest stable build (at the time of writing it is 3.2.0.3794 from Thu Oct 23, 2008 ), unzip it somewhere and install it in IDEA.
  1. File -> Project Structure

    And point the way



    Unfortunately, IDEA now has an error in defining the Flex SDK by default for the Flex Facet (more precisely, there should not be a facet at all , remember that this is an EAP), so manually specify: File -> Project Structure -> Facets -> Flex HelloWorld )


    Now you can create.
    1. Rename (Refactor -> Rename or Shift + F6) the scr / main / java and src / test / java folders by changing java to flex respectively (they were carefully created by maven, if you create a project from the archetype, you will not need to rename anything).
    2. In accordance with the project structure proposed by maven, we will create a New Mxml Component.


    3. And paste the following code: [HelloWorld.mxml]
    4. Edit pom.xml: [pom.xml]
    5. After saving the changes, pom.xml IDEA will offer to re-import the project (that is, it will update everything it needs according to the new POM (yes, for now, it does it a little crookedly, but the developers have been notified and are working on it )).
    6. In the target folder, the result is HelloWorld-1.0.swf result.png


    I did not comment on the POM. References to already been given. I will note only that due to the fact that at present in the world of Flex maven is not very common, most of the libraries in the central repository is missing. You can add your maven project to the central repository , but the third-party library is unlikely, so for myself I raised the server (which is listed in the repositories), http://maven.flyti.org (if you need some kind of library, then you You can write to me and I will add it to my public repository, but it would be better to ask the creators to put them in the central one).

    Update 0 as a reply to a comment.
    I do not see any objective advantages for transferring my projects to a new IDE. A lot of crap for code coloring? Dismiss.

    If the listed objective advantages, such as maven and ant support, the possibility of working find usages without a query on the context, etc., is not enough for you, then I forgot two more main and most important advantages: Generate and Refactor .

    Update 1
    Dependency on artifact compiler should be in plugins, a real example of POM .

Source: https://habr.com/ru/post/43254/


All Articles