xjimmyshcn

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
【软件准备】
OS:centos 5.6 i386
持续集成服务器:hudson-2.1.0-beta
自动化构建工具:Maven:apache-maven-2.2.1    Maven支持Flex的插件:flexmojos-3.8
分布式版本管理:mercurial-1.8.4
JDK:java-1.6.0-openjdk
flashplayer for linux:flash_player_10_linux_dev
【flex相关库版本】

第一部分:Maven2.2.1及Flexmojos3.8安装配置

 
假设主目录为:/home/xjimmy
 
 
【安装java】
yum install java-1.6.0-openjdk        #install jre
yum install java-1.6.0-openjdk-devel  #install jdk
  
java -version
java version "1.6.0_20"

【安装mercurial(hg)】
yum install mercurial
hg --version
Mercurial Distributed SCM (version 1.8.4)
(see http://mercurial.selenic.com for more information)
  
【下载hudson,maven,flashplayer】
tar xzvf apache-maven-2.2.1-bin.tar.gz
 
tar xzvf flash_player_10_linux_dev.tar.gz
cd  /home/xjimmy/flash_player_10_linux_dev/standalone/debugger
tar xzvf flashplayer.tar.gz
cp flashplayer /home/xjimmy/apache-maven-2.2.1/bin  #将可执行flashplayer放到maven的bin目录下
 
【自启动脚本中加入环境变量】
vi /etc/profile
#加入如下内容
export JAVA_HOME=/usr/lib/jvm/java
export M2_HOME=/home/xjimmy/apache-maven-2.2.1
export PATH=$PATH:$M2_HOME/bin
#保存后,最好重登录,使环境变量生效
 
 

【创建flex webapp项目】
 
cd apache-maven-2.2.1
 
mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0_20
Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.18-238.el5" arch: "i386" Family: "unix"
 
 
#选择合适的flexmojos-maven-plugin版本呢,如3.8
 
【生成webapp项目】
mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.org/content/groups/flexgroup -DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-modular-webapp -DarchetypeVersion=3.8 
 

安装时,设置groupId和artifactId分别改为com.madeiracloudflex-maven-madeiracloud 其它默认。

 

【目录结构】

[root@instant_dev apache-maven-2.2.1]# tree flex-maven-madeiracloud/
flex-maven-madeiracloud/
|--
pom.xml

|-- app (由swf改成,自定义)
| |--
pom.xml
| `-- src
| `-- main
| `-- flex
| `-- Main.mxml
|--
lib_cmawslib (由swc改成,自定义)
| |--
pom.xml
| `-- src
| |-- main
| | `-- flex
| | `-- App.as
| `-- test
| `-- flex
| `-- TestApp.as
`-- war
    |--
pom.xml
    `-- src
        `-- main
            `-- webapp
                `-- WEB-INF
                    `-- web.xml

15 directories, 8 files

 
【修改/home/xjimmy/apache-maven-2.2.1/flex-maven-madeiracloud/pom.xml】
<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>com.madeiracloud</groupId>
  <artifactId>flex-maven-madeiracloud</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

<name>Flex Maven MadeiraCloud</name>
<!--
<repositories>
    <repository>
        <id>flex-mojos-repository</id>
        <name>sonatype</name>
        <url>http://repository.sonatype.org/content/groups/flexgroup</url>
    </repository>
    <repository>
        <id>flex-mojos-internal-repository</id>
        <url>http://repository.sonatype.org/content/groups/public</url>
    </repository>
   
    <repository>
       <id>flash-nexus-repository</id>
       <url>http://www.flashnexus.org/nexus/content/groups/public</url>
    </repository>

</repositories>
-->
<repositories>
    <repository>
        <id>sonatype-repo</id>
        <name>sonatype</name>
        <url>http://repository.sonatype.org/content/groups/flexgroup/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>sonatype-snapshot</id>
        <url>http://repository.sonatype.org/content/groups/flexgroup/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

  <modules>
    <module>lib_cmawslib</module>
    <module>app</module>
    <module>war</module>
  </modules>
</project>
 
----------------------------------------------------------------------------------
【修改/home/xjimmy/apache-maven-2.2.1/flex-maven-madeiracloud/lib_cmawslib/pom.xml】 
#备注:
#1.将本项目的源码放到/home/xjimmy/apache-maven-2.2.1/flex-maven-madeiracloud/lib_cmawslib/src目录下 
#2.本项目用到了第三方库,先用mvn install:install-file命令安装swc库到本地资料库
#[root@instant_dev lib_cmawslib]# mvn install:install-file -Dfile=as3corelib.swc -DgroupId=com.madeiracloud -DartifactId=as3corelib -Dversion=1.0 -Dpackaging=swc -DlocalRepositoryPath=libs
#[root@instant_dev lib_cmawslib]# mvn install:install-file -Dfile=as3crypto.swc -DgroupId=com.madeiracloud -DartifactId=as3crypto -Dversion=1.0 -Dpackaging=swc -DlocalRepositoryPath=libs
####################################################
<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>

  <parent>
    <groupId>com.madeiracloud</groupId>
    <artifactId>flex-maven-madeiracloud</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>com.madeiracloud</groupId>
  <artifactId>lib_cmawslib</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swc</packaging>

  <name>Flex Maven Library cmawslib</name>

  <properties>
        <flex.flashPlayer.command>/home/xjimmy/apache-maven-2.2.1/bin/flashplayer</flex.flashPlayer.command>
  </properties>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>src/test</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.8</version>
 <dependencies>
    <dependency>
      <groupId>com.adobe.flex</groupId>
      <artifactId>compiler</artifactId>
      <version>3.6.0.16995</version>
      <type>pom</type>
    </dependency>
 </dependencies>
        <extensions>true</extensions>
        <configuration>
          <locales>
            <locale>en_US</locale>
          </locales>
      <targetPlayer>10.0.0</targetPlayer> 
        <licenses>
                <flashbuilder4>????-????-????-????-????-????</flashbuilder4>
        </licenses>
        <testRunner>
          <launcher>
                <flashplayerCommand>/home/xjimmy/apache-maven-2.2.1/bin/flashplayer</flashplayerCommand>
          </launcher>
        </testRunner> 

      </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.6.0.16995</version>
      <type>pom</type>
    </dependency>

    <dependency>
      <groupId>com.adobe.flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>4.0-rc-1</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.madeiracloud</groupId>
      <artifactId>as3crypto</artifactId>
      <version>1.0</version>
      <type>swc</type>
    </dependency>

    <dependency>
      <groupId>com.madeiracloud</groupId>
      <artifactId>as3corelib</artifactId>
      <version>1.0</version>
      <type>swc</type>
    </dependency>

  </dependencies>

<!-- local repository -->
 <repositories>
       <repository>
            <id>custom-libs-local</id>
            <url>file:${project.basedir}/libs</url>
       </repository>
 </repositories>


</project>
 -------------------------------------------------------------------------------
【修改/home/xjimmy/apache-maven-2.2.1/flex-maven-madeiracloud/war/pom.xml】
#(此文件为dos格式,行尾带^M硬回车,需要使用dos2unix ./war/pom.xml 转换成unix格式)
<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>
  <parent>
    <artifactId>flex-maven-madeiracloud</artifactId>
    <groupId>com.madeiracloud</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>com.madeiracloud</groupId>
  <artifactId>war</artifactId>
  <version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
 
<name>Flex Maven War</name>

  <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.8</version>
        <executions>
          <execution>
            <goals>
              <goal>copy-flex-resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.17</version>
      </plugin>
    </plugins>
  </build>

<dependencies>
  <dependency>
    <groupId>com.madeiracloud</groupId>
    <artifactId>app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>swf</type>
  </dependency>
</dependencies>
</project>
 -----------------------------------------------------------------------------------
【开始构建】
cd /home/xjimmy/apache-maven-2.2.1/flex-maven-madeiracloud
mvn clean install
   看到以下内容表示构建成功。
  ... 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Flex Maven MadeiraCloud ............................... SUCCESS [3.060s]
[INFO] Flex Maven Library cmawslib ........................... SUCCESS [14.088s]
[INFO] Flex Maven Application ................................ SUCCESS [4.240s]
[INFO] Flex Maven War ........................................ SUCCESS [3.297s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 
[INFO] Finished at: Thu Jun 30 10:46:14 CST 2011
[INFO] Final Memory: 34M/129M
[INFO] ------------------------------------------------------------------------
channel stopped
[DEBUG] Skipping watched dependency update; build not configured with trigger: flex-maven-madeiracloud #10
Finished: SUCCESS
 至此,已经可以利用Maven+Flexmojos进行Flex Web项目的自动化构建。
 
未完待续... 
posted on 2011-06-30 11:36  xjimmyshcn  阅读(1819)  评论(2编辑  收藏  举报