Re: Managing copyrights on .java files

Discussion in 'Java' started by blue indigo, Mar 3, 2009.

  1. blue indigo

    blue indigo Guest

    On Mon, 02 Mar 2009 16:08:34 -0600, Spud wrote:

    > I've got to add and standardize the copyright notice on a very large
    > number of .java files. We use Eclipse. Any suggestions for tools to make
    > it easier?


    Yes. Just prepend a standard copyright notice (that is formatted as a
    legal Java comment) to every file. I could knock up a shell script to do
    that in minutes using cat and directory walking; probably I'd copy a
    license file to the output tree under each java file's name with cp and
    then append the original java file from the input tree to the output file
    using cat. Then check the output tree compiles and works still, and
    proofread a few of the files. Then junk the input tree. The license file
    being something like this:

    /*
    Copyright (C) <year> <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or (at
    your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
    */

    with appropriate substitutions, including of the license terms themselves
    if you want something other than the GPL. You might also prefer // at the
    start of every line, especially if the license might contain "*/" within
    it for some reason.

    As for automatically adding this to future source files, NetBeans has a
    feature to do this, but it's a bit awkward to use and involved
    hand-modifying the .nbproject file for a project the last time I did it.
    Eclipse probably has something comparable. Depending on what you are
    using, there may be an option in your version control system to maintain
    a start-of-file notice on each source file, in which case you might set
    that up and then just check out and check back in every source file in a
    loop to do the pre-existing ones.

    If you want to be able to easily update or modify the license, keep two
    parallel source trees. The first you use the modify the code and build it.
    The second you generate as needed from the first and a license file as
    described above using a script, and tar up as your source distribution.
    (The first can be your version control repository, with the script
    checking out each file as the input to cat and ending with the code to tar
    up its output, so it actually does the whole job of building the source
    tarball for you. Of course if you include resource files as seems likely
    it gets a bit trickier. The script can just copy non-.java files and
    prepend license terms to .java files, with resource files needing manual
    license handling, for simplicity's sake.)

    --
    blue indigo
    UA Telecom since 1987
     
    blue indigo, Mar 3, 2009
    #1
    1. Advertising

  2. blue indigo

    Lew Guest

    blue indigo wrote:
    > As for automatically adding this to future source files, NetBeans has a
    > feature to do this, but it's a bit awkward to use and involved
    > hand-modifying the .nbproject file for a project the last time I did it.


    Way too much work! Just modify the NetBeans templates for new source
    files. Nothing a-tall awkward about it:

    Menu: _T_ools / _T_emplates

    Opens "Template Manager".

    Select desired template (e.g., "Java / Java Class").

    Click "_O_pen in Editor".

    Add copyright notice.

    Save.

    Close editor window.

    Bob's your uncle.

    --
    Lew
     
    Lew, Mar 3, 2009
    #2
    1. Advertising

  3. In article
    <
    d>,
    blue indigo
    <> wrote:
    [...]
    > Then junk the input tree.

    [...]

    Even better: don't commit the changes back to your version control
    system until you've compiled and tested.

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
     
    John B. Matthews, Mar 3, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pavils Jurjans

    Managing files in bin folder

    Pavils Jurjans, May 10, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    462
    Kevin Spencer
    May 10, 2004
  2. Andrew

    Managing Diagnostic Listener Files

    Andrew, Aug 5, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    489
    Andrew
    Aug 6, 2004
  3. Kleenex

    Managing global vars between files

    Kleenex, Sep 22, 2004, in forum: C Programming
    Replies:
    10
    Views:
    505
    Kleenex
    Sep 29, 2004
  4. Replies:
    9
    Views:
    335
    Andy Dingley
    Dec 18, 2007
  5. Pif
    Replies:
    0
    Views:
    301
Loading...

Share This Page