Announcement Announcement Module
Collapse
No announcement yet.
STS and roo integration? rename package. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS and roo integration? rename package.

    The view from noobies-ville:
    While setting up a new roo project in STS, using the Roo Shell window (in STS) to enter fields to my UserId entity,
    I realized I had mistyped the package name.
    No problem, I used refactor->rename to correct that: com.old.pkg->com.new.pkg
    and Eclipse appears all happy; but roo complains that it cannot find my code when i try to add the next field.
    Its exact words were:
    Code:
    ~.domain.UserId roo> 
    field string --fieldName fullName --class ~.domain.UserId 
    Java source code unavailable for type SRC_MAIN_JAVA/com.old.pkg.domain.UserId
    Apparently, for roo "~" still refers to com.old.pkg,
    but I can find no incantation to change this association. (cd com.newpkg)?
    I had rather expected that the omniscient roo would figure this out,
    or STS would explain it to roo, or I could use help or hint to find how to do this.

    I figure if I could stop roo and restart it, that might help,
    but I fear to exit roo, or X the Roo Shell window without knowing how to restart/reopen it.

    The docs indicate that "~" is set by project creation, but i don't want to create a new project.

    After some digging, I managed to put a --class com.newpkg.domain.UserId on my next field definition
    [with *no* help from hint or CTRL-SPACE to suggest this argument (your tutorial/blog saved the day)]
    Even now, "~" is still com.oldpkg, so my prompt now shows the longer com.newpkg....domain.UserId roo>

    Perhaps the "Java source code unavailable" exception could
    encourage roo to suggest the --class arg on the next field?
    or is there a way for the roo plugin to listen for the refactor-rename?

    ---
    [Alas, I tried "roo> quit", and indeed the friendly link to "open roo shell for projects..." is gone.]
    [ok, finally found Window->show view->Roo Shell; oops must X the existing Roo Shell first...
    maybe roo could close that on it way out?]

    Even so, "~" is still does not refer to com.new.pkg...
    Can someone tell a poor noob how to reset "~"?


    Edit: I edited my pom.xml to update the groupId; roo now appears to be using that as "~"
    RFE: If roo/STS relies on mvn to keep this state, maybe refactor can push the rename into pom.xml automagically?
    Last edited by Jack Punt; Jan 28th, 2010, 03:19 PM. Reason: workaround...?

  • #2
    Roo will update the "~" expansion variable anytime you either load Roo (in which case it reads it from the pom.xml) or when you initially use the "project" command (which is unavailable if you already have a project and therefore a pom.xml).

    In your case the simplest solution would have been to use Eclipse's refactor support, then edit the pom.xml to change the package name to what it should have been, then restarted the Roo shell. It is perfectly safe to restart the Roo shell within STS (and also the standalone Roo shell if you're not using STS) as often as you wish.

    HTH

    Comment


    • #3
      Ben,
      Thanks for the confirmation that ~ is derived from the pom.xml
      That was not obvious to the new user.
      I see the old name also appears in applicationContext.xml (which appears to be roo managed)

      Can these edits be automated as part of refactor?
      That is: all the package defs in the *.java and *.aj files were updated, why not in *.xml?
      [or a least a warning/mention that this may need to be done manually]

      [i'm not yet an Eclipse expert,
      but with STS/roo, and FlexBuilder, i'll undoubtedly become one soon;
      eagerly awaiting to have STS/roo/BlazeDS and FlashBuilder in one IDE...]
      Last edited by Jack Punt; Jan 28th, 2010, 04:23 PM.

      Comment


      • #4
        Hi Jack

        Roo has certain conventions about which files it updates and when, as detailed in the usability section of the reference guide. Because Roo doesn't hook into Eclipse's APIs, we have no way of knowing a user has completed a refactor command. It could be argued the m2eclipse could detect if the top-level-package has been renamed and it should modify the pom.xml, but to be honest it would require caution to ensure these sort of changes can be made safely.

        Perhaps we should edit the reference guide to more fully explain the ~ behaviour and provide a checklist of things to change should the user change their top level package. If you think that would be helpful, please log it into our Jira instance and I'll get it done.

        Cheers
        Ben

        Comment


        • #5
          My pom.xml has

          <groupId>com.sas.tools.appgen</groupId>

          but Roo thinks ~ is com.sas.tools instead, so when I do

          entity jpa --class ~.models.Artifact

          Roo creates com.sas.tools.models.Artifact not com.sas.tools.appgen.models.artifact.

          pom.xml does not mention com.sas.tools anywhere else.

          I've restarted the Roo shell (and also closed/reopened the Eclipse project) and Roo still gets the wrong ~

          focus does not work either:

          focus --class ~.models.Project
          Cannot locate the type com.sas.tools.models.Project

          (it should pick up com.sas.tools.appgen.models.Project)

          How can I fix this, so I don't have to use ~.appgen.models.Project etc?

          I'm using 1.2.1.RELEASE [rev 6eae723] in STS

          Comment

          Working...
          X