|
23 | 23 | import java.nio.file.Path;
|
24 | 24 | import java.nio.file.StandardCopyOption;
|
25 | 25 | import java.util.ArrayList;
|
| 26 | +import java.util.Collections; |
26 | 27 | import java.util.List;
|
27 | 28 | import java.util.Locale;
|
28 | 29 | import java.util.Map;
|
@@ -82,7 +83,9 @@ protected void run(File workingDirectory, String startClassName, Map<String, Str
|
82 | 83 | try {
|
83 | 84 | generateAotAssets(workingDirectory, startClassName, environmentVariables);
|
84 | 85 | compileSourceFiles();
|
85 |
| - copyNativeConfiguration(this.generatedResources.toPath()); |
| 86 | + copyAll(this.generatedResources.toPath().resolve("META-INF/native-image"), |
| 87 | + this.classesDirectory.toPath().resolve("META-INF/native-image")); |
| 88 | + copyAll(this.generatedClasses.toPath(), this.classesDirectory.toPath()); |
86 | 89 | }
|
87 | 90 | catch (Exception ex) {
|
88 | 91 | throw new MojoExecutionException(ex.getMessage(), ex);
|
@@ -158,14 +161,13 @@ private void compileSourceFiles() throws IOException, MojoExecutionException {
|
158 | 161 | }
|
159 | 162 | }
|
160 | 163 |
|
161 |
| - private void copyNativeConfiguration(Path generatedResources) throws IOException { |
162 |
| - Path targetDirectory = this.classesDirectory.toPath().resolve("META-INF/native-image"); |
163 |
| - Path sourceDirectory = generatedResources.resolve("META-INF/native-image"); |
164 |
| - List<Path> files = Files.walk(sourceDirectory).filter(Files::isRegularFile).toList(); |
| 164 | + private void copyAll(Path from, Path to) throws IOException { |
| 165 | + List<Path> files = (Files.exists(from)) ? Files.walk(from).filter(Files::isRegularFile).toList() |
| 166 | + : Collections.emptyList(); |
165 | 167 | for (Path file : files) {
|
166 |
| - String relativeFileName = file.subpath(sourceDirectory.getNameCount(), file.getNameCount()).toString(); |
167 |
| - getLog().debug("Copying '" + relativeFileName + "' to " + targetDirectory); |
168 |
| - Path target = targetDirectory.resolve(relativeFileName); |
| 168 | + String relativeFileName = file.subpath(from.getNameCount(), file.getNameCount()).toString(); |
| 169 | + getLog().debug("Copying '" + relativeFileName + "' to " + to); |
| 170 | + Path target = to.resolve(relativeFileName); |
169 | 171 | Files.createDirectories(target.getParent());
|
170 | 172 | Files.copy(file, target, StandardCopyOption.REPLACE_EXISTING);
|
171 | 173 | }
|
|
0 commit comments