Skip to content

Commit 9cf2baa

Browse files
authored
fix: bootstrapper gitignore exclusion fix (#2409)
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 7d6f9c9 commit 9cf2baa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

bootstrapper-maven-plugin/src/main/java/io/javaoperatorsdk/boostrapper/Bootstrapper.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public class Bootstrapper {
2323

2424
private MustacheFactory mustacheFactory = new DefaultMustacheFactory();
2525

26-
private static final List<String> TOP_LEVEL_STATIC_FILES =
27-
List.of(".gitignore", "README.md");
26+
// .gitignore gets excluded from resource, using here a prefixed version
27+
private static final Map<String, String> TOP_LEVEL_STATIC_FILES =
28+
Map.of("_.gitignore", ".gitignore", "README.md", "README.md");
2829
private static final List<String> JAVA_FILES =
2930
List.of("CustomResource.java", "Reconciler.java",
3031
"Spec.java", "Status.java");
@@ -106,22 +107,23 @@ private void addTemplatedFile(File projectDir, String fileName, String groupId,
106107
}
107108

108109
private void addStaticFiles(File projectDir) {
109-
TOP_LEVEL_STATIC_FILES.forEach(f -> addStaticFile(projectDir, f));
110+
TOP_LEVEL_STATIC_FILES.forEach((key, value) -> addStaticFile(projectDir, key, value));
110111
}
111112

112-
private void addStaticFile(File targetDir, String fileName) {
113-
addStaticFile(targetDir, fileName, null);
113+
private void addStaticFile(File targetDir, String fileName, String targetFileName) {
114+
addStaticFile(targetDir, fileName, targetFileName, null);
114115
}
115116

116-
private void addStaticFile(File targetDir, String fileName, String subDir) {
117+
private void addStaticFile(File targetDir, String fileName, String targetFilename,
118+
String subDir) {
117119
String sourcePath = subDir == null ? "/static/" : "/static/" + subDir;
118120
String path = sourcePath + fileName;
119121
try (var is = Bootstrapper.class.getResourceAsStream(path)) {
120122
targetDir = subDir == null ? targetDir : new File(targetDir, subDir);
121123
if (subDir != null) {
122124
FileUtils.forceMkdir(targetDir);
123125
}
124-
FileUtils.copyInputStreamToFile(is, new File(targetDir, fileName));
126+
FileUtils.copyInputStreamToFile(is, new File(targetDir, targetFilename));
125127
} catch (IOException e) {
126128
throw new RuntimeException("File path: " + path, e);
127129
}

0 commit comments

Comments
 (0)