Open dmitry-zhuravlev opened 8 years ago
In the case where the template is run on an existing project with Build.kt
, it's still possible that it's a single project (just one module). If there are several projects, then yes, each template probably needs to create its files under the correct module, I'll look into that.
things can get a bit more interesting indeed. Let's start by covering the scenario where the template is run on a completely empty project and I'll think about the other scenario.
I've checked the templates which comes with Kobalt (java, kotlin, kobalt plugin) and at the moment there is 2 isues which prevents it from integration:
1) Template should be configurable. At least "group" and "version". 2) Kobalt should generate source and test dirs under ${MODULE_NAME}/src and not within ${PROJECT_BASE_DIR}/src. Where ${MODULE_NAME} is the folder in the same hierarchy level like "kobalt" folder (Build.kt module). That means that in Build.kt file should be directory=${MODULE_NAME} definition.
Point 2) relates to some interesting bug which comes from IDEA core. See
JUnit and TestNG configuration hides Kobalt run configuration and there is no way to disable JUnit and TestNG. JUnit and TestNG plugins "think" that task relates to its configuration because of layout of modules where ${PROJECT_BASE_DIR} = ${MODULE_NAME} dir. So should be ${PROJECT_BASE_DIR}/${MODULE_NAME} instead.
Anyway I think that the best solution will be to shift template handling from Kobalt itself to IDEA plugin. There is a key benefits to do so:
1) Almost all templates can be configurable: User can change template of example code from
public static void main(String[] argv) { System.out.println("\n\nHello Java world from Kobalt\n\n"); }
to completelly different content. All remplates can be modified by user in "Settings--> File and Code Templates"2) There is a possibility to add some headers which are generated in respect of user settings (javadoc, author name etc)
3) IDEA can reformat the code which based on template in respect of user settings.
4) With Kobalt templates you cannot combine e.g. "java" template together with "kotlin" template. But within IDEA it is possible to implement.
5) There is no additional process for generating templates needed (no need to kobaltw --init). IDEA can create and generate needed files and folders.
So it is more solid solution because process can failed or not properly closed and so on.
But Kobalt templates should still exist for users who are not using IDEA and works from console.