|
15 | 15 | import org.openapitools.codegen.validation.Invalid; |
16 | 16 |
|
17 | 17 | import javax.inject.Inject; |
18 | | -import java.io.BufferedReader; |
19 | | -import java.io.BufferedWriter; |
20 | 18 | import java.io.File; |
21 | 19 | import java.io.IOException; |
22 | | -import java.nio.charset.StandardCharsets; |
23 | 20 | import java.nio.file.Files; |
24 | 21 | import java.nio.file.Path; |
25 | 22 | import java.nio.file.StandardOpenOption; |
@@ -162,7 +159,7 @@ public void run() throws IOException { |
162 | 159 |
|
163 | 160 | FileTree resourcesTree = (FileTree) getProject().fileTree(tempDir).exclude("**/*.java"); |
164 | 161 | move(resourcesTree, "resources", (src, dest) -> { |
165 | | - if (!"spring.factories".equals(src.getFileName().toString())) { |
| 162 | + if (!"org.springframework.boot.autoconfigure.AutoConfiguration.imports".equals(src.getFileName().toString())) { |
166 | 163 | throw new IllegalStateException("" + dest + " already exists"); |
167 | 164 | } |
168 | 165 | mergeSpringFactories(src, dest); |
@@ -202,25 +199,9 @@ private void clearDir(Path dir) throws IOException { |
202 | 199 | } |
203 | 200 |
|
204 | 201 | private void mergeSpringFactories(Path src, Path dest) { |
205 | | - try (BufferedReader srcReader = Files.newBufferedReader(src); BufferedReader destReader = Files.newBufferedReader(dest)) { |
206 | | - Properties srcProps = new Properties(); |
207 | | - srcProps.load(srcReader); |
208 | | - |
209 | | - Properties destProps = new Properties(); |
210 | | - destProps.load(destReader); |
211 | | - |
212 | | - for (String key : srcProps.stringPropertyNames()) { |
213 | | - if (destProps.containsKey(key)) { |
214 | | - String merged = destProps.getProperty(key) + "," + srcProps.getProperty(key); |
215 | | - destProps.put(key, merged); |
216 | | - } else { |
217 | | - destProps.put(key, srcProps.getProperty(key)); |
218 | | - } |
219 | | - } |
220 | | - |
221 | | - try (BufferedWriter writer = Files.newBufferedWriter(dest, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING)) { |
222 | | - destProps.store(writer, null); |
223 | | - } |
| 202 | + try { |
| 203 | + byte[] srcContent = Files.readAllBytes(src); |
| 204 | + Files.write(dest, srcContent, StandardOpenOption.APPEND); |
224 | 205 | Files.delete(src); |
225 | 206 | } catch (IOException e) { |
226 | 207 | throw new IllegalStateException(e); |
|
0 commit comments