Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class Bootstrapper {

private MustacheFactory mustacheFactory = new DefaultMustacheFactory();

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

private void addStaticFiles(File projectDir) {
TOP_LEVEL_STATIC_FILES.forEach(f -> addStaticFile(projectDir, f));
TOP_LEVEL_STATIC_FILES.forEach((key, value) -> addStaticFile(projectDir, key, value));
}

private void addStaticFile(File targetDir, String fileName) {
addStaticFile(targetDir, fileName, null);
private void addStaticFile(File targetDir, String fileName, String targetFileName) {
addStaticFile(targetDir, fileName, targetFileName, null);
}

private void addStaticFile(File targetDir, String fileName, String subDir) {
private void addStaticFile(File targetDir, String fileName, String targetFilename,
String subDir) {
String sourcePath = subDir == null ? "/static/" : "/static/" + subDir;
String path = sourcePath + fileName;
try (var is = Bootstrapper.class.getResourceAsStream(path)) {
targetDir = subDir == null ? targetDir : new File(targetDir, subDir);
if (subDir != null) {
FileUtils.forceMkdir(targetDir);
}
FileUtils.copyInputStreamToFile(is, new File(targetDir, fileName));
FileUtils.copyInputStreamToFile(is, new File(targetDir, targetFilename));
} catch (IOException e) {
throw new RuntimeException("File path: " + path, e);
}
Expand Down