Skip to content

Commit 5337280

Browse files
committed
排除配置文件发布
1 parent 2c34c31 commit 5337280

File tree

16 files changed

+315
-6
lines changed

16 files changed

+315
-6
lines changed

luna-commons-ali/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,16 @@
9393
</executions>
9494
</plugin>
9595
</plugins>
96+
97+
<!-- 过滤配置文件 -->
98+
<resources>
99+
<resource>
100+
<directory>src/main/resources</directory>
101+
<excludes>
102+
<exclude>**/*.properties</exclude>
103+
</excludes>
104+
<filtering>true</filtering>
105+
</resource>
106+
</resources>
96107
</build>
97108
</project>

luna-commons-api/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,16 @@
7979
</executions>
8080
</plugin>
8181
</plugins>
82+
83+
<!-- 过滤配置文件 -->
84+
<resources>
85+
<resource>
86+
<directory>src/main/resources</directory>
87+
<excludes>
88+
<exclude>**/*.properties</exclude>
89+
</excludes>
90+
<filtering>true</filtering>
91+
</resource>
92+
</resources>
8293
</build>
8394
</project>

luna-commons-baidu/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,16 @@
9292
</executions>
9393
</plugin>
9494
</plugins>
95+
96+
<!-- 过滤配置文件 -->
97+
<resources>
98+
<resource>
99+
<directory>src/main/resources</directory>
100+
<excludes>
101+
<exclude>**/*.properties</exclude>
102+
</excludes>
103+
<filtering>true</filtering>
104+
</resource>
105+
</resources>
95106
</build>
96107
</project>

luna-commons-baidu/src/test/java/com/luna/baidu/tests/OcrTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.luna.baidu.config.BaiduConfigValue;
1010
import com.luna.baidu.config.GetBaiduKey;
1111
import com.luna.common.utils.Base64Util;
12-
import com.luna.common.utils.ImageUtils;
12+
import com.luna.common.utils.img.ImageUtils;
1313

1414
/**
1515
* @Package: com.luna.baidu.tests

luna-commons-common/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,16 @@
139139
</executions>
140140
</plugin>
141141
</plugins>
142+
143+
<!-- 过滤配置文件 -->
144+
<resources>
145+
<resource>
146+
<directory>src/main/resources</directory>
147+
<excludes>
148+
<exclude>**/*.properties</exclude>
149+
</excludes>
150+
<filtering>true</filtering>
151+
</resource>
152+
</resources>
142153
</build>
143154
</project>
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package com.luna.common.utils.file;
2+
3+
import com.luna.common.dto.constant.ResultCode;
4+
import com.luna.common.exception.FileException;
5+
import com.luna.common.exception.base.BaseException;
6+
7+
import java.io.File;
8+
import java.io.FileInputStream;
9+
import java.io.FileOutputStream;
10+
import java.io.IOException;
11+
import java.nio.file.Files;
12+
import java.nio.file.Paths;
13+
14+
/**
15+
* @Package: com.luna.file.file
16+
* @ClassName: LocalFileUtil
17+
* @Author: luna
18+
* @CreateTime: 2020/7/16 15:31
19+
* @Description:
20+
*/
21+
public class LocalFileUtil {
22+
23+
/**
24+
* 获取文件数目
25+
*
26+
* @param path
27+
* @return
28+
*/
29+
public static Integer getFileLength(String path) {
30+
int fileCount = 0;
31+
int folderCount = 0;
32+
File d = new File(path);
33+
File list[] = d.listFiles();
34+
for (int i = 0; i < list.length; i++) {
35+
if (list[i].isFile()) {
36+
fileCount++;
37+
} else {
38+
folderCount++;
39+
}
40+
}
41+
return fileCount;
42+
}
43+
44+
/**
45+
* 批量转换文件类型
46+
*
47+
* @param path
48+
* @param oldExt
49+
* @param newExt
50+
*/
51+
public static void renameFiles(String path, String oldExt, String newExt) {
52+
File file = new File(path);
53+
if (!file.exists()) {
54+
throw new FileException(ResultCode.PARAMETER_INVALID, "文件路径不存在", new Object[] {path});
55+
}
56+
File[] files = file.listFiles();
57+
if (files.length <= 0) {
58+
throw new BaseException(ResultCode.PARAMETER_INVALID, "当前路径文件不存在", new Object[] {path});
59+
}
60+
for (File f : files) {
61+
if (f.isDirectory()) {
62+
renameFiles(f.getPath(), oldExt, newExt);
63+
} else {
64+
String name = f.getName();
65+
if (name.endsWith("." + oldExt)) {
66+
name = name.substring(0, name.lastIndexOf(".") + 1);
67+
name += newExt;
68+
f.renameTo(new File(f.getParent() + "\\" + name));
69+
}
70+
}
71+
}
72+
}
73+
74+
/**
75+
* 复制文件
76+
*
77+
* @param input 输入
78+
* @param output 输出
79+
* @throws IOException
80+
*/
81+
public static void copyFile(File input, File output) {
82+
if (!input.exists() || !output.exists()) {
83+
throw new FileException(ResultCode.PARAMETER_INVALID, "文件路径不存在", new Object[] {input, output});
84+
}
85+
FileInputStream fileInputStream = null;
86+
FileOutputStream fileOutputStream = null;
87+
try {
88+
// 建立数据的输入输出通道
89+
fileInputStream = new FileInputStream(input);
90+
fileOutputStream = new FileOutputStream(output);
91+
// 追加数据....
92+
93+
// 每新创建一个FileOutputStream的时候,默认情况下FileOutputStream 的指针是指向了文件的开始的位置。 每写出一次,指向都会出现相应移动。
94+
// 建立缓冲数据,边读边写
95+
byte[] buf = new byte[1024];
96+
int length = 0;
97+
while ((length = fileInputStream.read(buf)) != -1) {
98+
fileOutputStream.write(buf, 0, length);
99+
// 写出很多次数据,所以就必须要追加。
100+
}
101+
} catch (IOException e) {
102+
e.printStackTrace();
103+
} finally {
104+
try {
105+
// 关闭资源 原则: 先开后关,后开先关。
106+
fileOutputStream.close();
107+
fileInputStream.close();
108+
} catch (IOException e) {
109+
e.printStackTrace();
110+
}
111+
}
112+
}
113+
114+
/**
115+
* 批量复制文件
116+
*
117+
* @param inputPath 输入目录
118+
* @param outputPath 输出目录
119+
* @param number 每个文件复制数量
120+
* @param inputPrefix 输入文件前缀
121+
* @param outputPrefix 输出文件前缀
122+
* @param inputType 输入文件类型
123+
* @param outputType 输出文件类型
124+
* @return 文件操作数
125+
* @throws IOException
126+
*/
127+
public static Integer copyFile(String inputPath, String outputPath, Integer number, String inputPrefix,
128+
String outputPrefix, String inputType, String outputType) {
129+
int cont = 1;
130+
Integer fileLength = getFileLength(inputPath);
131+
// 每张图片复制次数
132+
for (int i = 1; i < fileLength; i++) {
133+
String inFile = inputPath + "\\" + inputPrefix + i + inputType;
134+
for (int i1 = 0; i1 < number; i1++) {
135+
String destFile = outputPath + "\\" + outputPrefix + cont + outputType;
136+
cont++;
137+
copyFile(new File(inFile), new File(destFile));
138+
}
139+
}
140+
return cont;
141+
}
142+
143+
/**
144+
* 判断一个文件是否存在
145+
*
146+
* @param fileName
147+
* @return
148+
*/
149+
public static boolean isFileExists(String fileName) {
150+
return Files.exists(Paths.get(fileName));
151+
}
152+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.luna.common.utils.img;
2+
3+
import com.luna.common.dto.constant.ResultCode;
4+
import com.luna.common.exception.FileException;
5+
6+
import javax.imageio.stream.FileImageOutputStream;
7+
import java.io.File;
8+
import java.io.FileInputStream;
9+
import java.io.IOException;
10+
import java.io.InputStream;
11+
12+
/**
13+
* 图片文件,与 byte[] 互转
14+
*/
15+
public class ImageUtils {
16+
17+
/**
18+
* 图片转字节
19+
*
20+
* @param imgFile
21+
* @return
22+
*/
23+
public static byte[] getBytes(String imgFile) {
24+
InputStream in = null;
25+
byte[] data = null;
26+
// 读取图片字节数组
27+
try {
28+
in = new FileInputStream(imgFile);
29+
data = new byte[in.available()];
30+
in.read(data);
31+
in.close();
32+
return data;
33+
} catch (IOException e) {
34+
e.printStackTrace();
35+
throw new FileException(ResultCode.PARAMETER_INVALID, "Exception: " + e.getMessage());
36+
}
37+
}
38+
39+
/**
40+
* 字节转图片
41+
*
42+
* @param data
43+
* @param path
44+
*/
45+
public static void byte2image(byte[] data, String path) {
46+
if (data.length < 3 || path.equals("")) {
47+
return;
48+
}
49+
try {
50+
FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));
51+
imageOutput.write(data, 0, data.length);
52+
imageOutput.close();
53+
} catch (Exception e) {
54+
e.printStackTrace();
55+
throw new FileException(ResultCode.PARAMETER_INVALID, "Exception: " + e.getMessage());
56+
}
57+
}
58+
}

luna-commons-file/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,16 @@
9999
</executions>
100100
</plugin>
101101
</plugins>
102+
103+
<!-- 过滤配置文件 -->
104+
<resources>
105+
<resource>
106+
<directory>src/main/resources</directory>
107+
<excludes>
108+
<exclude>**/*.properties</exclude>
109+
</excludes>
110+
<filtering>true</filtering>
111+
</resource>
112+
</resources>
102113
</build>
103114
</project>

luna-commons-file/src/main/java/com/luna/file/local/LocalFileUtil.java renamed to luna-commons-file/src/main/java/com/luna/file/file/LocalFileUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.luna.file.local;
1+
package com.luna.file.file;
22

33
import com.luna.common.dto.constant.ResultCode;
44
import com.luna.common.exception.FileException;
@@ -12,7 +12,7 @@
1212
import java.nio.file.Paths;
1313

1414
/**
15-
* @Package: com.luna.file.local
15+
* @Package: com.luna.file.file
1616
* @ClassName: LocalFileUtil
1717
* @Author: luna
1818
* @CreateTime: 2020/7/16 15:31

luna-commons-media/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,16 @@
128128
</executions>
129129
</plugin>
130130
</plugins>
131+
132+
<!-- 过滤配置文件 -->
133+
<resources>
134+
<resource>
135+
<directory>src/main/resources</directory>
136+
<excludes>
137+
<exclude>**/*.properties</exclude>
138+
</excludes>
139+
<filtering>true</filtering>
140+
</resource>
141+
</resources>
131142
</build>
132143
</project>

luna-commons-media/src/main/java/com/luna/media/ffmpeg/FfmpegUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.luna.common.dto.constant.ResultCode;
44
import com.luna.common.exception.FileException;
55
import com.luna.common.exception.JavaCvException;
6-
import com.luna.file.local.LocalFileUtil;
6+
import com.luna.file.file.LocalFileUtil;
77
import org.slf4j.Logger;
88
import org.slf4j.LoggerFactory;
99

luna-commons-media/src/main/java/com/luna/media/javacv/VideoUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.luna.common.exception.FileException;
55
import com.luna.common.exception.JavaCvException;
66
import com.luna.common.utils.StringUtils;
7-
import com.luna.file.local.LocalFileUtil;
7+
import com.luna.file.file.LocalFileUtil;
88
import com.luna.media.ffmpeg.FfmpegUtil;
99
import org.bytedeco.ffmpeg.global.avcodec;
1010
import org.bytedeco.ffmpeg.global.avutil;

luna-commons-message/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,16 @@
9898
</executions>
9999
</plugin>
100100
</plugins>
101+
102+
<!-- 过滤配置文件 -->
103+
<resources>
104+
<resource>
105+
<directory>src/main/resources</directory>
106+
<excludes>
107+
<exclude>**/*.properties</exclude>
108+
</excludes>
109+
<filtering>true</filtering>
110+
</resource>
111+
</resources>
101112
</build>
102113
</project>

luna-commons-tencent/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,16 @@
100100
</executions>
101101
</plugin>
102102
</plugins>
103+
104+
<!-- 过滤配置文件 -->
105+
<resources>
106+
<resource>
107+
<directory>src/main/resources</directory>
108+
<excludes>
109+
<exclude>**/*.properties</exclude>
110+
</excludes>
111+
<filtering>true</filtering>
112+
</resource>
113+
</resources>
103114
</build>
104115
</project>

0 commit comments

Comments
 (0)