Flexmojos-maven-plugin - 如何配置多个源mxml文件以生成多个swf文件?

时间:2018-02-07 11:01:47

标签: maven flex mxml flexmojos flex-mojos

当前工作代码:

我能够成功使用flexmojos-maven-plugin构建一个flex项目。但是,我只能在我的插件配置下提供一个'sourceFile'。请参阅下面的工作pom.xml,它从'src'目录正确构建Main.mxml文件。它成功生成了Main.mxml的'swf'文件:

<?xml version="1.0" encoding="UTF-8"?>
<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.test</groupId>
    <artifactId>TA_UI_Test2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>swf</packaging>
    <name>TA_UI_Test2 Flex</name>

    <dependencies>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>playerglobal</artifactId>
            <version>10-3.3.0.4852</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>rpc</artifactId>
            <version>4.5.1.21328</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>framework</artifactId>
            <version>3.2.0.3958</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>mx</artifactId>
            <version>4.5.0.19786</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>3.8</version>
                <extensions>true</extensions>
                <configuration>
                    <sourceFile>Main.mxml</sourceFile>
                    <debug>true</debug>
                    <storepass/>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.adobe.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>3.2.0.3958</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

    </build>

</project>

问题描述:

现在我的'src'目录下有多个其他mxml文件,即一个'src'目录下的所有mxml文件。如何在上面的插件中添加它们,只需要在sourceFile配置中使用一个名称?

我尝试过的事情:

我尝试复制粘贴多个flexmojos-maven-plugin块,并且每个块都指定了不同的sourceFile。但是,这没有用,因为maven只是从flexmojos-maven-plugin的最后一个块生成最终的'swf'文件。例如。如果第一个插件块有sourceFile Main.mxml,第二个插件块有sourceFile Secondary.mxml,则只为Secondary.mxml生成'swf',而不是Main.mxml。

您是否可以提供任何其他建议,使用单个pom / maven构建为各个mxml文件生成单独的swf文件?

1 个答案:

答案 0 :(得分:0)

经过相当多的研发,尝试了几次黑客攻击,并根据Christofer Dutz在this论坛上提出的宝贵建议,最终找到了一个干净的解决方案来解决上述问题。这是更新的pom.xml,它将为提供的源文件生成单独的swf文件:

<?xml version="1.0" encoding="UTF-8"?>
<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.test</groupId>
    <artifactId>TA_UI_Test2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>swf</packaging>
    <name>TA_UI_Test2 Flex</name>

    <dependencies>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>playerglobal</artifactId>
            <version>10-3.3.0.4852</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>rpc</artifactId>
            <version>4.5.1.21328</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>framework</artifactId>
            <version>3.2.0.3958</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>mx</artifactId>
            <version>4.5.0.19786</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>3.8</version>
                <extensions>true</extensions>
                <configuration>
                    <storepass></storepass>
                </configuration>
                <executions>
                    <execution>
                        <id>default-compile-swf</id> <!--DO NOT change this ID, else the plugin execution will fail.-->
                        <configuration>
                            <sourceFile>File1.mxml</sourceFile>
                            <debug>true</debug>
                            <output>${basedir}/target/File1.swf</output>
                        </configuration>
                        <goals>
                            <goal>compile-swf</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-compile-swf-2</id>
                        <configuration>
                            <sourceFile>File2.mxml</sourceFile>
                            <debug>true</debug>
                            <output>${basedir}/target/File2.swf</output>
                        </configuration>
                        <goals>
                            <goal>compile-swf</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-compile-swf-3</id>
                        <configuration>
                            <sourceFile>File3.mxml</sourceFile>
                            <debug>true</debug>
                            <output>${basedir}/target/File3.swf</output>
                        </configuration>
                        <goals>
                            <goal>compile-swf</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.adobe.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>3.2.0.3958</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

    </build>

</project>

重要提示:您必须提供任何一个执行的ID作为&#39; default-compile-swf&#39;,否则它将无法识别源文件。有关它将引发的错误的更多信息,请参阅我上面讨论的论坛的链接。

希望有一天能帮到某人:)