If you don't want to build an application but a library to share functionality among multiple applications, you have to create an "swc" library.

Flexmojos comes with an archetype for libraries too. 

In order to create a library application with the archetype, issue the following command:

mvn archetype:generate -DarchetypeGroupId=net.flexmojos.oss -DarchetypeArtifactId=flexmojos-archetypes-library -DarchetypeVersion=7.1.0

Same as with the application archetype you have to provide some settings. As soon as they are provided, the build should look similar to this:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO]<<< maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [net.flexmojos.oss:flexmojos-archetypes-library:7.1.0] found in catalog remote
Define value for property 'groupId': : org.apache.flex.examples
Define value for property 'artifactId': : my-first-flex-library
Define value for property 'version':  1.0-SNAPSHOT: : 1.0.0-SNAPSHOT
Define value for property 'package':  org.apache.flex.examples: : 
Confirm properties configuration:
groupId: org.apache.flex.examples
artifactId: my-first-flex-library
version: 1.0.0-SNAPSHOT
package: org.apache.flex.examples
 Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: flexmojos-archetypes-library:7.1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache.flex.examples
[INFO] Parameter: packageName, Value: org.apache.flex.examples
[INFO] Parameter: package, Value: org.apache.flex.examples
[INFO] Parameter: artifactId, Value: my-first-flex-library
[INFO] Parameter: basedir, Value: /Users/christoferdutz/Temp/examples
[INFO] Parameter: version, Value: 1.0.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /Users/christoferdutz/Temp/examples/my-first-flex-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.741s
[INFO] Finished at: Wed Apr 22 22:14:34 CEST 2015
[INFO] Final Memory: 15M/245M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "apache-release" could not be activated because it does not exist.
bash-3.2$ 

So now you'll find a directory "my-first-flex-library" containing the project.

In order to build the project do this:

cd my-first-flex-library
mvn install

You should see something similar to this:

[INFO] Scanning for projects...
[INFO]                                                                    
                                          `,;':,                :';;;  
                                         `:;''';'             `++'';;, 
                                         :;'''++;'           .+'+''';;;
                              :          ;'''++++''         ,';+++''';'
                  ,. `,  ,. ..: , `,    `'''+++##;'',      ;;'+#+++''''
                 ; ; ; ;; ;`: :,: ; ;    ;'+++;  #;;;;;:::;;;;+  +++'':
                 ; ; : ;; ;., : : ;.     ;;++#    ';;;;;;;;;;+   .+++; 
                 `;: :; `;: :;: , :;`     +;+#    ,;;;:::::;:    ;#+', 
      ;++++:'++      :                ;+,; ++;#    +;::::::;    ,+;;:  
     ++++++,'++                  `++'       +'''`   ;::::::,   +:;;:   
    `+++.   '++    ++++++  +++   +++         '''''   ;:::::   :;;;;    
    +++`    '++   ++++++++ +++` `++:         :'';;;   ;::`   :::::     
    +++     '++  +++'  :++: +++ +++           ;;;;;'        ::::::     
    +++     '++  +++    ++' `+++++`           ;;;;;;:      .:::::`     
    +++++++ '++  +++:::+++.  +++++            ;;;;;;;      ,:::::      
    +++++++ '++  +++++++++   :+++'            ;;;;;;;      ,:::::      
    +++'''  '++  +++;;;:`    +++++            ;;;;;;`      ::::::.     
    +++     '++  +++        +++ +++           ;;;;;:        ::::::     
    +++     :++. ++++   `  :++, ,++;         ''';;.   `..:   ::::;`    
    +++      ++'  +++++++  +++   +++        :''';    ,,,,,:   ;;;;;    
    ;++`     +++   ++++++ +++     +++      .+';+    :,,,,,,:   `';;;   
     ++'                                  `+'''    ::,,,,,:::    ';;'  
     :++                                  #;''    +:::,,,::::    .'':; 
                                         ';;''   ::::::::::::'   ,';;:.
                                         ;;;;''`;+;;::`  .::;;'.,';;;;:
                                        `::;;;''':;;       `;;;'';;;;;;
                                         :::;;;'';:          ;;';;;;;:;
                                         ,:::;;;',            ',;;;;::`
                                          .:::;:.              ;:;;::: 
                                           ::;,                 `,;;`  


[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-first-flex-library Flex 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ my-first-flex-library ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/christoferdutz/Temp/examples/my-first-flex-library/src/main/resources
[INFO] 
[INFO] --- flexmojos-maven-plugin:7.1.0:compile-swc (default-compile-swc) @ my-first-flex-library ---
[WARNING] No themes are explicitly defined in the <theme> section or in any scope="theme" dependencies. Flexmojos is now attempting to figure out which themes to include. (to avoid this warning you should explicitly state your theme dependencies)
[WARNING] Adding spark theme because spark.swc was included as a dependency
Writing configuration dump to /Users/christoferdutz/Temp/examples/my-first-flex-library/target/my-first-flex-library-1.0.0-SNAPSHOT-configs.xml
/Users/christoferdutz/Temp/examples/my-first-flex-library/target/my-first-flex-library-1.0.0-SNAPSHOT.swc (1914 bytes)
[INFO] 
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ my-first-flex-library ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/christoferdutz/Temp/examples/my-first-flex-library/src/test/resources
[INFO] 
[INFO] --- flexmojos-maven-plugin:7.1.0:test-compile (default-test-compile) @ my-first-flex-library ---
[INFO] Compiling test class: [org.apache.flex.examples.TestApp]
[WARNING] No themes are explicitly defined in the <theme> section or in any scope="theme" dependencies. Flexmojos is now attempting to figure out which themes to include. (to avoid this warning you should explicitly state your theme dependencies)
[WARNING] Adding spark theme because spark.swc was included as a dependency
Writing configuration dump to /Users/christoferdutz/Temp/examples/my-first-flex-library/target/test-classes/TestRunner-configs.xml
/Users/christoferdutz/Temp/examples/my-first-flex-library/target/test-classes/TestRunner.swf (894251 bytes)
[INFO] 
[INFO] --- flexmojos-maven-plugin:7.1.0:test-run (default-test-run) @ my-first-flex-library ---
[INFO] Running tests /Users/christoferdutz/Temp/examples/my-first-flex-library/target/test-classes/TestRunner.swf
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elapsed: 0 sec
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ my-first-flex-library ---
[INFO] Installing /Users/christoferdutz/Temp/examples/my-first-flex-library/target/my-first-flex-library-1.0.0-SNAPSHOT.swc to /Users/christoferdutz/Maven-Repository/org/apache/flex/examples/my-first-flex-library/1.0.0-SNAPSHOT/my-first-flex-library-1.0.0-SNAPSHOT.swc
[INFO] Installing /Users/christoferdutz/Temp/examples/my-first-flex-library/pom.xml to /Users/christoferdutz/Maven-Repository/org/apache/flex/examples/my-first-flex-library/1.0.0-SNAPSHOT/my-first-flex-library-1.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.085s
[INFO] Finished at: Wed Apr 22 22:19:05 CEST 2015
[INFO] Final Memory: 20M/693M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "apache-release" could not be activated because it does not exist.
bash-3.2$ 

The built library is available in the "target" directory. So if you open the file "my-first-flex-library-1.0.0-SNAPSHOT.swc".

If you are encountering problems in this step please have a look at the page: Preparing FDKs for Maven builds and Preparing your environment as probably these will help you sort out the problems.

Having a look at the details

For the details please have a look at the Your first Flex application document. The only main difference is the different packaging of type "swc" which makes Flexmojos create a Flash library.

  • No labels