Archived

This forum has been archived. Please start a new discussion on GitHub.

Custom headers in generated files

Is there a way to put custom headers in the files that are generated using slice2java.

I do not wish to change the Copyright notice but a simple comment saying something like "This is an auto-generated file - please do not modify"

Appreciate your help

Thanks

Comments

  • bernard
    bernard Jupiter, FL
    Hi Sameer,

    You could modify slice2java itself, i.e. edit Slice::JavaOut::printerHeader in src/slice/JavaUtil.cpp.

    Currently, slice2java does not offer a way to modify the header it generates.

    Best regards,
    Bernard
  • Hi Sameer,
    I do not wish to change the Copyright notice but a simple comment saying something like "This is an auto-generated file - please do not modify"

    I don't mean to tell you how to do your work, but thought I'd mention this just in case it helps...

    Do you feel you need a "do not modify" line in the generated code because you're afraid other programmers on your team will edit it? Are you putting generated code into your source control system? I'd advise you to not do so, and instead simply generate the code during the build. This approach is good for at least a couple reasons:
    • If your Slice code ever changes (or the generated code changes due to upgrading to a new version of Ice), you don't need to worry about lots of source code repository updates for the generated code.
    • People will be less likely to want to edit the generated code since it won't be in your source repository

    We use ZeroC's <slice2java> Ant task to generate code from the Slice definitions during our build, and it works great. If you want an example of how to do it, see the Ant build.xml for the TeRKPeerCommon module in our source code.

    Sorry if all this is plainly obvious to you, or if you need the "do not modify" line for other reasons--just trying to help you avoid future headaches.

    best,

    Chris