0

Okay, I have this package a.b.domain.employee.groovy. Is it possible to run grails generate-all on that package and put it on a different folder? I mean, when generate-all is ran, I'd like it to be a.b.controller.employeeController.groovy. Is it possible to do that? How? I searched from google but I can't seem to find an answer.. :\

황현정
  • 3,451
  • 6
  • 28
  • 35
  • By moving them into `domain` and `controller` packages, you kind of get in the way of Grails instead of letting it work for you - you'll end up with (largely unnecessary) `import` statements everywhere. I realize that your company has probably already established this as a practice and it's probably out of your control to fix, but just be aware that it's not really ideal. – Rob Hruska Feb 12 '12 at 16:15
  • My solution was to use "create-controller" instead of generate because in create controller, you can specify the folder of the controller that you want your controller to be in... Then I ran "grails install-template" and copied the template from there and changed some values and it worked.. Very tedious however.. T_T – 황현정 Feb 12 '12 at 17:11

2 Answers2

0

There doesn't seem to be a way to do that from the command line, but you can always move the files after they are generated. But I would recommend against it you should consider keeping the packages related to what the code is doing you will already have the controllers and domain objects in different folders there isn't much need to add controller into the package name.

Is there some reason you want to change how the packages work by default?

Here is a question about Grails package structure.

Community
  • 1
  • 1
Jeff Beck
  • 3,944
  • 3
  • 28
  • 45
  • It's a common practice in the office. I wonder how they do it.. I'm supposed to ask my officemate, but he offline at the moment.. I noticed that all the controllers at some package like a.b.controllers.someController.groovy while the domains are in a.b.domains.some.groovy... I don't want to risk it by moving files on another folder so I thought there could be an automated way to do it. – 황현정 Feb 12 '12 at 15:50
0

Generate controllers and domain classes separately with their respective commands while defining the package and they will be placed into the correct folder. I don't think you can do this with generate-all when different packages are used for domain classes and controllers

Thomas
  • 1