在构建WAR之前,在Maven中重命名生成的文件 [英] Rename a generated file in Maven before building WAR

查看:448
本文介绍了在构建WAR之前,在Maven中重命名生成的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手指越过你可以帮助我!

Fingers crossed you can help me!

我正在使用 SmartSprites 将我的目标网页上的PNG合并为一个,以便加载更快。

I am using SmartSprites to combine the PNGs on my landing page into one, so that it will load quicker.

SmartSprite将检查您的CSS文件,生成CSS Sprite图像,以及创建一个新的CSS文件,它将使用此精灵图像而不是原始图像。我想要做的是在我的maven WAR版本中自动用SmartSprite替换原始的CSS文件。

SmartSprite will examine your CSS files, generate a CSS Sprite image, and create a new CSS file which will use this sprite image instead of the originals. What I want to do is replace the original CSS file with the SmartSprite one automatically during my maven WAR build.

所以这就是我想要发生的事情:

So here's what I would like to happen:


  1. SmartSprite扫描我的CSS文件: mystyle.css

  2. SmartSprite创建精灵图像,并创建一个新的 mystyle-sprite.css 文件,该文件引用新的精灵图像。

  3. 我要复制 mystyle-sprite在构建WAR之前, mystyle.css 上的.css ,这样我就不必更改JSP文件中的任何引用。

  1. SmartSprite scans my CSS file: mystyle.css
  2. SmartSprite create a sprite image, and creates a new mystyle-sprite.css file, which references the new sprite image.
  3. I want to copy mystyle-sprite.css over mystyle.css before the WAR is built, so that I don't have to change any of my references in the JSP files.

这两个文件都位于输出目录(target / myproj / css)中。 SmartSprite中似乎没有任何标志可以覆盖原始文件,所以我想它必须在后处理时完成。

Both files are located in the output directory (target/myproj/css). There doesn't seem to be any flag in SmartSprite to override the original file, so I guess it had to be done post-processing.

以下是maven插件配置我正在使用SmartSprite。

Below is the maven plugin configuration I'm using for SmartSprite.

        <plugin>
            <groupId>org.carrot2.labs</groupId>
            <artifactId>smartsprites-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>spritify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>


推荐答案

您可以使用 Maven WAR插件

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <webResources>
            <resource>
                <directory><!-- Your output directory --></directory>
                <targetPath><!-- The target location of the files below --></targetPath>
                <includes>
                    <include><!-- file pattern --></include>
                    <include><!-- file pattern --></include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

您还应该配置SmartSprites以使用不同的输出目录来保留原始CSS文件名。尝试使用空 css-file-suffix 值的 output-dir-path 选项。

You should also configure SmartSprites to use a different output directory to preserve the original CSS filename. Try the output-dir-path option with an empty css-file-suffix value.

这篇关于在构建WAR之前,在Maven中重命名生成的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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