Skip to content

Commit

Permalink
Make magic string a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
hammerhead committed Nov 2, 2011
1 parent a77b234 commit 6189945
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/de/kabambo/maven/optipng/OptimizePngMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class OptimizePngMojo extends AbstractMojo {
*/
private static final String OPTIPNG_EXE = "optipng";

/**
* Optipng parameter specifying compression level.
*/
private static final String OPTIPNG_COMPRESSION_LEVEL_PARAM = "-o";

/**
* Timeout in seconds for processes to terminate.
*/
Expand Down Expand Up @@ -195,7 +200,6 @@ public void run() {

log.info(String.format("Optimized %s by %.2f kb (%.2f%%)",
image.getPath(), kbOptimized, percentageOptimized));

}
}

Expand All @@ -209,7 +213,7 @@ public void run() {
private Process startProcess(final File image) throws IOException {
List<String> args = new LinkedList<String>();
args.add(OPTIPNG_EXE);
args.add("-o");
args.add(OPTIPNG_COMPRESSION_LEVEL_PARAM);
args.add(String.valueOf(level));
args.add(image.getPath());
return new ProcessBuilder(args).start();
Expand All @@ -222,7 +226,7 @@ private Process startProcess(final File image) throws IOException {
* @param numberImages number of images to compress
* @return timeout in seconds
*/
private int calculateTimeout(int numberImages) {
private int calculateTimeout(final int numberImages) {
return numberImages * POOL_TIMEOUT + numberImages * level * 5;
}

Expand Down Expand Up @@ -261,3 +265,4 @@ private boolean verifyLevel() {
return level >= LEVEL_LOWER_BOUND && level <= LEVEL_UPPER_BOUND;
}
}

0 comments on commit 6189945

Please sign in to comment.