在构建WAR之前,在Maven中重命名生成的文件

Joh*_*lly 3 java css-sprites maven

越过你的手指可以帮助我!

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

SmartSprite将检查您的CSS文件,生成CSS Sprite图像,并创建一个新的CSS文件,该文件将使用此精灵图像而不是原始图像.我想要做的是在我的maven WAR构建期间自动用SmartSprite替换原始的CSS文件.

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

  1. SmartSprite扫描我的CSS文件:mystyle.css
  2. SmartSprite创建一个精灵图像,并创建一个新的mystyle-sprite.css文件,该文件引用新的精灵图像.
  3. 我想在构建 WAR之前在mystyle.css上复制mystyle-sprite.css,这样我就不必更改JSP文件中的任何引用.

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

下面是我用于SmartSprite的maven插件配置.

        <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>
Run Code Online (Sandbox Code Playgroud)

Mic*_*ski 20

我担心你不会发现比Maven AntRun插件更简单或更优雅的东西:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.7</version>
      <executions>
        <execution>
          <phase>prepare-package</phase>
          <configuration>
            <target>
              <copy file="${project.build.directory}/mystyle-sprite.css"
                tofile="${project.build.directory}/mystyle.css" />
            </target>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)