sebasira
sebasira

Reputation: 1834

IntelliJ IDEA File Templates - Customize directory/package for Multiple Files Template

I'm using IntelliJ IDEA to develop a Java app.

Let's suppose I have a Multiple File Template that creates a Model Entity, Service and a Controller.

When I use that template, 3 files are created in the same location. Assume that the Entity name is Car, then the files would be:

Assuming the following structure...

--+ app
  +-- model
  +-- service
  +-- controller

How can I define the location where each files gets created, so the result would be like:

--+ app
  +--+ model
     +-- Car
  +--+ service
     +-- CarService
  +--+ controller
     +-- CarController

Upvotes: 1

Views: 847

Answers (1)

Bas Leijdekkers
Bas Leijdekkers

Reputation: 26577

You can specify folders in the file name of the template. For example your main template can have the file name model/${NAME} and below it you can define two child templates with file names service/${NAME}Service and controller/${NAME}Controller. When the template is used this will create the folders if necessary, or use existing folders if they are already present.

Upvotes: 6

Related Questions