maven与flex的结合(flexmojos)

前段时间一直在研究maven,考虑使用maven来构建和整合项目,在普通web应用和java程序的构建上没什么问题,于是考虑把flex应用也整合进来,经过一番搜索,发现flexmojos这个maven插件目前比较成熟,功能也还算完善(如果有其他好的插件,也请大家告知),所以进行了flex整合maven的实验,在整合过程中发现一些问题,希望对大家有所帮助

1.首先,大家可以去看下flexmojos的文档,如何使用flexmojos里面都有提及https://docs.sonatype.org/display/FLEXMOJOS/Home

2.在使用过程中本人碰到的一些问题,可能比较低级,呵呵
1)在使用项目生成命令后,生成的pom文件如下,其中红色的是需要加的资源仓库,因为flexmojos依赖的几个jar文件在默认的maven资源仓库下是没有的,而且网上挺难找的,这个红色标注的资源仓库是其提供的,但是没有在其网站进行标示出来,而棕色的资源仓库,则是sonatype提供的资源仓库,但是其实里面没有包含所需的jar包(如果红色标示的资源仓库也因为防火墙的缘故无法下载,大家可以留下邮箱跟我索要)
<?xml version="1.0" encoding="UTF-8"?>
  <!--

    Copyright 2008 Marvin Herman Froeder
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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.reuental.flexdemo</groupId>
  <artifactId>Flexdemo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swf</packaging>

  <name>Flexdemo 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.6</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>

    <dependency>
      <groupId>com.adobe.flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>0.85</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile><!--https://docs.sonatype.org/pages/viewpage.action?pageId=2949459-->
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.maven.ide.eclipse</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>0.9.9-SNAPSHOT</version>
            <configuration>
              <mappingId>customizable</mappingId>
              <configurators>
                <configurator id='org.maven.ide.eclipse.configuration.flex.configurator' />
              </configurators>
              <mojoExecutions>
                <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
              </mojoExecutions>
            </configuration>
          </plugin>
        </plugins>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.4</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

  <repositories>
<repository>
<id>sonatype_repo</id>
<name>sonatype</name>
<url>http://repository.sonatype.org/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>


<repository>
<id>sonatype_snapshot</id>
<url>http://repository.sonatype.org/content/groups/forge</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>

  </repositories>

</project>


2)在对项目进行test,package或者install的时候,如果出现要求指定flash的路径,是因为自动测试需要flashplayer,可以先去(http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.exe)下载flashplayer的sa debug版本,然后改名为FlashPlayer.exe放置于项目pom所在目录,如果不希望FlashPlayer被包含于项目,也可以放置于自己喜欢的路径,然后在test,package,install等需要有测试过程的时候加入参数-DflashPlayer.command=路径,当然不需要自动测试的话,也可以在命令里加入参数-Dmaven.test.skip=true或者在配置文件配置test.skip=true

以上是在整合flexmojos时遇到的一些问题,希望能给大家一些帮助,当然,如果有更好的插件或者解决方案,也请大家告知我,谢谢!

猜你喜欢

转载自reuental.iteye.com/blog/652895