Can you store internal file templates in sub folders?

I have built an IntelliJ plugin that uses a large number of file templates to generate a project for the user. Currently they are all stored under: resources/fileTemplates/internal as .ft files and there is no reference to them in plugin.xml.

As more are added it’s becoming increasingly difficult to manage. Is it possible to store file templates in sub folders or is there another approach I should be taking? I have tried to include the folder name when getting the template but IntelliJ seems unable to find it unless it’s in the root folder.

This would make such a difference for me so I really hope you can help.

 

0
1 comment

To anyone that finds this question in the future, one way to achieve this is to add the following Gradle task:

processResources {
exclude("fileTemplates/internal/**")
from(fileTree("src/main/resources/fileTemplates/internal").files) {
eachFile {
relativePath = RelativePath(true, "fileTemplates", "internal", this.name)
}
}
}

This will flatten the internal file template directory in the resultant Jar. This means all templates still need to be named uniquely but makes it much easier to organise them in the project! I found this approach in the MinecraftDev plugin source code: https://github.com/minecraft-dev/MinecraftDev/blob/dev/build.gradle.kts#L170

0

Please sign in to leave a comment.