使用Maven构建Flex项目,包括样式表 [英] Using Maven to build Flex project including stylesheets

查看:156
本文介绍了使用Maven构建Flex项目,包括样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Flex样式表由编译器解析并与其资产(通常为图形)捆绑到一个swf文件中,然后可以在运行时加载。我有一个固定数量的样式的项目(目前4:旧企业风格,新的企业风格和两者的高对比度版本)。使用Flash Builder(Eclipse与Flex IDE插件)我可以将所有.css文件与主项目工件.swf文件一起编译为.swf文件。我们目前的理解是,Maven只需要为每个项目(POM文件)创建一个工件,但可能会添加一些附加的工件(POM文件)像拉链包装)。由于可扩展性原因 - 我有许多图书馆和模块项目的复杂设置,其中几个具有各自的样式表 - 将项目分成主项目和每个样式表的副本将是不切实际的。至少在Eclipse项目方面,每个都有一些POM文件的子文件夹,全部由主pom文件引用,并引用相同的src / location(并且在一个Eclipse项目中)可能会工作。虽然这是丑陋的,每个人都需要独立的工件,但仍然需要以某种方式进行组装。



重要的是能够有一个包含(Eclipse )将主要的swf文件和每个样式表swf文件(以及一些静态文件,如在运行时加载的本地化文本)。这将是我描述的几个项目的大型组合的一部分。在一个单独的问题



我正在使用Eclipse 3.6.1(Helios)与Flash Builder插件(即Flex4),定位Flex SDK 3.5(FlashPlayer 10.0)。我已经安装Maven 3.0.2,使用Sonatypes flexmojos-maven-plugin 3.7.1 (因为它似乎比 Servebox )。我已经为我的项目手动创建了pom文件,并且它们可以正常工作(尽管只编译一个swf工件文件,具体取决于是否将主要.as文件或其中一个.css文件指定为sourceFile)



我已经尝试了几天,以了解Maven Way(这似乎是为Java定制的,并不适合Flex),但是无法让它工作,所以我有一个单一的项目,或者至少有一个单一的组件,其中包含所有内容。



在这里做最好的方法是什么?

解决方案

我没有找到从同一个POM文件创建多个工件的方法,甚至不要多次运行flexmojo编译目标(即使在执行标签绑定时, Maven会抱怨)所以我发现最好的方法是使用一个非常相似的解决方案,我的整体项目,我已经描述

我只想为我的一个Eclipse项目插件,但需要几个文件夹才能使用多个POM。我的文件夹结构如下所示:

  colored_plugin / src / colored_plugin_main.as 
colored_plugin / src / green.css
colored_plugin / src / ...
colored_plugin / src / assets / rainbow.jpg< - 将嵌入到样式表swf文件
colored_plugin / WebContent / assets / labels.xlf
color_plugin / WebContent / config / config.xlf
colored_plugin / POMs / assembly / pom.xml
colored_plugin / POMs / plugin / pom.xml
colored_plugin / POMs / style1 / pom.xml
colored_plugin / pom.xml
master_build / pom.xml
master_build / swf-assembly.xml
master_build / css-assembly.xml
master_build / plugin-assembly.xml
master_build / assembly / pom.xml
master_build / assembly / final-asembly.xml

我使用master_build文件夹作为中心位置来存储我的简单swf项目的swf-assembly文件,所以我把包含样式表的插件的程序集描述符放在同一个位置。



POM c ompiling插件(POMs / plugin / pom.xml)非常类似于一个简单的swf项目(见其他问题):

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi: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> de.zefiro.maven.example< / groupId>
< artifactId> colored_plugin_internal< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< relativePath> ../../& lt; / relativePath>
< / parent>

< name>彩色插件(Plugin Executeable)< / name>
< artifactId> $ {project.parent.artifactId} _swf< / artifactId>
< packaging> swf< / packaging>

< build>
< sourceDirectory> ../../ src< / sourceDirectory>

<! - 此名称需要精确指定,因为运行时将按照配置xml - >中指定的方式加载它
< finalName> SampleProjectModuleColored< / finalName>

< plugin>
< groupId> org.sonatype.flexmojos< / groupId>
< artifactId> flexmojos-maven-plugin< / artifactId>
< version> 3.7.1< / version>
< configuration>
< sourceFile> colored_plugin_main.as< / sourceFile>
< / configuration>
< / plugin>

< plugins>
< plugin>
< artifactId> maven-assembly-plugin< / artifactId>
< configuration>
< descriptors>
< descriptor> ../../../ master_build / swf-assembly.xml< / descriptor>
< / descriptors>
< / configuration>
<执行>
< execution>
< id> WebContent-packaging< / id>
< phase> package< / phase>
< goals>< goal>单个< / goal>< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>

<依赖关系>
<依赖关系>
< groupId> $ {group-id}< / groupId>
< artifactId> project_swc< / artifactId>
< version> $ {project.version}< / version>
< scope> $ {zefiro.swf.scope}< / scope> <! - 告诉我们要使用运行时共享库​​(rsl)编译的Flex Mojo - >
< type> swc< / type>
< / dependency>
[...]
< / dependencies>

< / project>

样式表的POM是几乎相同的版本:.css文件被指定为源在这里(至少在我的情况下)不需要依赖关系,但是它仍然需要打包,以便稍后可以参考(并重新包装)它的汇编。

 <?xml version =1.0encoding =UTF-8?> 
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> de.zefiro.maven.example< / groupId>
< artifactId> colored_plugin_internal< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< relativePath> ../../& lt; / relativePath>
< / parent>

< name> Colored Plugin(Stylesheet'Green')< / name>
< artifactId> $ {project.parent.artifactId} _css_green< / artifactId>
< packaging> swf< / packaging>

< build>
< sourceDirectory> ../../ src< / sourceDirectory>
< finalName> style_green< / finalName>
< plugins>
< plugin>
< groupId> org.sonatype.flexmojos< / groupId>
< artifactId> flexmojos-maven-plugin< / artifactId>
< version> 3.7.1< / version>
< configuration>
< sourceFile> green.css< / sourceFile>
< / configuration>
< / plugin>
< plugin>
< artifactId> maven-assembly-plugin< / artifactId>
< configuration>
< descriptors>
< descriptor> ../../../ master_build / css-assembly.xml< / descriptor>
< / descriptors>
< / configuration>
<执行>
< execution>
< id> WebContent-packaging< / id>
< phase> package< / phase>
< goals>
< goal> single< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>

< / project>

汇编描述符也是一个简化版本,只打包swf文件。我不知道它是否需要,也许可以直接使用默认的Maven工件来完成装配,但是对于我来说,最简单的做法就像在其他项目中一样。

 < assembly 
xmlns =http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
xmlns :xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1 .0 http://maven.apache.org/xsd/assembly-1.1.0.xsd\">
< id>样式表< / id>
< formats>
< format> zip< / format>
< / formats>
< includeBaseDirectory> false< / includeBaseDirectory>
< fileSets>
<! - 采取样式表swf工件(只有,不是其中生成的其他东西) - >
< fileSet>
< directory> $ {project.build.directory}< / directory>
< outputDirectory> /< / outputDirectory>
< includes>
< include> *。swf< / include>
< / includes>
< / fileSet>
< / fileSets>
< / assembly>

装配项目有这个POM:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema -instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">
< modelVersion> 4.0.0< / modelVersion>

< parent>
< groupId> de.zefiro.maven.example< / groupId>
< artifactId> colored_plugin_internal< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< relativePath> ../../& lt; / relativePath>
< / parent>

< name> Colored Plugin(Assembly)< / name>
< artifactId> colored_plugin< / artifactId>
< packaging> pom< / packaging>

< build>
< plugins>
< plugin>
< artifactId> maven-assembly-plugin< / artifactId>
< version> 2.2.1< / version>
< configuration>
< descriptors>
< descriptor> ../../../ master_build / plugin-assembly.xml< / descriptor>
< / descriptors>
< / configuration>
<执行>
< execution>
< id> Plugin_assembly< / id>
< phase> package< / phase>
< goals>
< goal> single< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>

<依赖关系>
<依赖关系>
< groupId> $ {group-id}< / groupId>
< artifactId> $ {project.parent.artifactId} _swf< / artifactId>
< version> $ {project.version}< / version>
< type> zip< / type>
< classifier> WebContent< / classifier>
< / dependency>
<依赖关系>
< groupId> $ {group-id}< / groupId>
< artifactId> $ {project.parent.artifactId} _css_green< / artifactId>
< version> $ {project.version}< / version>
< type> zip< / type>
< classifier>样式表< / classifier>
< / dependency>
< / dependencies>
< / project>

插件汇编描述符将所有这一切包在一起。它也位于中央位置,因此以通用方式编写:它引用了来自调用POM的group-id和artifactId,并利用了我引用的名称约定。最终的项目将由程序集POM构建,因此我指定了'nice'artifactId。主项目POM(见下文)获取手工派生的名称,而所有其他项目(主应用程序和所有样式表)都将从此自动导出,并生成仅在内部使用的Maven工件。我有多个样式表,所以我的实际程序集POM列出了多个样式表依赖(与此示例相反),而我的程序集描述符全部使用通配符。

 < assembly 
xmlns =http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
xmlns: xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1。 2 http://maven.apache.org/xsd/assembly-1.1.2.xsd\">
< id> WebContent< / id>
< formats>
< format> zip< / format>
< / formats>
< includeBaseDirectory> false< / includeBaseDirectory>
< fileSets>
<! - 添加WebContent文件夹 - >
< fileSet>
< directory> ../../ WebContent< / directory>
< outputDirectory> /< / outputDirectory>
< / fileSet>
< / fileSets>
< dependencySets>
<! - 添加插件主可执行文件 - >
< dependencySet>
< includes>
< include> $ {group-id}:$ {project.parent.artifactId} _swf:zip:WebContent:$ {project.version}< / include>
< / includes>
< useProjectAttachments> true< / useProjectAttachments>
< unpack> true< / unpack>
< outputDirectory> /< / outputDirectory>
< / dependencySet>
<! - 添加样式表 - >
< dependencySet>
< includes>
< include> $ {group-id}:$ {project.parent.artifactId} _css _ *:zip:样式表:$ {project.version}< / include>
< / includes>
< useProjectAttachments> true< / useProjectAttachments>
< unpack> true< / unpack>
< outputDirectory> / assets / styles< / outputDirectory>
< / dependencySet>
< / dependencySets>
< / assembly>

请注意,我使用与我用于简单swf项目的此汇编描述符相同的ID (如我的另一个问题所示)。这使得在整个程序集插件中更容易指定正确的工件,因为我可以使用WebContent作为所有项目的分类器。



最后,主POM因为我的项目只是其他POM的一个小调用者:

 <?xml version =1.0encoding =UTF -8\" >?; 
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> de.zefiro.maven.example< / groupId>
< artifactId> full_build< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< relativePath> ../ master_build< / relativePath>
< / parent>

< name>彩色插件< / name>
< artifactId> colored_plugin_internal< / artifactId>
< packaging> pom< / packaging>

< modules>
< module> pom / plugin< / module>
< module> pom / style1< / module>
< module> pom / assembly< / module>
< / modules>

< / project>

可以通过以下方式添加新的样式表:




  • 将red.css样式表和所有附带文件添加到src /目录

  • 将Colored_plugin / POMs / style1 / pom.xml复制到colored_plugin / POMs /style2/pom.xml

  • 将其添加到color_plugin / pom.xm作为模块

  • 将其添加到colored_plugin / POMs / assembly / pom。作为依赖关系

  • 由于通配符和命名约定,程序集描述符(/master_build/plugin-assembly.xml)不需要更改



最终的项目工件是一个zip文件,由我的主程序集消耗(并与其他项目合并),并包含这些文件:

  SampleProjectModuleColored.swf 
assets / labels.xlf
assets / styles / style_green.swf
config / config.xlf

它将作为



<$ p存储在存储库中$ p> de.zefiro.maven.example:彩色_plugin:zip:WebContent:1.0-SNAPSHOT


Flex stylesheets are parsed by the compiler and bundled with their assets (graphics, usually) into a swf file, which can then be loaded at runtime. I've got a project with a fixed number of styles (currently 4: old corporate style, new corporate style, and high contrast versions of both). Using Flash Builder (Eclipse with Flex IDE plugin) I'm able to have all .css files compiled to .swf files alongside the primary project artifact .swf file. This is also possible with ant scripts.

My current understanding is that Maven wants to only create one artifact per project (POM file), but may have some additional ones added (like zip packaging). For scalability reasons - I've got a complex setup of many library and module projects, several of them having their own individual stylesheets - it would be very impractical to split up the projects into the 'main' project and copies for each stylesheet. At least on the Eclipse project side, having some subfolders with POM files in each, all refered by a master pom file and referring the same src/ location (and being inside one Eclipse project) would probably work. Though that's ugly and needs individual artifactIds for each, and still need to be assembled somehow.

The important thing is to be able to have a final assembly which contains the (Eclipse) projects main swf file and each stylesheets swf file (and some static files like localized texts to be loaded at runtime). This will be part of a large assembly of several of those projects which I've described in a separate question.

I'm using Eclipse 3.6.1 (Helios) with Flash Builder Plugin (i.e. Flex4), targetting Flex SDK 3.5 (FlashPlayer 10.0). I've installed Maven 3.0.2, using Sonatypes flexmojos-maven-plugin 3.7.1 (as it seems more active than the one from Servebox). I've manually created pom files for my projects and they work (though only compiling one swf artifact file, depending on whether I specify the main .as or one of the .css files as sourceFile)

I've tried for some days now to understand "The Maven Way" (which seems to be tailored for Java and not fitting perfectly for Flex), but couldn't get this to work so that I have a single project, or at least a single assembly with everything in it.

What would be the best way to do this here?

解决方案

I did not find a way to create multiple artifacts from the same POM file, not even to run the flexmojo compile target more than once (even when binding with execution tag, Maven will complain). So the best way I found was using a quite similar solution as for my overall project, which I've described in this question, including my solution, and which I suggest reading, as I'll base on that. I had hoped for a less hackish solution here, using this multi-project-approach seems a bit dirty to me. That's also why I split the question, which in turn got me the honor of being noticed by Jeff Atwood himself :)

I do want to use only one Eclipse project for my plugin, but need several folders to use multiple POMs. My folder structure looks like this:

colored_plugin/src/colored_plugin_main.as
colored_plugin/src/green.css
colored_plugin/src/...
colored_plugin/src/assets/rainbow.jpg          <- will be embedded into stylesheet swf file
colored_plugin/WebContent/assets/labels.xlf
colored_plugin/WebContent/config/config.xlf
colored_plugin/POMs/assembly/pom.xml
colored_plugin/POMs/plugin/pom.xml
colored_plugin/POMs/style1/pom.xml
colored_plugin/pom.xml
master_build/pom.xml
master_build/swf-assembly.xml
master_build/css-assembly.xml
master_build/plugin-assembly.xml
master_build/assembly/pom.xml
master_build/assembly/final-asembly.xml

I'm using the master_build folder as a central location to store my swf-assembly file for my simple swf projects, so I put my assembly descriptor for the plugins containing stylesheets in the same location.

The POM compiling the plugin (POMs/plugin/pom.xml) is quite similar to the one of the simple swf projects (see other question):

<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>de.zefiro.maven.example</groupId>
        <artifactId>colored_plugin_internal</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../../</relativePath>
        </parent>

    <name>Colored Plugin (Plugin Executeable)</name>
    <artifactId>${project.parent.artifactId}_swf</artifactId>
    <packaging>swf</packaging>

    <build>
        <sourceDirectory>../../src</sourceDirectory>

        <!-- This name needs to be exactly specified, as the runtime will load it as it's specified in the configuration xml -->
        <finalName>SampleProjectModuleColored</finalName>

        <plugin>
            <groupId>org.sonatype.flexmojos</groupId>
            <artifactId>flexmojos-maven-plugin</artifactId>
            <version>3.7.1</version>
            <configuration>
                <sourceFile>colored_plugin_main.as</sourceFile>
            </configuration>
        </plugin>

        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>../../../master_build/swf-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>WebContent-packaging</id>
                        <phase>package</phase>
                        <goals><goal>single</goal></goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>${group-id}</groupId>
            <artifactId>project_swc</artifactId>
            <version>${project.version}</version>
            <scope>${zefiro.swf.scope}</scope> <!-- tell Flex Mojo that we want to compile using runtime shared libraries (rsl) -->
            <type>swc</type>
        </dependency>
        [...]
    </dependencies>

</project>

The POM for the stylesheet is a nearly identical version of it: the .css file is specified as source, dependencies are not needed here (at least in my case), but it still needs to be packaged so that I can later reference (and repack) it for the assembly.

<?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>

    <parent>
        <groupId>de.zefiro.maven.example</groupId>
        <artifactId>colored_plugin_internal</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../../</relativePath>
    </parent>

    <name>Colored Plugin (Stylesheet 'Green')</name>
    <artifactId>${project.parent.artifactId}_css_green</artifactId>
    <packaging>swf</packaging>

    <build>
        <sourceDirectory>../../src</sourceDirectory>
        <finalName>style_green</finalName>
        <plugins>
            <plugin>
                <groupId>org.sonatype.flexmojos</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>3.7.1</version>
                <configuration>
                    <sourceFile>green.css</sourceFile>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>../../../master_build/css-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>WebContent-packaging</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

The assembly descriptor is also a simplified version, only packaging the swf file. I'm not sure it's needed and perhaps the assembly could be done with the default Maven artifact directly, but it was easiest for me to just do it like in every other project.

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>Stylesheet</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <!-- Take the stylesheet swf artifact (only, not the other stuff which is generated there) -->
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>*.swf</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

The assembly project has this 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.zefiro.maven.example</groupId>
        <artifactId>colored_plugin_internal</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../../</relativePath>
    </parent>

    <name>Colored Plugin (Assembly)</name>
    <artifactId>colored_plugin</artifactId>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <descriptors>
                        <descriptor>../../../master_build/plugin-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>Plugin_assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>${group-id}</groupId>
            <artifactId>${project.parent.artifactId}_swf</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <classifier>WebContent</classifier>
        </dependency>
        <dependency>
            <groupId>${group-id}</groupId>
            <artifactId>${project.parent.artifactId}_css_green</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <classifier>Stylesheet</classifier>
        </dependency>
    </dependencies>
</project>

The plugin assembly descriptor packs all this together. It's also in a central location and thus written in a generic way: It references group-id and artifactId from the calling POM and utilizing a name convention I've introduced. The final project will be build by the assembly POM, thus there I specify the 'nice' artifactId. The main project POM (see below) gets a manually derived name, while all other projects (main application and all stylesheets) are automatically derived from this and produce Maven artifacts which are only used internally. I've more than one stylesheet, so my real assembly POM lists multiple stylesheet dependencies (as opposed to this example), whereas my assembly descriptor takes them all using a wildcard.

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>WebContent</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <!-- add the WebContent folder -->
        <fileSet>
            <directory>../../WebContent</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>
    <dependencySets>
        <!-- add plugin main executable -->
        <dependencySet>
            <includes>
                <include>${group-id}:${project.parent.artifactId}_swf:zip:WebContent:${project.version}</include>
            </includes>
            <useProjectAttachments>true</useProjectAttachments>
            <unpack>true</unpack>
            <outputDirectory>/</outputDirectory>
        </dependencySet>
        <!-- add stylesheets -->
        <dependencySet>
            <includes>
                <include>${group-id}:${project.parent.artifactId}_css_*:zip:Stylesheet:${project.version}</include>
            </includes>
            <useProjectAttachments>true</useProjectAttachments>
            <unpack>true</unpack>
            <outputDirectory>/assets/styles</outputDirectory>
        </dependencySet>
    </dependencySets>
</assembly>

Note that I used the same ID for this assembly descriptor as I've used for the simple swf projects (as shown in my other question). This makes it easier to specify the correct artifact in the overall assembly plugin, as I can just use 'WebContent' as classifier for all my projects.

Finally, the main POM for my project is just a small caller for those other POMs:

<?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>

    <parent>
        <groupId>de.zefiro.maven.example</groupId>
        <artifactId>full_build</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../master_build</relativePath>
    </parent>

    <name>Colored Plugin</name>
    <artifactId>colored_plugin_internal</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>pom/plugin</module>
        <module>pom/style1</module>
        <module>pom/assembly</module>
    </modules>

</project>

A new stylesheet can be added by:

  • adding the red.css stylesheet and all accompanying files to the src/ directory
  • duplicating the colored_plugin/POMs/style1/pom.xml to colored_plugin/POMs/style2/pom.xml
  • adding it to colored_plugin/pom.xm as a module
  • adding it to colored_plugin/POMs/assembly/pom.xm as a dependency
  • due to the wildcard and naming convention, the assembly descriptor (/master_build/plugin-assembly.xml) does not need a change

The final project artifact is a zip file to be consumed (and merged with the other projects) by my master assembly and contains those files:

SampleProjectModuleColored.swf
assets/labels.xlf
assets/styles/style_green.swf
config/config.xlf

It will be stored in the repository as

de.zefiro.maven.example:colored_plugin:zip:WebContent:1.0-SNAPSHOT

这篇关于使用Maven构建Flex项目,包括样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆