Add header(copyright) information to existing source files

后端 未结 6 2260
我在风中等你
我在风中等你 2021-02-09 08:18

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 m

相关标签:
6条回答
  • 2021-02-09 08:44

    Talk your boss out of it.

    See Get Rid of Source Code Templates.

    0 讨论(0)
  • 2021-02-09 08:54

    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.

    0 讨论(0)
  • 2021-02-09 09:00

    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.

    0 讨论(0)
  • 2021-02-09 09:01

    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.

    0 讨论(0)
  • 2021-02-09 09:08

    I think you can use Eclipse replace command using Regular Expression.

    Imagine that your copyright is something like:

    /* jQuery UI CSS Framework
    *  Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
    *  Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
    */
    

    then

    1. Go to menu: Search -> File
    
    2. in the Search dialog 
    2.1. check the "Regular Expression"
    2.2. in the Containing text:
        \A[^(\Q/*\E\s+jQuery.*)]
    2.3 click the Replace
        past your copyright
    

    Explanation of regex:

    \A - Start of the file

    \Q...\E - Here goes the regex keywords ( because / and * are keys in regex )

    \s+ - whitespaces

    [^(..)] - means except

    0 讨论(0)
  • 2021-02-09 09:08

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

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

    0 讨论(0)
提交回复
热议问题