如何在没有任何* .mxml文件的情况下编译maven / flex项目?

时间:2010-12-13 16:18:42

标签: actionscript-3 maven-2 flex4

有没有办法编译不包含任何* .mxml的maven / flex项目? flex项目仅包含ActionScript类(即“src / flex”目录仅包含* .as文件)。我的pom.xml在这里:

<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<name>test</name>
<packaging>swf</packaging>
<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.8</version>
            <extensions>true</extensions>
            <dependencies>
                <dependency>
                    <groupId>com.adobe.flex</groupId>
                    <artifactId>compiler</artifactId>
                    <version>4.5.0.18623</version>
                    <type>pom</type>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>com.adobe.flex.framework</groupId>
        <artifactId>flex-framework</artifactId>
        <version>4.5.0.18623</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>

“mvn package -e”抛出此错误:

[ERROR] Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:3.8:compile-swf (default-compile-swf) on project test: Source file not expecified and no default found! -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:3.8:compile-swf (default-compile-swf) on project q-integra-scorecard-ldservice: Source file not expecified and no default found!

2 个答案:

答案 0 :(得分:2)

尝试在&lt; plugin&gt;中添加此内容,其中“Main.as”是您的类:

<configuration>
    <sourceFile>Main.as</sourceFile>
</configuration>

答案 1 :(得分:1)

在我的情况下,我没有任何主要源文件(它是一个充满ISessionProxy.as等接口类的SWC)。

所以我必须做两件事来完成这项工作:

1)引用我的源目录(在build标签下):

<build>
    <sourceDirectory>src/main/flex</sourceDirectory>

2)按照我发现on this mail groupthe FlexMojos Google Group

的建议
  

“...只删除你的pom上的所有依赖项,因为这些依赖项   已经在超级pom上定义了。“

所以,我删除了所有依赖项并将它们一个接一个地添加回去,直到我编译它为止。我只需要:

<dependency>
    <groupId>com.adobe.flex.framework</groupId>
    <artifactId>flex-framework</artifactId>
    <version>${flex.sdk.version}</version>
    <type>pom</type>
</dependency>

我甚至删除了FlexMojos插件的所有依赖项:

<plugin>
    <groupId>org.sonatype.flexmojos</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <version>${flexmojos.version}</version>
    <configuration>
            <targetPlayer>${flash.player.version}</targetPlayer>
    </configuration>
</plugin>

这对我有用,产生了我需要的SWC,我希望它也可以帮助别人!