|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.report;
|
|
|
|
|
|
+import com.uas.report.util.ArrayUtils;
|
|
|
import com.uas.report.util.ContextUtils;
|
|
|
import com.uas.report.util.FileUtils;
|
|
|
import com.uas.report.util.ReportUtils;
|
|
|
@@ -106,12 +107,25 @@ public class Application extends SpringBootServletInitializer implements Applica
|
|
|
if (!libDir.exists()) {
|
|
|
libDir.mkdirs();
|
|
|
}
|
|
|
+ String[] extractJars = ContextUtils.getBean(SystemProperties.class).getExtractJars();
|
|
|
+ if(ArrayUtils.isEmpty(extractJars)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 根据配置的 jar,创建相应的匹配规则
|
|
|
+ String pattern = "WEB-INF/lib/(";
|
|
|
+ for(int i = 0; i < extractJars.length; i++){
|
|
|
+ if(i != 0){
|
|
|
+ pattern += "|";
|
|
|
+ }
|
|
|
+ pattern += extractJars[i];
|
|
|
+ }
|
|
|
+ pattern += ")-[\\d.]+?[\\S]+?.jar";
|
|
|
ZipFile zipFile = new ZipFile(warFile);
|
|
|
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
|
|
while (entries.hasMoreElements()) {
|
|
|
ZipEntry zipEntry = entries.nextElement();
|
|
|
- // 只提取 jasperreports-$version.jar
|
|
|
- if (zipEntry.getName().matches("[\\s\\S]*?jasperreports-[\\d.]+?.jar")) {
|
|
|
+ // 只提取指定的 jar
|
|
|
+ if (zipEntry.getName().matches(pattern)) {
|
|
|
logger.info("extract... " + zipEntry.getName());
|
|
|
try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
|
|
|
String name = zipEntry.getName();
|