Fingers crossed you can help me!
I am using SmartSprites to combine the PNGs on my landing page into one, so that it will load quicker.
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:
- SmartSprite scans my CSS file: mystyle.css
- SmartSprite create a sprite image, and creates a new mystyle-sprite.css file, which references the new sprite image.
- 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.
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.
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>
I'm afraid you won't find anything simpler or more elegant than Maven AntRun Plugin with something like this:
You can use the Maven WAR plugin:
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 emptycss-file-suffix
value.