Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding author name in Eclipse automatically to existing files [closed]

Is there a real easy to use tool (no monster tool) that I can plug into Eclipse, and press a "generate header" button and then the authors name appears in every file in that project?

like image 884
Franz Kafka Avatar asked Oct 31 '11 19:10

Franz Kafka


People also ask

How do I change the default author in Eclipse?

Simply go to: Window - Preferences - Java - Code Style - Code Templates - Comments - Types - Edit... and change ${user} to whatever you want. Also go to: Window - Preferences - Java - Editor - Templates - @author - Edit... and change ${user} to whatever you want.

How do I view the author in Eclipse?

In Eclipse right click on your java class. this will give the name of authors for each line.

How do I import text into Eclipse?

Right-click on your project in the Package Explorer and select Import.... This will start up the Import wizard. In the import window's filter bar (the text field that will, by default says "type filter text") type "file" and then select File System.


2 Answers

Actually in Eclipse Indigo thru Oxygen, you have to go to the Types template Window -> Preferences -> Java -> Code Style -> Code templates -> (in right-hand pane) Comments -> double-click Types and make sure it has the following, which it should have by default:

/**  * @author ${user}  *  * ${tags}  */ 

and as far as I can tell, there is nothing in Eclipse to add the javadoc automatically to existing files in one batch. You could easily do it from the command line with sed & awk but that's another question.

If you are prepared to open each file individually, then selected the class / interface declaration line, e.g. public class AdamsClass { and then hit the key combo Shift + Alt + J and that will insert a new javadoc comment above, along with the author tag for your user. To experiment with other settings, go to Windows->Preferences->Java->Editor->Templates.

like image 120
Adam Avatar answered Oct 06 '22 14:10

Adam


To old files I don't know how to do it... I think you will need a script to go thru all files and add the header.

To change the new ones you can do this.

Go to Eclipse menu bar

  1. Window menu.
  2. Preferences
  3. search for Templates
  4. go to Code templates
  5. click on +code
  6. Click on New Java files
  7. Click Edit
  8. add

/**
${user}
*/

And it's done every new File will have your name on it !

like image 32
Cristiano Fontes Avatar answered Oct 06 '22 14:10

Cristiano Fontes