Announcement Announcement Module
Collapse
No announcement yet.
Imports being removed when adding fields to file. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Imports being removed when adding fields to file.

    When adding a new field through the Roo shell's field command I am losing some of my custom imports that my addon adds to the file.

    Anybody have any ideas on why it is doing this?

  • #2
    Destro190,

    Can you give us an idea of what you are trying to achieve with the add-on? Are you writing to an ITD? Your own ITD or one generated by another add-on?

    If you are writing to another ITD, I'm guessing you may not want to since the other add-on owns it. I assume you subscribed your add-on to changes based on the metadata information for your type of object? Check out the @RooJavaBean roo built-in add-on (roo-javabean) for details on how that works.

    Ken

    Comment


    • #3
      If we have a class like:

      Code:
      package com.mypackage;
      
      import com.mypackage.MyClass.MyBean;
      
      @Input(MyBean.class)
      public class MyClass
      {
          public static class MyBean{}
      }
      Then, running something like:

      Code:
      field boolean --fieldName foo --class com.mypackage.MyClass
      will remove the import of MyBean and it will no longer compile because the annotation needs the import to be able to see MyBean.

      Comment


      • #4
        How are you setting up your imports, using the ClassOrInterfaceTypeDetailsBuilder on the existing type?

        I see a clear() method on that class's init() method if you use it on an existing type. Then it re-adds existing imports that are "registered."

        Do you use the import registration feature or are you using a text template and writing each file line?

        Comment

        Working...
        X