master
王兵 4 years ago
commit cb72cd1974

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -0,0 +1,26 @@
```java
<plugin>
<groupId>xyz.wbsite</groupId>
<artifactId>optimizer-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<tasks>
<task>
<taskType>COMPRESS_CSS</taskType>
<directory>src/main/resources/static/css/</directory>
<targetPath>target/classes/static/css/</targetPath>
<include>**/*.css</include>
<exclude>**/*.min.css</exclude>
</task>
</tasks>
</configuration>
</plugin>
```

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.wbsite</groupId>
<artifactId>optimizer-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<description>optimizer</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
</properties>
<repositories>
<!-- 将中央仓库地址指向阿里云聚合仓库,提高下载速度 -->
<repository>
<id>central</id>
<name>Central Repository</name>
<layout>default</layout>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<pluginRepositories>
<!-- 将插件的仓库指向阿里云聚合仓库解决低版本maven下载插件异常或提高下载速度 -->
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.7</version>
</dependency>
<!-- js和css优化插件 -->
<dependency>
<groupId>com.yahoo.platform.yui</groupId>
<artifactId>yuicompressor</artifactId>
<version>2.4.8</version>
</dependency>
<!-- html优化插件 -->
<dependency>
<groupId>com.googlecode.htmlcompressor</groupId>
<artifactId>htmlcompressor</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,10 @@
package xyz.wbsite.optimizer;
/**
* Created by LiuFa on 2017/10/14.
* xyz.wbsite.optimizer
* greatapp
*/
public interface Compressor<T> {
void compress(String fileName, T config);
}

@ -0,0 +1,174 @@
package xyz.wbsite.optimizer;
import com.googlecode.htmlcompressor.compressor.HtmlCompressor;
import com.googlecode.htmlcompressor.compressor.XmlCompressor;
import com.googlecode.htmlcompressor.compressor.YuiCssCompressor;
import com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.codehaus.plexus.util.FileUtils;
import xyz.wbsite.optimizer.compressor.SimpleJavaScriptCompressor;
import xyz.wbsite.optimizer.task.Task;
import xyz.wbsite.optimizer.util.FileUtil;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* @goal run
* @phase compile
* @execute phase="compile"
*/
public class Optimizer extends AbstractMojo {
/**
* @parameter
*/
private Task[] tasks;
public void execute() throws MojoExecutionException {
getLog().info("------------------------------------------------------------------------");
for (Task task : tasks) {
try {
File directory = task.getDirectory();
File targetPath = task.getTargetPath();
String include = task.getInclude();
String exclude = task.getExclude();
List fileList = FileUtils.getFiles(directory, include, exclude);
for (Object o : fileList) {
if (o instanceof File) {
File sourceFile = (File) o;
File targetFile = new File(targetPath, sourceFile.getAbsolutePath().substring(directory.getAbsolutePath().length()));
switch (task.getTaskType()) {
case COMPRESS_PLAIN:
compressPLAIN(sourceFile, targetFile);
break;
case COMPRESS_CSS:
compressCSS(sourceFile, targetFile);
break;
case COMPRESS_JS:
compressJS(sourceFile, targetFile);
break;
case COMPRESS_HTML:
compressHTML(sourceFile, targetFile);
break;
case COMPRESS_XML:
compressXML(sourceFile, targetFile);
break;
}
}
}
} catch (IOException e) {
// e.printStackTrace();
}
}
getLog().info("------------------------------------------------------------------------");
getLog().info("The optimization task has been completed.");
}
public void compressPLAIN(File sourceFile, File targetFile) {
try {
// 源文件大小
long sourceLength = sourceFile.length();
// 从源文件向目标复制文件
FileUtils.copyFile(sourceFile, targetFile);
// 对目标文件进行压缩
String string = FileUtil.readFileToString(sourceFile);
String targetString = FileUtil.trim(string);
FileUtil.writeStringToFile(targetString, targetFile, false, false);
// 目标文件压缩后的大小
long targetLength = targetFile.length();
// 打印压缩信息
getLog().info(targetFile.getName() + FileUtil.compressorInfo(sourceLength, targetLength));
} catch (Exception e) {
e.printStackTrace();
getLog().info(sourceFile.getAbsolutePath() + " compress failed");
}
}
public void compressCSS(File sourceFile, File targetFile) {
try {
// 源文件大小
long sourceLength = sourceFile.length();
// 从源文件向目标复制文件
FileUtils.copyFile(sourceFile, targetFile);
// 对目标文件进行压缩
YuiCssCompressor compressor = new YuiCssCompressor();
String compress = compressor.compress(FileUtil.readFileToString(sourceFile));
FileUtil.writeStringToFile(compress, targetFile, false, false);
// 目标文件压缩后的大小
long targetLength = targetFile.length();
// 打印压缩信息
getLog().info(targetFile.getName() + FileUtil.compressorInfo(sourceLength, targetLength));
} catch (Exception e) {
e.printStackTrace();
getLog().info(sourceFile.getAbsolutePath() + " compress failed");
}
}
public void compressJS(File sourceFile, File targetFile) {
try {
// 源文件大小
long sourceLength = sourceFile.length();
// 从源文件向目标复制文件
FileUtils.copyFile(sourceFile, targetFile);
// 对目标文件进行压缩
YuiJavaScriptCompressor compressor = new YuiJavaScriptCompressor();
String compress = compressor.compress(FileUtil.readFileToString(sourceFile));
FileUtil.writeStringToFile(compress, targetFile, false, false);
// 目标文件压缩后的大小
long targetLength = targetFile.length();
// 打印压缩信息
getLog().info(targetFile.getName() + FileUtil.compressorInfo(sourceLength, targetLength));
} catch (Exception e) {
e.printStackTrace();
getLog().info(sourceFile.getAbsolutePath() + " compress failed");
}
}
public void compressHTML(File sourceFile, File targetFile) {
try {
// 源文件大小
long sourceLength = sourceFile.length();
// 从源文件向目标复制文件
FileUtils.copyFile(sourceFile, targetFile);
// 对目标文件进行压缩
HtmlCompressor compressor = new HtmlCompressor();
compressor.setRemoveIntertagSpaces(true);
compressor.setCompressJavaScript(true);
compressor.setJavaScriptCompressor(new SimpleJavaScriptCompressor());
compressor.setCompressCss(true);
String compress = compressor.compress(FileUtil.readFileToString(sourceFile));
FileUtil.writeStringToFile(compress, targetFile, false, false);
// 目标文件压缩后的大小
long targetLength = targetFile.length();
// 打印压缩信息
getLog().info(targetFile.getName() + FileUtil.compressorInfo(sourceLength, targetLength));
} catch (Exception e) {
e.printStackTrace();
getLog().info(sourceFile.getAbsolutePath() + " compress failed");
}
}
public void compressXML(File sourceFile, File targetFile) {
try {
// 源文件大小
long sourceLength = sourceFile.length();
// 从源文件向目标复制文件
FileUtils.copyFile(sourceFile, targetFile);
// 对目标文件进行压缩
XmlCompressor compressor = new XmlCompressor();
String compress = compressor.compress(FileUtil.readFileToString(sourceFile));
FileUtil.writeStringToFile(compress, targetFile, false, false);
// 目标文件压缩后的大小
long targetLength = targetFile.length();
// 打印压缩信息
getLog().info(targetFile.getName() + FileUtil.compressorInfo(sourceLength, targetLength));
} catch (Exception e) {
e.printStackTrace();
getLog().info(sourceFile.getAbsolutePath() + " compress failed");
}
}
}

@ -0,0 +1,10 @@
package xyz.wbsite.optimizer;
public enum TaskType {
COMPRESS_PLAIN,//一般压缩(去除换行多余空格)
COMPRESS_CSS,
COMPRESS_JS,
COMPRESS_HTML,
COMPRESS_XML
}

@ -0,0 +1,20 @@
package xyz.wbsite.optimizer.compressor;
import com.googlecode.htmlcompressor.compressor.Compressor;
import java.util.regex.Pattern;
public class SimpleJavaScriptCompressor implements Compressor {
@Override
public String compress(String source) {
if (source == null || "".equals(source)) {
return source;
}
String result = source;
// 将空格、制表符、回车、换行符替换为空字符
result = Pattern.compile("//.*|\\s+|\t+|\r+|\n+").matcher(result).replaceAll(" ");
result = Pattern.compile("\\s?(=|:|;|,|:\\{|\\{|}|\\(|\\))\\s?").matcher(result).replaceAll("$1");
return result;
}
}

@ -0,0 +1,117 @@
package xyz.wbsite.optimizer.task;
import xyz.wbsite.optimizer.TaskType;
import java.io.File;
public class Task {
/**
* @parameter
*/
private TaskType taskType;
/**
* @parameter
*/
private File directory;
/**
* @parameter defaultValue="${project.basedir}/target"
*/
private File targetPath;
/**
* @parameter
*/
private String include;
/**
* @parameter
*/
private String exclude;
/**
* @parameter :,
*/
private boolean JsConfigMunge = false;
/**
* @parameter :infowarn
*/
private boolean JsConfigVerbose = false;
/**
* @parameter :
*/
private boolean JsConfigPreserveAllSemiColons = false;
/**
* @parameter :
*/
private boolean JsConfigDisableOptimizations = false;
public TaskType getTaskType() {
return taskType;
}
public void setTaskType(TaskType taskType) {
this.taskType = taskType;
}
public File getDirectory() {
return directory;
}
public void setDirectory(File directory) {
this.directory = directory;
}
public File getTargetPath() {
return targetPath;
}
public void setTargetPath(File targetPath) {
this.targetPath = targetPath;
}
public String getInclude() {
return include;
}
public void setInclude(String include) {
this.include = include;
}
public String getExclude() {
return exclude;
}
public void setExclude(String exclude) {
this.exclude = exclude;
}
public boolean isJsConfigMunge() {
return JsConfigMunge;
}
public void setJsConfigMunge(boolean jsConfigMunge) {
JsConfigMunge = jsConfigMunge;
}
public boolean isJsConfigVerbose() {
return JsConfigVerbose;
}
public void setJsConfigVerbose(boolean jsConfigVerbose) {
JsConfigVerbose = jsConfigVerbose;
}
public boolean isJsConfigPreserveAllSemiColons() {
return JsConfigPreserveAllSemiColons;
}
public void setJsConfigPreserveAllSemiColons(boolean jsConfigPreserveAllSemiColons) {
JsConfigPreserveAllSemiColons = jsConfigPreserveAllSemiColons;
}
public boolean isJsConfigDisableOptimizations() {
return JsConfigDisableOptimizations;
}
public void setJsConfigDisableOptimizations(boolean jsConfigDisableOptimizations) {
JsConfigDisableOptimizations = jsConfigDisableOptimizations;
}
}

@ -0,0 +1,36 @@
package xyz.wbsite.optimizer.util;
/**
* Created by LiuFa on 2017/10/14.
* xyz.wbsite.optimizer.config
* greatapp
*/
public class FileInfo {
private String fileName;
private long fileLength;
private String fileSize;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public long getFileLength() {
return fileLength;
}
public void setFileLength(long fileLength) {
this.fileLength = fileLength;
}
public String getFileSize() {
return fileSize;
}
public void setFileSize(String fileSize) {
this.fileSize = fileSize;
}
}

@ -0,0 +1,386 @@
package xyz.wbsite.optimizer.util;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
public class FileUtil {
private static DecimalFormat df = new DecimalFormat("#.00");
/**
*
*
* @param sourceLength
* @return FileInfo
*/
private static String getFileSize(long sourceLength) {
if (sourceLength < 1024) {
return df.format((double) sourceLength) + "BT";
} else if (sourceLength < 1048576) {
return df.format((double) sourceLength / 1024) + "KB";
} else if (sourceLength < 1073741824) {
return df.format((double) sourceLength / 1048576) + "MB";
} else {
return df.format((double) sourceLength / 1073741824) + "GB";
}
}
/**
*
*
* @param sourceLength
* @param targetLength
* @return
*/
public static String compressorInfo(long sourceLength, long targetLength) {
long compressorLength = sourceLength - targetLength;
String rate = df.format((float) compressorLength / sourceLength * 100);
return String.format(Locale.getDefault(), " %s==>%s,%s%%", getFileSize(sourceLength), getFileSize(targetLength), rate);
}
public static String trim(String source) {
if (source == null || "".equals(source)) {
return source;
}
String result;
Pattern s = Pattern.compile("\\s{2,}");
result = s.matcher(source).replaceAll("\\s");
Pattern p = Pattern.compile("\t*|\r*|\n*");
result = p.matcher(result).replaceAll("");
return result;
}
public static List<String> readFileToLines(File filePath) {
return readFileToLines(filePath.getAbsolutePath());
}
public static List<String> readFileToLines(String fileName) {
List<String> returnString = new ArrayList<String>();
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读入一行直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
returnString.add(tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return returnString;
}
public static String readFileToString(File file) throws IOException {
byte[] bytes = readFileToByteArray(file);
return new String(bytes, "UTF-8");
}
public static byte[] readFileToByteArray(File file) throws IOException {
InputStream in = openInputStream(file);
Throwable var2 = null;
byte[] var5;
try {
long fileLength = file.length();
var5 = fileLength > 0L ? toByteArray(in, fileLength) : toByteArray(in);
} catch (Throwable var14) {
var2 = var14;
throw var14;
} finally {
if (in != null) {
if (var2 != null) {
try {
in.close();
} catch (Throwable var13) {
var2.addSuppressed(var13);
}
} else {
in.close();
}
}
}
return var5;
}
public static void writeBytesToFile(byte[] buffer, final File file) {
OutputStream output = null;
BufferedOutputStream bufferedOutput = null;
try {
output = new FileOutputStream(file);
bufferedOutput = new BufferedOutputStream(output);
bufferedOutput.write(buffer);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != bufferedOutput) {
try {
bufferedOutput.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != output) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static boolean writeStringToFile(String data, File file, boolean isNewLine, boolean isAppend) {
PrintWriter printWriter = null;
try {
printWriter = openPrintWriter(file);
if (isNewLine && isAppend) {// 换行追加
printWriter.println();
printWriter.append(data);
} else if (!isNewLine && isAppend) {// 不换行追加
printWriter.append(data);
} else {// 直接写入
printWriter.print(data);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (printWriter != null) printWriter.close();
}
}
public static PrintWriter openPrintWriter(File file) {
try {
return new PrintWriter(new FileOutputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
public static FileInputStream openInputStream(File file) throws IOException {
if (file.exists()) {
if (file.isDirectory()) {
throw new IOException("File '" + file + "' exists but is a directory");
} else if (!file.canRead()) {
throw new IOException("File '" + file + "' cannot be read");
} else {
return new FileInputStream(file);
}
} else {
throw new FileNotFoundException("File '" + file + "' does not exist");
}
}
public static FileOutputStream openOutputStream(File file) throws IOException {
if (file.exists()) {
if (file.isDirectory()) {
throw new IOException("File '" + file + "' exists but is a directory");
} else if (!file.canRead()) {
throw new IOException("File '" + file + "' cannot be read");
} else {
return new FileOutputStream(file);
}
} else {
throw new FileNotFoundException("File '" + file + "' does not exist");
}
}
/**
* @param fileLocation
* @return URL
*/
public static URL getURL(String fileLocation) {
try {
return new URL(fileLocation);
} catch (MalformedURLException var6) {
try {
return (new File(fileLocation)).toURI().toURL();
} catch (MalformedURLException var5) {
var5.printStackTrace();
}
}
return null;
}
public static byte[] toByteArray(InputStream input, long size) throws IOException {
if (size > 2147483647L) {
throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size);
} else {
return toByteArray(input, (int) size);
}
}
public static byte[] toByteArray(InputStream input, int size) throws IOException {
if (size < 0) {
throw new IllegalArgumentException("Size must be equal or greater than zero: " + size);
} else if (size == 0) {
return new byte[0];
} else {
byte[] data = new byte[size];
int offset;
int read;
for (offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) {
;
}
if (offset != size) {
throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size);
} else {
return data;
}
}
}
public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Throwable var2 = null;
byte[] var3;
try {
copy((InputStream) input, (OutputStream) output);
var3 = output.toByteArray();
} catch (Throwable var12) {
var2 = var12;
throw var12;
} finally {
if (output != null) {
if (var2 != null) {
try {
output.close();
} catch (Throwable var11) {
var2.addSuppressed(var11);
}
} else {
output.close();
}
}
}
return var3;
}
public static int copy(InputStream input, OutputStream output) throws IOException {
long count = copyLarge(input, output);
return count > 2147483647L ? -1 : (int) count;
}
public static boolean copy(File in, File out) throws Exception {
try {
FileInputStream input = new FileInputStream(in);
FileOutputStream output = new FileOutputStream(out);
copy(input, output);
input.close();
output.close();
return true;
} catch (IOException ie) {
return false;
}
}
public static long copyLarge(InputStream input, OutputStream output) throws IOException {
return copy(input, output, 4096);
}
public static long copy(InputStream input, OutputStream output, int bufferSize) throws IOException {
return copyLarge(input, output, new byte[bufferSize]);
}
public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException {
long count;
int n;
for (count = 0L; -1 != (n = input.read(buffer)); count += (long) n) {
output.write(buffer, 0, n);
}
return count;
}
public static boolean clearDirectory(File dir) {
if ((dir == null) || !dir.isDirectory()) {
throw new IllegalArgumentException("Argument " + dir +
" is not a directory. ");
}
File[] entries = dir.listFiles();
int sz = entries.length;
for (int i = 0; i < sz; i++) {
if (entries[i].isDirectory()) {
if (!clearDirectory(entries[i])) {
return false;
}
} else {
if (!entries[i].delete()) {
return false;
}
}
}
if (!dir.delete()) {
return false;
}
return true;
}
/**
* DOS/WindowsUNIX/Linux
* "\"全部换为"/"便
* "/""\"DOS/Windows
*/
public static String toUNIXpath(String filePath) {
return filePath.replace('\\', '/');
}
public static void inputStream2File(InputStream is, File target) {
try {
if (!target.exists() && !target.createNewFile()) {
throw new RuntimeException(target.getName() + "not exists");
}
OutputStream outStream = new FileOutputStream(target);
byte[] buffer = new byte[8 * 1024];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
outStream.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,67 @@
package xyz.wbsite;
import org.codehaus.plexus.util.FileUtils;
import xyz.wbsite.optimizer.Optimizer;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class TaskTest {
public static void main(String[] args) throws IOException {
{
System.out.println("=================================================CSS");
File directory = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\src\\main\\resources\\static");
File targetPath = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\target\\classes\\static");
String include = "**/*.css";
String exclude = "";
Optimizer optimizer = new Optimizer();
List fileList = FileUtils.getFiles(directory, include, exclude);
for (Object o : fileList) {
if (o instanceof File) {
File sourceFile = (File) o;
File targetFile = new File(targetPath, sourceFile.getAbsolutePath().substring(directory.getAbsolutePath().length()));
optimizer.compressCSS(sourceFile, targetFile);
}
}
}
{
System.out.println("=================================================JS");
File directory = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\src\\main\\resources\\static");
File targetPath = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\target\\classes\\static");
String include = "**/*.js";
String exclude = "**/*.min.js";
Optimizer optimizer = new Optimizer();
List fileList = FileUtils.getFiles(directory, include, exclude);
for (Object o : fileList) {
if (o instanceof File) {
File sourceFile = (File) o;
File targetFile = new File(targetPath, sourceFile.getAbsolutePath().substring(directory.getAbsolutePath().length()));
optimizer.compressJS(sourceFile, targetFile);
}
}
}
{
System.out.println("=================================================COMPRESS_HTML");
File directory = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\src\\main\\resources\\static");
File targetPath = new File("E:\\workspace\\dbtool\\target\\project\\wadmin\\target\\classes\\static");
String include = "**/*.ftl";
String exclude = "";
Optimizer optimizer = new Optimizer();
List fileList = FileUtils.getFiles(directory, include, exclude);
for (Object o : fileList) {
if (o instanceof File) {
File sourceFile = (File) o;
File targetFile = new File(targetPath, sourceFile.getAbsolutePath().substring(directory.getAbsolutePath().length()));
optimizer.compressHTML(sourceFile, targetFile);
}
}
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.