How to use archetypes

Maven Flex Plugin archetypes

The plugin contains three archetypes

  • flex-simple-swc-archetype: you may use this archetype to create a ActionScript library that does not use Flex SDK Framework.
  • flex-swc-archetype: you may use this archetype to create an ActionScript Library that uses Flex SDK Framework.
  • flex-swf-archetype: you may use this archetype to create a Flex Application project.

Generating a project with an archetype

The following command will generate a new project containing a "pom.xml" file and a folder named "src".

  mvn archetype:generate -DarchetypeCatalog="http://maven.servebox.org"

You will be prompted to choose one of the available archetypes

  Choose archetype:
  1: local -> flex-swf-archetype (Flex SWF Archetype)
  2: local -> flex-simple-swc-archetype (Simple SWC Library Archetype)
  3: local -> flex-swc-archetype (SWC Library Archetype)
  Choose a number:  (1/2/3): 

When you choose one of the available archetypes, you will be invited to enter the groupId of the project; you name it "com.company" for example

  Define value for groupId: : com.company

After that you should define the artifactId, it corresponds to the project's name :

  Define value for groupId: : myProject

In the next step you will be invited to set the project's version, the default value is "1.0-SNAPSHOT"

  Define value for version:  1.0-SNAPSHOT: : 1.0-SNAPSHOT

When it asks you to define the package, you can ignore it and let it empty. And finally confirm the creation of the project.

  Confirm properties configuration:
  groupId: com.company
  artifactId: myProject
  version: 0.1-SNAPSHOT
  package:
  Y: : Y

Now the project is created and ready to be used.

Generated project structure

The generated project structure from flex-swf-archetype is similar to what is shown just below

    ...
    +myProject
      +src
        +main
          +flex
            -main.mxml
            -MyClass.as
          +resources
          +test
            +test
              -TestMyClass.as
        -pom.xml
    ...

The generated project structure from flex-simple-swc-archetype and flex-swc-archetype will look like what is shown just below

   ...
    +myProject
      +src
        +main
          +flex
            -MyClass.as
          +test
            +test
              -TestMyClass.as
        -pom.xml
    ...