Grails
  1. Grails
  2. GRAILS-5372

grails generate-all asks for confirmation twice

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2-M4
    • Fix Version/s: None
    • Component/s: Scaffolding
    • Labels:
      None

      Description

      If entering n upon grails generate-all asking if the create view should be overwritten, the same question is asked again after all other views have been dealt with.

        Issue Links

          Activity

          Hide
          Björn Wilmsmann added a comment -

          create.gsp seems to be created twice, as generate-all even asks for confirmation to overwrite create.gsp if it's called for the first time.

          Show
          Björn Wilmsmann added a comment - create.gsp seems to be created twice, as generate-all even asks for confirmation to overwrite create.gsp if it's called for the first time.
          Hide
          D Gardner added a comment - - edited

          I'm using Grails 1.3.7. I have customised scaffolding view templates. If I run "grails generate-views my.DomainClass", I get asked for confirmation to overwrite view GSPs even if no views have been generated before.

          The problem seems to be in the org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGenerator class. The generateViews method generates a view for each template file retrieved by getTemplateNames, but getTemplateNames looks in different locations for template files and does not remove templates with duplicate file names (disregarding the directory path). My guess is that it returns the default templates from $GRAILS_HOME/src/grails/templates/scaffolding/*.gsp and then the customised templates from <app>/src/grails/templates/scaffolding/*.gsp and then generateViews generates GSP files with the same names as the template files, even if there are several template files with the same name. It is just fortunate that the customised templates happen to be generated last. This would explain the confirmation messages and double generation.

          The problem will be absent if no customised templates are present, so that might have been a barrier to reproducing this bug. Just run "grails generate-templates" first and then watch "grails generate-views" ask for confirmation to overwrite files that never existed before.

          If this is fixed by removing template files with duplicate names, the documentation will need to make it clear which template locations take precedence over others. The code seems to look for templates in about six different places, though some are mutually exclusive.

          Show
          D Gardner added a comment - - edited I'm using Grails 1.3.7. I have customised scaffolding view templates. If I run " grails generate-views my.DomainClass ", I get asked for confirmation to overwrite view GSPs even if no views have been generated before. The problem seems to be in the org.codehaus.groovy.grails.scaffolding.DefaultGrailsTemplateGenerator class. The generateViews method generates a view for each template file retrieved by getTemplateNames , but getTemplateNames looks in different locations for template files and does not remove templates with duplicate file names (disregarding the directory path). My guess is that it returns the default templates from $GRAILS_HOME/src/grails/templates/scaffolding/*.gsp and then the customised templates from <app>/src/grails/templates/scaffolding/*.gsp and then generateViews generates GSP files with the same names as the template files, even if there are several template files with the same name. It is just fortunate that the customised templates happen to be generated last. This would explain the confirmation messages and double generation. The problem will be absent if no customised templates are present, so that might have been a barrier to reproducing this bug. Just run " grails generate-templates " first and then watch " grails generate-views " ask for confirmation to overwrite files that never existed before. If this is fixed by removing template files with duplicate names, the documentation will need to make it clear which template locations take precedence over others. The code seems to look for templates in about six different places, though some are mutually exclusive.
          Hide
          Raviteja added a comment -

          This issue seems to be present in Grails 2 also. It is really annoying

          Steps to reproduce:

          • Run install-templates
          • Customise them
          • Run generate-views

          Even for the first time it asks whether to overwrite existing files(*.gsp).

          Show
          Raviteja added a comment - This issue seems to be present in Grails 2 also. It is really annoying Steps to reproduce: Run install-templates Customise them Run generate-views Even for the first time it asks whether to overwrite existing files(*.gsp).
          Hide
          Deyan Tsvetanov added a comment -

          This is a very very frustrating issue.
          It also doubles the time for generation, which is more frustrating if there are many domains to be scaffolded.

          Lets hope it will be addressed or at least triaged and scheduled soon

          Show
          Deyan Tsvetanov added a comment - This is a very very frustrating issue. It also doubles the time for generation, which is more frustrating if there are many domains to be scaffolded. Lets hope it will be addressed or at least triaged and scheduled soon

            People

            • Assignee:
              Unassigned
              Reporter:
              Björn Wilmsmann
            • Votes:
              5 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Last Reviewed:

                Development