Project level file headers

I've searched the online help and these forums and can't find anything on this. I have two projects and each project needs a different file header comment - say a copyright notice. How can I setup my file templates and my projects so whenever I create a new class in a project, the file has the appropriate project specific copyright notice in it?

Thanks,
Rick

6 comments

By the way, I have a source tree containing JAVA files without a copyright header. We are currently waiting for the licence definition, and we'll soon need to include the copyright at the top of the file, above all import statements, comments...

An easy way (using win32) to do this is by using an ant task that modifies the JAVA files, but is there a clean way to update the licence definition ?
The method used would have to detect some kind of token in the copyright statement in order to detect the right comment corresponding to the copyright, or detect the first comment from the top of the file...?
I though maybe that would be a handy feature in IDEA, although developpers are not supposed to change the licence very often ;)

Couldn't a JavaDoc Doclet do the job nicely ? After all, JavaDoc constructs a source code syntax tree in memory, so it knows about the existing comments, and could easily detect copyright statements...

Any ANT tips to include portions of text at the top of JAVA files are welcome !

Thanks.
Dan/

0

Hi Dan,

I think, the easiest way would be a small Java program. It should not
have more than 30 lines.

Tom

0

If you look at:
"Project Settings - Miscellaneous"
you'll see that you can choose to use a per-project code style scheme.
I guess class templates could easily be included in this section as well.
But that solves only half of the problem, because it only works when creating a new class using IDEA...
How about existing classes that need to include a copyright statement as well ?

Dan/

0

Check out Jalopy (http://jalopy.sourceforge.net/). I almost sure that it can find your old header and exchange it with another.
It can do lots of other things to, and it is available as a ANT plugin.

/Anders

0

Thanks Dan,

I don't know why I didn't think to look at the bug/rfe database.

0

Please sign in to leave a comment.