Adding a standard comment header to all source files in eclipse

Is there a way to add a standard header comment in one place and it applies to all my source files in my project? the title will contain my name, contact details, company, license, etc.

+45
eclipse
Nov 05 '10 at 12:03
source share
6 answers

If you are looking for a tool with good Eclipse integration (and a nice GUI), I suggest: Eclipse Copyright

This adds:

  • new panel in settings (global or project) with: Menu> Windows> Preferences> General> Copyright .
  • Menu Menu> Project> Apply Copyright ...
  • really nice wizard with many options and some default template for Open-Source license (Apache, EPL, ...)

I just tried it with eclipse 3.6 and it works great.

To install it there is an update site:

https://dl.bintray.com/jmini/Eclipse-Copyright-Generator/ 
+46
Mar 30 '11 at 20:26
source share

Window> Settings> Java> Code Style> Code Templates> Comments> Files

+24
Nov 05 '10 at
source share

In addition to the answer provided by Bozho, there are releng tools provided by eclipse that give you some menu commands for correcting copyrights in existing files. You can install releng tools from this update site:

Eclipse Project Updates - http://download.eclipse.org/eclipse/updates/4.3

And here is some information:

https://wiki.eclipse.org/Development_Resources/How_to_Use_Eclipse_Copyright_Tool

+9
Nov 05 '10 at 7:32
source share

In addition to Andrew Eisenberg's answer, here's what I learned about the Eclipse copyright tool . I found that this works best with all the solutions offered.

Advantages:

  • Easily update copyright years or license title.
  • Easy to apply to the whole project or its parts.

Disadvantages:

  • Does not work on all types of files. At least it didn't work on JSP files for me.
  • You cannot configure multiple licenses and apply them as you want. There is only one license.

Setting (from settings):

Customization (from preferences)

You can apply the license at the file or package level.

You can apply the license at the file or package level

+6
Jun 02 '15 at 9:06
source share

The project associated with the @Jmini link (Eclipse Author Generator) seems dead, you can use this plugin to add headers: JAutoDoc , it is very easy to use and has many utilities for javadoc.

You need to specify the license in project|general > Preferences > java > JAutodoc > FileHeader and later in the project: project > JAutodoc > Add Header , make sure that the Replace Existing Header option is enabled.

The template is recorded using Velocity , so you can add all the necessary information as variables.

+2
Jun 05 '14 at 14:21
source share

this is my setting in Window > Preferencers > Java > Code Style > Code Template > Code > New Java files :

 /* * Copyright (c) 20XX XXXXXXXXX. All rights reserved. Whatever...... */ ${filecomment} ${package_declaration} ${typecomment} /** * * @author ${user} * */ ${type_declaration} 
-one
Nov 28 '17 at 17:25
source share



All Articles