Protecting generated code when you rerun UML-to-Java transformations

To protect generated code when you rerun a transformation, you must create a Java™ code template. The transformation uses the template to enclose the generated method bodies. When you rerun the transformation, it does not overwrite the code that the template encloses.
To protect generated code when you rerun a transformation:
  1. Click Window > Preferences.
  2. In the Preferences window, expand Java > Code Style and click Code Templates.
  3. In the Configure generated code and comments pane, expand the Code list and click Method body.
  4. Click Edit.
  5. In the Edit Template window, replace the existing code with the following code:
    // begin-user-code
    // ${todo} Auto-generated method stub 
    ${body_statement} 
    // end-user-code
     
  6. To avoid syntax errors when you rerun the transformation, after // end-user-code, press Enter.
  7. Click OK.
  8. To rerun the transformation, complete one of the following steps:
    • To run the transformation on the source specified in the configuration, right-click a transformation configuration (.tc) file; then click Transform and click the transformation to run.
    • To specify a different source on which to run the transformation, in the Modeling perspective, highlight elements in the source model or project; then click Modeling > Transform and select your transformation.
      Tip: To run this transformation again, click Modeling > Transform > Run Last. The transformation uses the same source elements from when you last ran the transformation.
Related tasks
Running UML-to-Java transformations
Running UML-to-Java transformations in silent mode
Generating debugging information for UML-to-Java transformations

Feedback