Grails
  1. Grails
  2. GRAILS-5713

Package by convention for new artefacts

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2 final
    • Fix Version/s: 1.2.2
    • Component/s: Project infrastructure
    • Labels:
      None

      Description

      When calling commands like create-domain-class and create-controller without an explicit package name artefacts should automatically be put inside a default package whose name is the app name (e.g. class name someapp.SomeArtefact ). This way naming conflicts could be avoided without bothering the user with the 'WARNING: You have not specified a package. ...' message and an additionally required y/n input.

      This default package sould maybe also be made configurable so I could define my own package name in Config.groovy without having to enter it each time I call one of the create commands.

        Activity

        Björn Wilmsmann created issue -
        Hide
        Björn Wilmsmann added a comment -

        This patch adds such a feature to all artefact creation scripts.

        Corresponding setting in Config.groovy is grails.defaultPackage="somePackage". Still have to figure out how to add this line to Config.groovy automatically upon app creation.

        Show
        Björn Wilmsmann added a comment - This patch adds such a feature to all artefact creation scripts. Corresponding setting in Config.groovy is grails.defaultPackage="somePackage". Still have to figure out how to add this line to Config.groovy automatically upon app creation.
        Björn Wilmsmann made changes -
        Field Original Value New Value
        Attachment _GrailsCreateArtifacts.groovy [ 47598 ]
        Hide
        Wolfgang Schell added a comment -

        Hi had something similar on my todo list for a while, every since having read about a feature like this in Spring Roo.

        Suggestion (similar in Roo): check for .MyClassName or ~.subpkg.AnotherClassName and replace '' with the default app package name. This allows something like this:

        grails create-app MyApp -base-package=com.example.greatapp

        grails create-controller ~.web.MyController
        grails create-domain-class ~.core.Person
        grails create-taglib ~.web.support.MyTagLib

        Of course the '-base-package' part would have to be stored somewhere. I'd suggest application.properties, as this can be modified programmatically, e.g. by creating a script 'grails set-base-package com.example.greatapp'.

        Show
        Wolfgang Schell added a comment - Hi had something similar on my todo list for a while, every since having read about a feature like this in Spring Roo. Suggestion (similar in Roo): check for .MyClassName or ~.subpkg.AnotherClassName and replace ' ' with the default app package name. This allows something like this: grails create-app MyApp -base-package=com.example.greatapp grails create-controller ~.web.MyController grails create-domain-class ~.core.Person grails create-taglib ~.web.support.MyTagLib Of course the '-base-package' part would have to be stored somewhere. I'd suggest application.properties, as this can be modified programmatically, e.g. by creating a script 'grails set-base-package com.example.greatapp'.
        Graeme Rocher made changes -
        Fix Version/s 1.2.2 [ 16198 ]
        Graeme Rocher made changes -
        Original Estimate 0 minutes [ 0 ]
        Remaining Estimate 0 minutes [ 0 ]
        Graeme Rocher made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Show
        Graeme Rocher added a comment - Fixed 1.3.x: http://github.com/grails/grails-core/commit/d9f2b982739e1f7a1d5cffb6b62bb4761eb0c0b0 Fixed 1.2.x: http://github.com/grails/grails-core/commit/94b5522d5b4389ab8f075cfc714455eb187604d0
        Graeme Rocher made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Closed [ 6 ]
        Contegix Support made changes -
        Project Import Thu Mar 24 21:22:24 CDT 2011 [ 1301019744151 ]
        Burt Beckwith made changes -
        Workflow jira [ 34116 ] Grails [ 46488 ]
        Burt Beckwith made changes -
        Workflow Grails [ 46488 ] Copy of Grails [ 53945 ]
        Burt Beckwith made changes -
        Workflow Copy of Grails [ 53945 ] Grails [ 61355 ]
        Burt Beckwith made changes -
        Workflow Grails [ 61355 ] Grails2 [ 68935 ]
        Burt Beckwith made changes -
        Workflow Grails2 [ 68935 ] jira [ 78914 ]
        Burt Beckwith made changes -
        Workflow jira [ 78914 ] Grails2 [ 86926 ]
        Peter Ledbrook made changes -
        Workflow Grails2 [ 86926 ] jira [ 95274 ]
        Peter Ledbrook made changes -
        Workflow jira [ 95274 ] Grails2 [ 103383 ]

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Björn Wilmsmann
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development