如何告诉YUI压缩器maven插件输出到WAR文件和/或源目录?

时间:2012-08-08 08:47:18

标签: maven yui m2e yui-compressor

我正在尝试将YUI压缩器添加到我的JSF eclipse maven项目中。我不是maven专业人士,我只是使用m2e maven插件来解析我的依赖项并右键单击我的项目并将其导出到.WAR文件。此时,YUI压缩器插件正在工作,并在我更改并保存资源(即html文件)时压缩所有css和javascript文件。我的问题是,它既不会将压缩文件放回MyProject/src/main/webapp/resources/css|js,也不会放回生成的.WAR文件中。它将它们放入MyProject/target/app-0.01-SNAPSHOT/resources/css|js,似乎没有(?)使用。如何设置它以将文件放入原始输入目录中的.WAR文件(所以我可以看到并将它们包含在我的html文件中)?我在这里读了几个帖子,但找不到解决方案。

以下是我pom.xml的相关部分:

<build>

    <plugins>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.3.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>

            <!-- I was playing around with this. At this point, the following does the same as the default
            setting, i.e. putting the files into the /target/ directory, which is not what i want/need. -->
            <configuration>
                <sourceDirectory>${project.basedir}/src/main/webapp/resources/js</sourceDirectory>
                <outputDirectory>${project.build.directory}/${project.build.finalName}/resources/js</outputDirectory>
            </configuration>

        </plugin>
    </plugins>

    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>net.alchim31.maven</groupId>
                                    <artifactId>yuicompressor-maven-plugin</artifactId>
                                    <versionRange>[1.3.0,)</versionRange>
                                    <goals>
                                        <goal>compress</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute>
                                        <runOnIncremental>true</runOnIncremental>
                                    </execute>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

</build>

0 个答案:

没有答案