1

我正在尝试将 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>
4

0 回答 0