Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add header(copyright) information to existing source files

I want to add our company's copyright information to all of our EXISTING source code files.

The project is developed in Eclipse. so, for new files I can modify the settings as suggested here. But for existing files, how am I supposed to do this. How can I modify hundreds of java files to add the copyright information. (And I'm unable to open the releng plugin mentioned in the above link.

Any windows based text maniputaion scripting language will also help.

like image 542
jai Avatar asked Dec 14 '10 07:12

jai


People also ask

How do you add a copyright header?

Let's see how to do that in Copyright Preferences: We first navigate to Preferences -> General -> Copyright. Then, to add a new copyright header, we click on the Add button. To modify an existing license, we select a license from the Licenses and then click on the Modify button.

How do I add copyright to all files in Intellij?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Copyright. From the Default project copyright list, select the profile you want to use as the default profile. Apply the changes and close the dialog. After that you can add the copyright to the necessary files.

How do you add copyright in Visual Studio?

Open a source code file. Place the caret at the first line. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu and select Add Copyright Header from the menu.

How do you set a copyright code?

You can create an HTML copyright symbol using the © or © symbol codes. These are often enclosed within a paragraph. The ampersand denotes that want to embed a special character onto the web page.


4 Answers

Correcting Konstantin's solution:

find . -name \*.java -exec sh -c "mv '{}' tmp && cp copyright '{}' && cat tmp >> '{}' && rm tmp" \;

Problem was that && is being interpreted by the shell directly instead of being passed to find. Escaping them is no solution either, as the find exec does not understand them. So just give the whole command to some shell.

like image 160
data Avatar answered Sep 20 '22 15:09

data


Please try eclipse Releng plugin.
This would help to fix/add copyright statement in all .java files and .properties.
Simply right click on the project and select "Fix copyright".
Link.

like image 21
Suresh Avatar answered Sep 22 '22 15:09

Suresh


I would install CygWin (core + find) and do something of a kind

find . -name *.java -exec mv '{}' tmp && cp copyright '{}' && cat tmp >> '{}' && rm tmp \;

like image 42
Konstantin Avatar answered Sep 21 '22 15:09

Konstantin


You can use maven license plugin to do this.

Check this and this. The plugin support templates for your license header, remove the license and check for the license in all your files.

like image 38
ahvargas Avatar answered Sep 21 '22 15:09

ahvargas