본문 바로가기
Homo Faber/Maven Definitive Guide

Maven에서 Flexmojo 사용하기

by javauser 2009. 10. 8.

기존 Maven : The Definitive Guide에는 없던 내용이 온라인 상으로 추가되었다. 다음은 http://www.sonatype.com/books/maven-book/reference/flex-dev.html 에 있는 원문을 참조하여 번역한 내용이다.

19장. Flexmojo로 개발하기

19.1 개요
이 장은 Flex 애플리케이션과 라이브러리를 개발하기 위해 Maven을 사용하는데 사람들이 관심있는 Flexmojo 프로젝트에 대한 개요를 제공한다.

19.2 Flexmojo의 빌드 환경 설정
Maven으로 Flex 라이브러리와 애프리케이션을 컴파일하기 전에, 다음의 두가지 설정 작업이 필요하다.
  • Flex 프레임워크를 포함하는 레파지토리를 참조하도록 Maven Settings 설정
  • Flex 단위 테스팅을 지원하기 위해 PATH에 Flash Player 추가
  • (선택사항) Sonatype 플러그인 그룹을 포함시키기 위해 Maven Settings 설정

19.2.1. Flex 프레임워크를 가지는 레파지토리 참조
Flexmojo에 대한 Maven 환경을 셋업하려면, 두가지 선택사항이 있다. pom.xml에 Sonatype Flexmojos 레파지토리를 직접적으로 참조하거나, 혹은 Nexus 를 설치하고 레파지토리 관리자에 프록시 레파지토리로 Sonatype Flexmojos 레파지토리를 추가한다. 가장 직접적인 방법은 레파지토리에 직접적으로 참조하는 것으로, Nexus를 다운로드하고 설치하는 것은 자체 빌드가 만들어내는 산출물들을 캐싱하고 관리할 필요가 있는 통제와 유연성을 제공한다. 만일 Flexmojo를 직접 사용하기 원한다면 다음의 19.2.1.1. "POM에서 Sonatype의 Flexmojos 레파지티로 참조"를 읽으면 된다. 만일 개발 팀을 지원하도록 장기적인 관점에서의 해결책을 설정하려면, 19.2.1.2. "Nexus를 사용한 Sonatype의 Flexmojos 레파지토리 프록싱"을 계속해서 읽어라.

만일 조직이 프록시 원격 레파지토리로 Sonatype 의 Nexus를 이미 사용하고 있다면, 단일 Nexus 그룹을 지정하는 변경된 ~/.m2/settings.xml을 가지고 있을 것이다. 그러한 상황이라면, 개발팀이 참조하는 Nexus Repository 그룹에 Sonatype Flexmojos 레파지토리 그룹에 대한 프록시 레파지토리인 http://repository.sonatype.org/content/groups/flexgroup/ 를 추가해야 한다. 이 원격 그룹에 대한 프록시 레파지티로를 추가하고 그 다음에 Nexus 설치의 public repository group에 이 그룹을 추가하면 Nexus에 접근하는 사람은 Sonatype의 repository.sonatype.org Nexus 인스턴스의 산출물들에 대한 접근이 가능할 것이다.

19.2.1.1. POM에 Sonatype의 Flexmojos 레파지토리 참조
Flexmojos는 중앙 Maven 레파지티로에서 현재 서비스되지 않는 몇가지 산출물들을 의존한다. 이러한 산출물들은 Sonatype이 운영하는 레파지토리에서부터 사용이 가능하다. Flexmojos를 사용하려면, 프로젝트의 pom.xml에 이 레파지토리를 참조할 필요가 있다. 이와 같이 하려면, 프로젝트의 pom.xml에 예제 19.1 "POM에 Sonatype의 Flexmojos 레파지티로에 대한 참조 추가"에 나타난 것처럼 repositories 요소를 추가한다.

예제 19.1 POM에 Sonatype의 Flexmojos 레파지티로에 대한 참조 추가

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
 
  <modules>
    <module>swc</module>
    <module>swf</module>
    <module>war</module>
  </modules>

  <repositories>
    <repository>
      <id>flexmojos</id>
      <url>http://repository.sonatype.org/content/groups/flexgroup/</url>
    </repository>
  </repositories>

</project>


위의 예제에 있는 XML은 산출물과 플러그인들을 다운받으려고 할 때 Maven이 시도하는 레파지토리 목록의 해당 레파지토를 추가하는 것이다.

19.2.1.2. Nexus를 사용해서 Sonatype의 Flexmojos 레파지토리 프록싱
Sonatype 의 Flexmojos 레파지토를 직접적으로 참조하는 대신에 Sonatype은 레파지토리 관리자를 설치하고 Sonatype의 public 레파지토리를 프록시하는 것을 권한다. Nexus와 같은 레파지토리 관리자를 사용해서 원격 레파지토리를 프록싱할 때 빌드가 외부 자원에 직접적으로 의존하지 않도록 제어와 안정성을 가질 수 있다. 이러한 통제와 안정성 외에도 레파지토리 관리자는 빌드가 만들어내는 바이너리 산출물에 대한 배포 대상을 제공한다. Nexus에 대한 다운로드, 설치, 설정에 대한 내용은 Nexus를 사용한 레파지토리 관리자의 설치장을 참조하라. 일단 Nexus가 설치되고 기동했다면, Sonatype의 public 레파지토리에 대한 프록시 레파지토리를 추가하기 위해 다음의 단계를 수행한다.

새로운 프록시 레파지토리를 추가하려면, Nexus UI의 좌측에 있는 Nexus 메뉴에서 Views/Repositories 밑에 있는 Repositories를 클릭한다. Repositories를 클릭하면 Repositories 패널이 로딩된다. Repositories 패널에서 Add.. 버튼을 클릭하고 그림 19.1 "Sonatype Nexus에 프록시 레파지토리 추가"에 나타난 Proxy Repository를 선택한다.


그림 19.1 Sonatype Nexus에 프록시 레파지토리 추가

새로운 Proxy 레파지토리가 생성되었다면, Sonatype Flexmojos 레파지토리를 설정할 필요가 있다. 새로운 repository를 선택하고, 창 하단부에 있는 Configuration 탭을 선택한다. 그림 19.2 "Sonatype Flexmojos 프록시 레파지토리 설정"에 나타난 것처럼 해당 값으로 필드를 채운다.
  • Repository ID는 "sonatype-flexmojos"
  • Repository Name은 "Sonatype Flexmojos Proxy"
  • Remote Storage Location은 "http://repository.sonatype.org/content/groups/flexgroup/"

그림 19.2 Sonatype Flexmojos 프록시 레파지토리 설정

위의 그림과 같이 설정을 했으면, 프록시 레파지토리를 저장하기 위해 Save 버튼을 클릭하고 Sonatype Flexmojos 레파지토 프록싱을 시작한다. Nexus는 public 레파지토리 그룹을 가지고 있느넫, 이는 몇가지 레파지토리들을 Maven 사용자를 위해 접근을 단일화시킨 지점으로 묶는다. 새로운 프록시 레파지토리에 대한 설정을 마무리하기 위해, 이 새로운 프록시 레파지토리를 Nexus public 그룹에 추가해야 한다. 이렇게 하려면, Repositories 패널의 상단에 보이는 repositories 목록으로 되돌아간다. Public Repositories 그룹을 클릭하고 Repository 패널의 하단에 있는 Configuration 탭을 클릭한다. Configuration 탭을 클릭하면 그림 19.3 "Public Repositories 그룹에 Sonatype Flexmojos 프록시 추가" 에 보이는 것과 같이 Group configuration이 나타난다.


그림 19.3 Public Repositories 그룹에 Sonatype Flexmojos 프록시 추가

Sonatype Public Proxy를 Public Repositories에 추가하려면 Available Repositories 목록에 있는 Sonatype Public Proxy 레파지토리를 선택하고 Ordered Group Repositories 목록에 이동시킨다. Save 버튼을 클릭하면 Sonatype Flexmojos 레파지토리에 대한 프록시를 Nexus 에 성공적으로 추가된다. 사용자는 레파지토리 그룹에 있는 산출물을 요청할 때마다, Nexus가 아직 해당 산출물을 캐싱하고 있지 않으면, Sonatype Flexmojos 레파지토리인 http://repository.sonatype.org/content/groups/flexgroup/ 에 질의를 보낸다. Nexus는 Sonatype Flexmojos 레파지토리로부터 가지고 온 모든 산출물에 대한 로컬 캐시를 관리하게 된다. 이 로컬 캐시를 통해 통제와 더 안정된 빌드 환경을 보장받게 된다. 만일 여러명의 개발자들이 Sonatype의 public 레파지토리의 산출물들을 의존하도록 세팅한다면, 필요한 산출물들이 Nexus 인스턴에 의해 캐싱되었으면 Sonatype의 레파지토가 가용하지 않더라도 완전히 자체적으로 포함되는 빌드 환경을 갖추게 된다.

마지막 단계는 방금 설정한 Nexus 인스턴스로 Maven 을 연결하는 것이다. 모든 레파지토리에 대해 미러로 Nexus 레파지토리 그룹을 사용하기 위해 Maven Settings를 변경할 필요가 있다. 이렇게 하려면, ~/.m2/settings.xml 파일에서 다음의 XML을 추가할 필요가 있다.

예제 19.2 로컬 Nexus 인스턴스에 대한 Settings XML
<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!—-Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!—-make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
위의 XML은 모든 설정된 레파지토리와 플러그인 레파지토리에 대해 단일 public 레파지티로 그룹을 찾도록 Maven을 설정한다. 산출물에 대한 모든 요청이 Nexus 를 통하도록 보장하는 간단한 방법이다.

19.2.2. Flex 단위 테스트를 지원하는 환경 설정
Flexmojos는 단위 테스트를 실행하는 독자적인 Flash 플레이를 설치할 수 있다. 이와 같이 하려면, PATH에 독자적인 Flash 플레이어를 추가하거나, -DflashPlayer.command 옵션을 사용해서 빌드에 Flash 플레이어 실행의 위치를 넘겨줄 필요가 있다. 단위 테스트를 실행할 때 Flexmojos는 독자적인 Flash 플레이어에 대한 다음의 플랫폼에 특수한 실행 파일을 기대한다.
MS 윈도우
Flexmojos는 FlashPlayer.exe 바이너리를 찾는다. 단위 테스트 실행을 지원하기 위해 PATH에 FlashPlayer.exe를 포함하는 디렉토리를 추가하거나 -DflashPlayer.command=${filepath} 명령행 옵션을 사용해서 Maven에게 FlashPlayer.exe 바이너리의 위치를 넘겨준다.
Macintosh OSX
Flexmojos는 "Flash Palyer" 어플리케이션 위치를 찾는다. 단위 테스트 실행을 지원하려면, PATH에 "Flash Player"를 포함하는 디렉토리를 추가하거나 -DflashPlayer.command=${filepath} 명령행 옵션을 사용해서 Maven에게 실행파일 경로를 넘겨준다.
Unix (Linux, Solaris 등)
Flexmojos는 flashplayer 실행파일을 찾는다. 단위 테스트 실행을 지원하려면, PATH에 flashplayer를 포함하는 디렉토리를 추가하거나 -DflashPlayer.command=${filepath} 명령행 옵션을 사용해서 Maven에게 실행파일의 경로를 넘겨준다.

유의
Linux에서 headless 빌드에서 단위테스트를 실행하려면 X virtual framebuffer (Xvfb)가 설치되어야 한다. Xvfb에 대한 더 상세한 정보는 여기를 참조하라.

만일 Adobe Flash CS4나 Adobe Flex Builder를 사용해서 Flash 애플리케이션을 개발하고 있거나 브라우저에서 플래시 내용을 보고 있다면, PC의 어딘가에 Flash player가 설치되었을 가능성이 있다. Flex 단위 테스트에 대해 이러한 플레이어 중에 하나를 사용하도록 Maven을 설정할 수도 있지만, Flash Player의 디버그 버전에서 실행하도록 설정하기 원할 것이다. 비호환성에 대한 잠재적인 문제를 최소화시키기 위해, 다음의 Flash Player 중에 하나를 다운로드 받아서 로컬 PC에 설치해야 한다. 해당 환경에 대한 독자적인 Flash Player를 다운로드 받는다.
위의 플레이어를 설치하고 OSX 머신에 PATH를 추가하려면, 다음과 같은 명령을 실행한다.
$ wget http://download.macromedia.com/pub/flashplayer/updaters/10/\
flashplayer_10_sa_debug.app.zip
$ unzip flashplayer_10_sa_debug.app.zip
$ sudo cp -r Flash\ Player.app /Applications/
$ export PATH=/Applications/Flash\ Player.app/Contents/MacOS:/usr/local/bin:/usr/local/maven/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/java/
latest/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin:/usr/local/bin

명령행에 PATH에 Flash Player에 대한 경로를 추가하는 대신에, 환경 프로파일을 설정해야 한다. OSX에서 ~/.bash_profile에 마지막 export 구문을 추가할 수도 있다.

19.2.3. Maven Settings의 Plugin Group에 Flexmojos 추가
명령행에서 Flexmojos goal을 실행할 필요가 있다면, Maven Settings에 Sonatype Plugin 그룹을 추가하면 좀 더 편해질 수 있다. 이와 같이 하려면, ~/.m2/settings.xml 을 열고 다음의 plugin group을 추가한다.

예제 19.3 Maven Settings에 Sonatype Plugin 추가
<pluginGroups>
  <pluginGroup>com.sonatype.maven.plugins</pluginGroup>
  <pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>

일단 Maven Settings에 위의 플러그인 그룹을 추가했으면, flexmojos 접두어 플러그인을 사용해서 Flexmojos goal을 호출할 수 있다. 이러한 설정이 없으면, flexbuilder goal을 호출하려면 다음과 같은 명령행을 호출해야 한다.
$ mvn org.sonatype.flexmojos:flexmojos-maven-plugin:3.2.0:flexbuilder
Maven Settings에 org.sonatype.plugins 그룹을 설정했다면, 다음과 같이 동일한 goal을 호출할 수 있다.
$ mvn flexmojos:flexbuilder

19.3 Archetype에서 Flexmojos 프로젝트 생성
Flexmojos는 새로운 Flex 프로젝트를 빨리 생성하기 위해 사용될 수 있는 몇가지 archetype들을 가지고 있다. 다음의 archetype들은 모두 org.sonatype.flexmojos 그룹에 있는 3.3.0 버전들이다.
flexmojos-archetypes-library
SWC를 만드는 간단한 Flex Library 프로젝트를 생성
flexmojos-archetypes-application
SWF를 만드는 간단한 Flex 애프리케이션을 생성
flexmojos-archetypes-modular-webapp
WAR를 생성하는 프로젝트에서 궁극적으로 화면에 나타나는 SWF를 만드는 프로젝트가 사용하는 SWC를 만드는 프로젝트로 구성된 다중 모듈 프로젝트를 생성

19.3.1. Flex Library 생성
Flex Library 프로젝트를 생성하려면, 명령행에서 다음의 명령을 실행한다.
$ mvn archetype:generate \
    -DarchetypeRepository=http://repository.sonatype.org/content/groups/public \
    -DarchetypeGroupId=org.sonatype.flexmojos \
    -DarchetypeArtifactId=flexmojos-archetypes-library \
    -DarchetypeVersion=3.3.0
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com.sonatype.maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : org.sonatype.test
Define value for artifactId: : sample-library
Define value for version:  1.0-SNAPSHOT: : 1.0-SNAPSHOT
Define value for package:  org.sonatype.test: : org.sonatype.test 
Confirm properties configuration:
groupId: org.sonatype.test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org.sonatype.test
 Y: : Y[INFO] Parameter: groupId, Value: org.sonatype.test
[INFO] Parameter: packageName, Value: org.sonatype.test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org.sonatype.test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

sample-library/ 디렉토를 보면, 프로젝트가 그림 19.4 "Flexmojo Library Archetype 파일 구조"에 나타나는 디렉토리 구조로 구성된다는 것을 볼 수 있을 것이다.

Flexmojo Library Archetype File Structure
그림 19.4 Flexmojo Library Archetype 파일 구조

간단한 Flex 라이브러리 archetype은 POM, 하나의 소스와 단위 테스트의 세개의 파일만을 포함하고 있다. 이들 각각의 파일에 대해서 살펴보자. 먼저 POM (Project Object Model)

예제 19.4 Flex Library Archetype에 대한 Project Object Model
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sonatype.test</groupId>
  <artifactId>sample-library</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swc</packaging>
  <name>test Flex</name>
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.2.0.3958</version>
      <type>pom</type>
    </dependency>
    <!-- flexmojos Unit testing support -->
    <dependency>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-unittest-support</artifactId>
      <version>3.3.0</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>


예제 19.4의 "Flex Library Archetype에 대한 Project Object Model"은 매우 단순하며, 이 POM의 핵심은 flexmojos-maven-plugin 설정의 extensions가 true로 세팅된 것이다. 이 설정은 flexmojos-maven-plugin에서 정의된 swc 패키징에 대한 생명주기를 바꾼다. 그 다음에 archetype은 flex-framework 의존관계와 flexmojos-unittest-support 테스트 영역의 의존관계를 포함한다. flex-framework 의존관계는 SWC 라이브러리들과 Flex 애플리케이션을 컴파일하는데 필요한 리소스들에 대한 참조를 포함하는 POM이다.
예제 19.4 "Flex Library Archetype에 대한 Project Object Model"에서 packaging은 매우 중요하다. POM의 packaging 타입은 빌드 결과를 만드는데 사용되는 생명주기를 조정한다. packaging 요소에 있는 swc 값은 flexmojos-maven-pluging이 제공하는 Flex에 특화된 생명주기를 검색하는 Maven의 특별한 선언이다. 위의 POM의 또 다른 중요한 부분은 Flex 소스 코드와 Flex 단위 테스트의 위치를 지정하는 build 요소이다. 다음에는 이 archetype이 만든 예제 Actionscript를 포함하고 있는 예제 19.5 "Flex Library Archetype의 예제 애플리케이션 클래스"를 간단하게 살펴보자.

예제 19.5. Flex Library Archetype의 예제 애플리케이션 클래스
package org.sonatype.test {
  public class App {
    public static function greeting(name:String):String {
      return "Hello, " + name;
    }
  }
}
위의 코드는 단순하지만, "여기에 코드를 입력하시오"와 같은 간략하고 빠른 틀을 제공한다. 이러한 간단한 코드를 테스트하는 것인 바보같이 보일 수 있지만, TestApp.as 라는 예제 테스트가 src/test/flex 디렉토리에 제공된다. 이 테스트는 예제 19.6 "Library Archetype의 App 클래스에 대한 단위 테스트"에 나타나있다.

예제 19.6 Library Archetype의 App 클래스에 대한 단위 테스트
package org.sonatype.test {
  import flexunit.framework.TestCase;
  public class TestApp extends TestCase {
    /**
     * Tests our greeting() method
     */
    public function testGreeting():void {
      var name:String = "Buck Rogers";
      var expectedGreeting:String = "Hello, Buck Rogers";
      var result:String = App.greeting(name);
      assertEquals("Greeting is incorrect", expectedGreeting, result);
    }
  }
}

이 빌드를 실행하려면, sample-library 프로젝트 디렉토리로 가서 mvn install을 실행한다.
$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-library Flex
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] [flexmojos:compile-swc]
[INFO] flexmojos 3.3.0 - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[WARNING] Nothing expecified to include.  Assuming source and resources folders.
[INFO] Flex compiler configurations:
-compiler.headless-server=false
-compiler.keep-all-type-selectors=false
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex/\
3.2.0.3958...
-compiler.namespaces.namespace http://www.adobe.com/2006/mxml
        target/classes/configs/mxml-manifest.xml
-compiler.optimize=true
-compiler.source-path src/main/flex
...
[INFO] [resources:testResources]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered \
        resources, i.e.  build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO] [flexmojos:test-compile]
[INFO] flexmojos 3.3.0 - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] Flex compiler configurations:
-compiler.include-libraries ~/.m2/repository/org/sonatype/flexmojos/\
        flexmojos-unittest-support...
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex
        3.2.0.3958/flex-3.2.0....
-compiler.optimize=true
-compiler.source-path src/main/flex target/test-classes src/test/flex
-compiler.strict=true
-target-player 9.0.0
-use-network=true
-verify-digests=true -load-config=
[INFO] Already trust on target/test-classes/TestRunner.swf
[INFO] [flexmojos:test-run]
[INFO] flexmojos 3.3.0 - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] flexunit setup args: null
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elpased: 0 sec
[INFO] [install:install]

주의
Flex 단위 테스트를 실행하려면 Flash Player가 포함된 PATH 환경 변수를 설정할 필요가 있다. 단위 테스트에 대한 Flexmojos 설정에 대한 더 자세한 정보는 19.2.2의 "Flex 단위 테스트를 지원하는 환경 설정"을 참고하라.
위의 프로젝트에 대한 mvn install을 실행하면 Maven과 Flexmojos 플러그인이 Flex 컴파일러에 대한 모든 라이브러리와 의존관계를 관리하고 있는 결과에 주목해야 한다. Maven이 자바 클래스패스의 내용을 관리하도록 자바 개발자를 도우는데 뛰어난 것처럼, Flex 개발자들을 위해 컴파일 경로에 대한 복잡성을 관리하는데 도움이 될 수 있다. Flexmojos 프로젝트가 웹 브라우저나 Flash Player를 기동하고 프로젝트의 소스 코드에 대한 TestApp.as 클래스를 실행하는데 사용하는 것에 놀랄 수도 있을 것이다.

19.3.2. Flex 애플리케이션 생성
Maven archetype에서 Flex 애플리케이션을 생성하려면, 다음과 같은 명령을 실행한다.
$ mvn archetype:generate \
    -DarchetypeRepository=http://repository.sonatype.org/content/groups/public \
    -DarchetypeGroupId=org.sonatype.flexmojos \
    -DarchetypeArtifactId=flexmojos-archetypes-application \
    -DarchetypeVersion=3.3.0

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com.sonatype.maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : org.sonatype.test
Define value for artifactId: : sample-application
Define value for version:  1.0-SNAPSHOT: : 1.0-SNAPSHOT
Define value for package:  org.sonatype.test: : org.sonatype.test
Confirm properties configuration:
groupId: org.sonatype.test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org.sonatype.test
 Y: : Y
[INFO] Parameter: groupId, Value: org.sonatype.test
[INFO] Parameter: packageName, Value: org.sonatype.test
[INFO] Parameter: basedir, Value: /Users/Tim/flex-sample
[INFO] Parameter: package, Value: org.sonatype.test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-application
[INFO] BUILD SUCCESSFUL

sample-application/ 디렉토리를 보면, 그림 19.5의 "Flex 애플리케이션 Archetype에 대한 디렉토리 구조"에 나타난 파일 구조를 볼 수 있을 것이다.

Directory Structure for Flex Application Archetype
그림 19.5 Flex 애플리케이션 Archetype에 대한 디렉토리 구조

애플리케이션 archetype으로 만들어진 애플리케이션을 만들면 다음과 같은 POM이 만들어진다.

예제 19.7. Flex 애플리케이션 Archetype에 대한 POM
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sonatype.test</groupId>
  <artifactId>sample-application</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swf</packaging>
  <name>sample-application Flex</name>
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.2.0.3958</version>
      <type>pom</type>
    </dependency>
    <!-- flexmojos Unit testing support -->
    <dependency>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-unittest-support</artifactId>
      <version>3.3.0</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>


예제 19.7의 "Flex 애플리케이션 Archetype에 대한 POM"과 예제 19.4의 "Flex Library Archetype에 대한 Project Object Model"과의 차이는 packaging 요소가 swc 대신에 swf 라는 것이다. packaging을 swf로 세팅함으로써 프로젝트는 target/sample-application-1.0-SNAPSHOT.swf에 Flex 애플리케이션을 만들게 된다. 이 archetype으로 만들어진 예제 애플리케이션은 "Hello World"라는 문자를 보여준다. Main.mxml이 src/main/flex에 있다.

예제 19.8. 예제 애플리케이션 Main.mxml
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Text text="Hello World!"/>
</mx:Application>


위 애플리케이션은 메시지 트레이스를 출력하는 것만 하는 FlexUnit 테스트를 만든다. 예제 단위 테스트가 src/test/flex/org/sonatype/test에 있다.

예제 19.9. Main.mxml에 대한 단위 테스트
package org.sonatype.test
{
        import flexunit.framework.TestCase;
        import Main;
        public class TestApp extends TestCase
        {
                public function testNothing():void
                {
                        //TODO un implemented
                        trace("Hello test");
                }
        }
}

19.3.3. 다중 모듈 프로젝트 생성 : Flex 의존관계를 가지는 웹 애플리케이션
Web 애플리케이션이 참조하는 Flex 애플리케이션과 다시 Flex 애플리케이션이 참조하는 Flex Library 프로젝트를 가지는 다중 모듈 프로젝트를 만들려면 다음과 같이 수행한다.
$ mvn archetype:generate \
    -DarchetypeRepository=http://repository.sonatype.org/content/groups/public \
    -DarchetypeGroupId=org.sonatype.flexmojos \
    -DarchetypeArtifactId=flexmojos-archetypes-modular-webapp \
    -DarchetypeVersion=3.3.0

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com.sonatype.maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : org.sonatype.test
Define value for artifactId: : sample-multimodule
Define value for version:  1.0-SNAPSHOT: : 1.0-SNAPSHOT
Define value for package:  org.sonatype.test: : org.sonatype.test
Confirm properties configuration:
groupId: org.sonatype.test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org.sonatype.test
 Y: : Y
[INFO] Parameter: groupId, Value: org.sonatype.test
[INFO] Parameter: packageName, Value: org.sonatype.test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org.sonatype.test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-multimodule
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
sample-multimodule/ 디렉토리를 살펴보면, swc, swf, war의 세개의 프로젝트를 포함하는 디렉토리 구조를 볼 수 있을 것이다.
Directory Structure for Flex Multimodule Archetype
그림 19.6. Flex 멀티모듈 archetype에 대한 디렉토리 구조

이 다중 모듈 프로젝트의 간단한 최상위 POM이 나타나있다. swc, swf, war 모듈을 참조하는 모듈로 구성한다.

예제 19.10. 모듈화된 웹 애플리케이션 archetype에 의해 생성된 최상위 POM
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                     http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sonatype.test</groupId>
  <artifactId>sample-multimodule</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
 
  <modules>
    <module>swc</module>
    <module>swf</module>
    <module>war</module>
  </modules>
</project>

swc 프로젝트는 예제 19.4의 "Flex Library Archetype에 대한 Project Object Model"에 나타난 POM과 유사한 간단한 POM을 가진다. 이 POM의 artifactId가 모듈 디렉토리의 이름과 다른 swc-swc 임을 유의하라.

예제 19.11. swc 모듈 POM
<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.sonatype.test</groupId>
    <artifactId>sample-multimodule</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>org.sonatype.test</groupId>
  <artifactId>swc-swc</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swc</packaging>
  <name>swc Library</name>
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
        <configuration>
          <locales>
            <locale>en_US</locale>
          </locales>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.2.0.3958</version>
      <type>pom</type>
    </dependency>
    <!-- flexmojos Unit testing support -->
    <dependency>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-unittest-support</artifactId>
      <version>3.3.0</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

swf 모듈의 POM은 예제 19.7의 "Flex 애플리케이션 archetype에 대한 POM"과 유사하며 swc-swc 산출물에 대한 의존관계가 추가되었다. 다음의 POM은 모듈을 저장하는 디렉토리와 다른 artifactId를 정의하고 있음을 유의하라. POM에 있는 artifactId는 swf-swf이다.

예제 19.12. swf 모듈 POM
<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.sonatype.test</groupId>
    <artifactId>sample-multimodule</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>org.sonatype.test</groupId>
  <artifactId>swf-swf</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swf</packaging>
  <name>swf Application</name>
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
        <configuration>
          <locales>
            <locale>en_US</locale>
          </locales>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.2.0.3958</version>
      <type>pom</type>
    </dependency>
    <!-- flexmojos Unit testing support -->
    <dependency>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-unittest-support</artifactId>
      <version>3.3.0</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.sonatype.test</groupId>
      <artifactId>swf-swc</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>swc</type>
    </dependency>
  </dependencies>
</project>

주의
예제 19.12의 "swf 모듈 POM"에서 "swf-swc"에 대한 의존관계는 "swc-swc"로 변경해야 한다. 이는 FlexMojos 3.3.0 릴리즈 버전에 있는 모듈화 webapp archetype의 버그이다. FlexMojos 3.4.0 릴리즈에서는 수정될 것이다.

SWC에 대한 의존관계를 선언할 때 의존관계에 대한 유형을 지정할 필요가 있는데, 그럼으로써 Maven은 원격 혹은 로컬 레파지토리에 적합한 산출물을 위치시킬 수 있다. 이 경우 swf-swf 프로젝트는 swc-swc 프로젝트가 생성한 SWC를 의존하고 있다. swf-swf 프로젝트에 대한 의존관계를 추가할 때 FlexMojos 플러그인은 Flex 컴파일러의 라이브러리 경로에 적절한 SWC 파일을 추가하게 된다.

다음엔 war 모듈에 있는 간단한 POM을 살펴보자.

예제 19.13. war 모듈 POM
<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>sample-multimodule</artifactId>
    <groupId>org.sonatype.test</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>org.sonatype.test</groupId>
  <artifactId>war-war</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <goals>
              <goal>copy-flex-resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.sonatype.test</groupId>
      <artifactId>war-swf</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>swf</type>
    </dependency>
  </dependencies>
</project>

주의
예제 19.13의 "war 모듈 POM"에서 "war-swf"에 대한 의존관계는 "swf-swf"로 바꾸어야 한다. 이는 FlexMojos 3.3.0 릴리즈에 있는 모듈화 webapp archetype의 버그이다. FlexMojos 3.4.0 릴리즈에서 수정될 것이다.

예제 19.13의 "war 모듈 POM"에 나타난 POM은 이 프로젝트의 copy-flex-resources goal을 실행하기 위한 FlexMojos 플러그인을 설정한다. copy-flex-resources goal은 SWF 애플리케이션을 웹 애플리케이션의 문서 루트에 복사하게 된다. 이 프로젝트에서 WAR를 빌드하고 생성하면 swf-swf-1.0-SNAPSHOT.swf 파일이 target/war-war-1.0-SNAPSHOT에 있는 웹 애플리케이션의 루트 디렉토리에 복사된다.
다중 모듈 웹 애플리케이션 프로젝트를 빌드하려면 최상위 디렉토리에서 mvn install을 실행한다. 이를 실행하면 swc-swc, swf-swf, war-war 산출물을 빌드하고 웹 애플리케이션의 문서 루트에 swf-swf-1.0-SNAPSHOT.swf를 포함하는 war/target/war-war-1.0-SNAPSHOT.war 에 WAR 파일을 생성한다.

유의
Flex 단위 테스트를 실행하려면 Flash Player를 포함하게끔 PATH 환경 변수를 설정해야 한다. 단위 테스트에 대한 FlexMojos 설정에 대한 더 자세한 정보는 19.2.2 "Flex 단위 테스트를 지원하는 환경 설정"을 참고하라.

19.4. FlexMojos 생명주기
FlexMojos Maven 플러그인은 packaging 을 기반으로 생명주기를 변경한다. 만일 프로젝트가 swc나 swf의 packaging을 가진다면, FlexMojos 플러그인은 플러그인 설정이 true로 되어 있으면 변경된 생명주기를 실행한다. 예제 19.14의 "변경 Flex 생명주기를 위한 플러그인 extensions 세팅"에서 extensions를 true로 세팅한 flexmojos-maven-plugin에 대한 플러그인 설정을 보여주고 있다.

예제 19.14. 변경 Flex 생명주기를 위한 플러그인 extensions 세팅
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
        <configuration>
          <locales>
            <locale>en_US</locale>
          </locales>
        </configuration>
      </plugin>
    </plugins>
  </build>


19.4.1 SWC 생명주기
packaging이 swc일 때 FlexMojos는 그림 19.7의 "FlexMojos SWC 생명주기"에 나타난 생명주기를 실행한다. 색깔이 다른 goal이 FlexMojos 플러그인의 goal들이며, 흰색의 goal은 핵심 Maven 플러그인의 표준 goal을 나타낸다.
The FlexMojos SWC Lifecycle
그림 19.7 FlexMojos SWC 생명주기

FlexMojos의 goal은 다음과 같다.
flexmojos:compile-swc
이 goal은 sourceDirectory에 있는 모든 ActionScript와 MXML을 SWC로 컴파일을 한다. SWC는 Flex 애플리케이션에서 사용되는 컴포넌트와 리소스를 포함하는 Adobe 라이브러리이거나 클래스 파일이다.
flexmojos:test-compile
이 goal은 testSourceDirectory에 있는 모든 ActionScript와 MXML 파일을 컴파일한다.
flexmojos:test-run
이 goal은 Flash Player를 사용해서 단위테스트를 실행한다. 이 goal은 19.2.2의 "Flex 단위테스트를 지원하는 환경 설정"에서 설명된 대로 Flash Player가 설정되었다면 실행시킬 수 있다.

19.4.2 SWF 생명주기
packaging이 swf 이면, FlexMojos는 그림 19.8의 "FlexMojos SWF 생명주기"에서 보이는 것과 같이 해당 생명주기를 실행한다. 색깔이 다른 goal들이 FlexMojos 플러그인의 goal이며, 흰색의 goal들이 핵심 Maven 플러그인의 goal들이다.

The FlexMojos SWF Lifecycle
그림 19.8 FlexMojos SWF 생명주기

FlexMojos의 goal은 다음과 같다.
flexmojos:compile-swf
이 goal은 sourceDirectory의 모든 ActionScript와 MXML 파일들을 SWF로 컴파일한다. SWF는 Adobe Flash Player나 Adobe AIR 소프트웨어에서 실행되는 애플리케이션을 포함하는 파일이다.
flexmojos:test-compile
이 goal은 testSourceDirectory의 모든 ActionScript와 MXML 파일을 컴파일한다.
flexmojos:test-run
이 goal은 Flash Player를 사용해서 단위테스트를 실행한다. 이 goal은 Flash Player가 19.2.2 "Flex 단위테스트를 지원하기 위한 환경 설정"에 설명된 것과 같이 설정되었다면 실행할 수 있다.

19.5 FlexMojos 플러그인 goal
FlexMojos Maven 플러그인은 다음과 같은 goal들을 포함한다.
flexmojos:asdoc
ActionScript 소스 파일에 대한 문서 생성
flexmojos:asdoc-report
Maven 사이트에 포함될 수 있는 보고서 형태로 ActionScript 소스에 대한 문서 생성
flexmojos:compile-swc
Flex나 AIR 애플리케이션에서의 사용을 위한 Flex 소스(ActionScript와 MXML)을 SWC 라이브러리로 컴파일
flexmojos:compile-swf
Adobe Flash Player나 Adobe AIR 실행에서의 사용을 위한 Flex 소스(ActionScript와 MXML)을 SWF로 컴파일
flexmojos:copy-flex-resources
웹 애플리케이션 프로젝트로 Flex 리소스 복사
flexmojos:flexbuilder
Adobe Flex Builder에서의 사용을 위한 프로젝트 생성
flexmojos:generate
Granite GAS3를 사용해서 Java 클래스 기반의 ActionScript 3 생성
flexmojos:optimize
swc 파일에 대한 post-linke SWF 최적화를 실행하는 goal. 이 goal은 RSL 파일을 생성하는데 사용
flexmojos:sources
Flex 프로젝트에 대한 모든 소스를 포함하는 JAR 생성
flexmojos:test-compile
Flex 프로젝트에 있는 모든 테스트 클래스 컴파일
flexmojos:test-run
Adobe Flash Player를 사용한 테스트 실행
flexmojos:test-swc
특정 프로젝트에 대한 테스트 클래스를 포함하는 SWC 빌드
flexmojos:wrapper
SWF 애플리케이션에 대한 HTML 랩퍼 생성

19.5.1 ActionScript 문서 생성
ActionScript를 위한 문서를 생성하는 asdoc이나 asdoc-report goal을 실행할 수 있다. 일단 goal이 실행되었으면, 문서는 ${basedir}/target/asdoc으로 HTML 형태로 저장된다. 그림 19.9의 "FlexMojos 플러그인에 의해 생성된 ActionScript 문서"는 FlexMojos 애플리케이션 archetype 프로젝트에 대한 asdoc을 실행한 결과를 보여준다.
Actionscript Documentation Generated by the FlexMojos Plugin
그림 19.9 FlexMojos 플러그인에 의해 생성된 ActionScript 문서

19.5.2. Flex 소스 컴파일
FlexMojos는 ActionScript와 MXML을 SWC와 SWF로 컴파일하는 많은 goal들을 포함한다. compile-swc와 compile-swf goal은 프로젝트의 소스로부터 결과물을 생성하는데 사용되며, test-compile은 단위테스트를 컴파일하는데 사용된다. FlexMojos archetype에 의해 생성된 간단한 프로젝트에서 compile-swc와 compile-swf goal이 프로젝트가 생명주기를 변경하고 compile 단계에 compile-swc나 compile-swf를 엮고 test-compile 단계에 test-compile 를 엮었기 때문에 호출된다. 만일 FlexMojos 컴파일러에 대한 옵션을 설정할 필요가 있다면, FlexMojos 플러그인 설정을 수행할 수 있다. 예를 들어, 예제 19.7의 "Flex 애플리케이션 Archetype에 대한 POM"에 나타난 POM을 사용한 애플리케이션에서 컴파일시 코드 수준의 경고를 모시하고 특정 폰트 세팅을 사용하고자 원한다면, 예제 19.15의 "Compiler 플러그인 변경"에 나타나 플러그인 configuration을 사용할 수 있다.

예제 19.15 Compile 플러그인 변경
<build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <extensions>true</extensions>
        <configuration>
          <configurationReport>true</configurationReport>
          <warnings>
            <arrayTostringChanges>true</arrayTostringChanges>
            <duplicateArgumentNames>false</duplicateArgumentNames>
          </warnings>
          <fonts>
            <advancedAntiAliasing>true</advancedAntiAliasing>
            <flashType>true</flashType>
            <languages>
              <englishRange>U+0020-U+007E</englishRange>
            </languages>
            <localFontsSnapshot>
              ${basedir}/src/main/resources/fonts.ser
            </localFontsSnapshot>
            <managers>
              <manager>flash.fonts.BatikFontManager</manager>
            </managers>
            <maxCachedFonts>20</maxCachedFonts>
            <maxGlyphsPerFace>1000</maxGlyphsPerFace>
          </fonts>
        </configuration>
      </plugin>
    </plugins>
  </build>


19.5.3 Flex Builder 프로젝트 파일 생성
FlexMojos 프로젝트에 대한 Flex Builder 프로젝트 파일을 생성하려면, 19.2.3 "Maven Settings의 Plugin Group에 FlexMojos 추가"에 설명된 대로 플러그인 그룹을 설정하고, flexbuilder goal을 실행한다.
$ mvn flexmojos:flexbuilder

위의 goal을 실행하면 다음과 같은 것들이 생성된다.
.project, .settings/org.eclipse.core.resources.prefs, .actionScriptProperties, .flexLibProperties

19.6 FlexMojos 플러그인 보고서
FlexMojos Maven 플러그인은 다음과 같은 보고서를 포함한다.
flexmojos:asdoc-report
Maven 사이트에 포함될 수 있는 레포트로 ActionScript 소스에 대한 문서 생성

19.6.1 ActionScript 문서 레포트 생성
Maven 사이트 빌드의 일부로 asdoc-report를 생성하려면 다음의 XML을 POM에 추가한다.

예제 19.16. ActionScript 문서 레포트 설정
<reporting>
  <plugins>
    <plugin>
      <groupId>org.sonatype.flexmojos</groupId>
      <artifactId>flexmojos-maven-plugin</artifactId>
      <version>3.3.0</version>
      <reportSets>
        <reportSet>
          <id>flex-reports</id>
          <reports>
            <report>asdoc-report</report>
          </reports>
        </reportSet>
      </reportSets>
    </plugin>
  </plugins>
</reporting>


mvn site를 실행할때 Maven은 위의 레포트를 생성하고 그림 19.10 "Maven Site의 ActionScript 문서 레포트"에서 보이는 것과 같이 "Project Reports"에 그 결과를 위치시킨다.
Actionscript Documentation Report on Maven Site
그림 19.10. Maven Site의 ActionScript 문서 레포트

만일 asdoc-report에 대해 configuration 옵션을 넘길 필요가 있다면, 예제 19.17의 "asdoc-report 설정"에 나타난 바와 같이 reportSets 요소에 설정 요소를 추가할 필요가 있다.

예제 19.17 asdoc-report 설정
<reporting>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.3.0</version>
        <reportSets>
          <reportSet>
            <id>flex-reports</id>
            <reports>
              <report>asdoc-report</report>
            </reports>
            <configuration>
              <windowTitle>My TEST API Doc</windowTitle>
              <footer>Copyright 2009 Sonatype</footer>
            </configuration>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>


19.7 Flexmojos 개발과 커스터마이징
다음은 Flexmojos 프로젝트에 대해 변경하거나 공헌하는 첫번째 단계로써 설명하는 내용이다. Flexmojos는 ActionScript를 SWF와 SWC 산출물로 컴파일하는데 관심이 있는 사람들을 위한 도구 이상의 것이며, 개발자들의 커뮤니티이다. 다음의 내용은 모든 사람을 위한 것은 아니지만, 해당 내용을 살펴보고 참여하기 원한다면, 동참하기 바란다.

19.7.1 Flexmojos 소스 코드 얻기
Flexmojos는 Sonatype Forge에서 관리되는 오픈 소스 프로젝트이며, Flexmojos의 소스 코드는 Sonatype Forge의 Subversion 레파지토리에 저장되어 있다. 웹 브라우저로 http://svn.sonatype.org/flexmojos/trunk 로 이동해서 Flexmojos Subversion 레파지토리의 내용을 볼 수 있다.
Flexmojos Subversion Repository
그림 19.11 Flexmojos Subversion 레파지토리

만일 Flexmojos 프로젝트에 참여하기를 희망하는 사람들은 로컬 PC에 현재의 Flexmojos 소스 코드를 체크아웃하기 원할 것이다. Subversion을 사용해서 Flexmojos 소스를 체크아웃하려면 다음과 같이 명령행에 해당 명령을 실행한다.
$ svn co http://svn.sonatype.org/flexmojos/trunk flexmojos
A flexmojos
...
$ ls
COPYRIGHT               flexmojos-sandbox         pom.xml
flexmojos-archetypes    flexmojos-super-poms      src
flexmojos-maven-plugin  flexmojos-testing
flexmojos-parent        flexmojos-touchstone

반응형