Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 77026

Summary: [relengtool] allow fix copyright.. action to be more customizable
Product: [Eclipse Project] Platform Reporter: Amy Wu <for.work.things>
Component: RelengAssignee: Platform-Releng-Inbox <platform-releng-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P5 CC: airvine, carolynmacleod4, daniel_megert, john.arthorne, kim.moir, Michael.Valenta, mober.at+eclipse, thatnitind
Version: 3.2Keywords: helpwanted
Target Milestone: 3.6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 277735    
Bug Blocks:    
Attachments:
Description Flags
org.eclipse.releng.tools patch
none
fix copyrights preference page screenshot
none
org.eclipse.releng.tools.patch
none
new copyright tool preference page screenshot none

Description Amy Wu CLA 2004-10-26 12:17:41 EDT
The current Fix Copyright.. action included in org.eclipse.releng.tools is 
pretty neat but so strict.  It would be real nice if it was a little more 
flexible.

It would be nice to customize the following: 
-Copyright notice (currently it's always the below statement but this would be 
changing to use EPL instead of CPL)
/******************************************************************************
 * Copyright (c) {DATE} {INITIAL COPYRIGHT OWNER} {OTHER COPYRIGHT OWNERS}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 *
 * Contributors:
 *    {INITIAL AUTHOR} - initial API and implementation 
 ****************************************************************************/ 

-default creation year (currently it's 2003 and it needs to be changed with 
every year)

-default contributors list (currently it's only "IBM Corporation - initial API 
and implementation" and other other initial contributors will need to modify 
this themselves)

-the ability to replace all existing copyright statements with a brand new one

-the ability to update all existing copyright statements with a brand new one 
(keeping the old creation year/contributors list for example, when switching 
over from CPL to EPL)

-the ability to ignore copyright statements in .properties files

-have the fix copyright action work on any IResource, not just IProject 
(sometimes a project might include packages copied from other sources that you 
don't want to touch)

Having these options in a preference page would make the fix copyright tool 
easier to use and more controllable.
Comment 1 Amy Wu CLA 2004-10-26 12:25:21 EDT
Created attachment 15395 [details]
org.eclipse.releng.tools patch

Here is a patch I made for org.eclipse.releng.tools that adds most of the
suggestions I listed in the previous note.  Rather than mess with the current
Fix Copyright tool, I added an "Advanced Fix Copyright.." action that should
show up in the Navigator view for all IResources

The suggestions I did not implement were:
-default contributors list (currently it's only "IBM Corporation - initial API 

and implementation" and other other initial contributors will need to modify 
this themselves)
-the ability to update all existing copyright statements with a brand new one 
(keeping the old creation year/contributors list for example, when switching 
over from CPL to EPL)

And I did not implement them mainly because I could not think of an
easy/flexible way to parse the contributors list.
Comment 2 Amy Wu CLA 2004-10-26 12:28:10 EDT
Created attachment 15396 [details]
fix copyrights preference page screenshot

Here is a screenshot of the Copyright Tool preference page that shows up in the
Preferences.. dialog with the patch.
Comment 3 Amy Wu CLA 2004-11-05 16:50:10 EST
Created attachment 15704 [details]
org.eclipse.releng.tools.patch

Actually, I found some bugs with the previous patch.  Here is a corrected
patch.	I also updated the functionality a little bit so that users can choose
to have a default revision year and also to just always use that default
revision year instead of asking CVS for the real revision year.  This saves
time because asking cvs the revision year for every file takes quite a while.

While I was at it, I made the fix copyright tool a cancellable background job.
Comment 4 Amy Wu CLA 2004-11-05 16:50:40 EST
Created attachment 15705 [details]
new copyright tool preference page screenshot
Comment 5 Nitin Dahyabhai CLA 2005-08-24 10:53:38 EDT
+1 for including this in the 3.2 releng tools
Comment 6 Andrew Irvine CLA 2005-11-30 17:15:24 EST
+1 for 3.2, but ...

I would go even further than suggested.  Make the entire copyright block customizable.  For example not all Eclipse based products will be under the CPL/EPL/whatever license.

Extract all text fields out such that users provide a property file with what text they want for the various blocks.  Blocks would include the initial copyright line, the all rights reserved block and the contributors block.
Comment 7 Andrew Irvine CLA 2005-11-30 17:16:48 EST
Should have looked at the screen shot first.  Looks customizable to me.  Still a +1!
Comment 8 Sonia Dimitrov CLA 2005-12-01 16:16:31 EST
Patch applied in 3.2 stream.
Comment 9 Andrew Irvine CLA 2005-12-06 12:40:26 EST
I downloaded the latest version of releng tools.  After installing on Eclipse 3.2M3 I modified the template via the preference pages to be of the format:

Copyright (c) ${date} myCompany.
All rights reserved.

When ran via the team menu files were updated with the standard IBM copyright, ignoring the template of the preference page.
Comment 10 Andrew Irvine CLA 2005-12-06 12:56:30 EST
This bug and I just don't get along.  Switching to the "Navigator" view I saw the "Advanced Fix Copyright.." item on the menu, which does exactly what I expected, replaces the copyright as written.

I had not realized I was looking for a new menu item; since I was in the Package Explorer I never saw the new entry.  If this tool is accepted as the way to fix copyrights it might be an idea to replace the existing entry with this entry.
Comment 11 Sonia Dimitrov CLA 2005-12-06 16:15:47 EST
Re-opening to address issue identified in comment #10.
Comment 12 Carolyn MacLeod CLA 2009-05-29 12:06:00 EDT
Unfortunately, the excellent suggestion in comment 10 and 11 (replace the old FixCopyrightAction with the new AdvancedFixCopyrightAction) was never done, and so we have been running with 2 slightly different Fix Copyrights actions since 2005.

Since then, the two actions have diverged.

Bug 140936, Bug 180988, Bug 234872, and Bug 277735 were fixed in AdvancedFixCopyrightAction, and

Bug 140936, Bug 180988, Bug 234872, Bug 186121, and Bug 180767 were fixed in FixCopyrightAction.

The context menu item text has changed over the years also, but in the current version of Eclipse (3.5) the menu items are:
1) "Fix Copyrights"  (this runs the newer AdvancedFixCopyrightAction.java, which uses the preferences in the Copyright Tool preference page)

2) "Eclipse/IBM Fix Copyrights..."  (this runs the old FixCopyrightAction.java, and does NOT use the Copyright Tool preferences, therefore it uses a hardcoded copyright that is only useful for Eclipse/IBM files)

I had a chat with Michael Valenta, who says that there are some key advantages to the newer AdvancedFixCopyrightAction:
a) The CVS performance problem can be fixed in AdvancedFixCopyrightAction
b) AdvancedFixCopyrightAction is SVN-ready
c) The Preferences page provided by AdvancedFixCopyrightAction makes it more flexible because it provides a copyright template that can be used by anyone (but the default is the standard Eclipse/IBM copyright).

So - I am proposing to delete the old FixCopyrightAction for 3.6. If anyone is still using it, please do a test run of selecting the new "Fix Copyrights" menu item. This should just work for you, with the default preference settings. If there are any issues, please open a new bug and point to it from here.
Comment 13 Carolyn MacLeod CLA 2009-05-29 12:26:41 EDT
Comment 12 mentions a CVS performance problem, and adding SVN capability.
FYI, the bug covering these issues is bug 216797.
Comment 14 John Arthorne CLA 2009-05-29 12:55:53 EDT
+1 on deleting the old action in 3.6. The last missing features from "advanced fix copyrights" was the ripple problem (updating copyrights due to a previous copyright update in previous year). That final issue was fixed in bug 277735 so I think the new action is now all we need.
Comment 15 Martin Oberhuber CLA 2009-05-29 13:35:14 EDT
(In reply to comment #12)
FYI, "Advanced Fix Copyright" does a fallback to the original "Eclipse/IBM Fix Copyrights" code when it finds a copyright but cannot interpret it properly. With the recent changes from bug 277735 this is pretty unlikely now because pretty much any text is accepted as Copyright comment as long as it is a block comment and has Copyright (c) in it.

From the top of my head, here's a few things where "Eclipse/IBM Fix Copyrigths" currently differs from the "Advanced" one -- this list of differences has been reduced over the years but still is not quite at zero:

* Eclipse/IBM can do "copyright normalization", i.e. it can detect slightly 
  different coypright text (such as "and others." on the first line or not; 
  differences in space chars or formatting; typos;) and replace these all with
  the standard Eclipse/IBM copyright notice.
  The other (Advanced) action, on the other hand, keeps the text as it is and
  only replaces/updates the copyright year.

* Eclipse/IBM has some SWT specific handling built in (hardcoded) for licenses
  other than EPL (Mozilla, Apache). Again, Advanced can do kinda the same 
  because it keeps the existing text unchanged and only updates the year.

I have personally used the "Advanced" form successfully this year and I'm much in favor of making this the only available one. For "Copyright Normalization" it is questionable whether this is actually needed. Also, some additional preference / customization options would help getting the same form the advanced one.

I think that as per the current state of affairs, when the patch for bug 277735 is going to be released with RC3 then everybody should be on the safest side just using the "Advanced" action. The "Eclipse/IBM" one is currently buggy in that it can destroy XML files (bug 276257).
Comment 16 Martin Oberhuber CLA 2009-05-29 13:36:49 EDT
(In reply to comment #11)
> Re-opening to address issue identified in comment #10.

If I'm not mistaken, the issue from comment #10 is fixed now so this bug could be finally closed ?

Comment 17 Carolyn MacLeod CLA 2009-05-29 13:43:59 EDT
I read the issue from comment 10 as this one:
"If this tool [the advanced one] is accepted as the way to fix copyrights it might be an idea to replace the existing entry with this entry."
Comment 18 Dani Megert CLA 2009-05-29 13:59:25 EDT
Martin, you probably made a typo when you've set bug 227735 blocking this bug.
Comment 19 Martin Oberhuber CLA 2009-05-29 14:11:20 EDT
Thanks Dani :) It's bug 277735 of course.
Comment 20 Carolyn MacLeod CLA 2009-06-01 16:41:45 EDT
FYI, I ran AdvancedFixCopyrightAction (aka "Fix Copyrights") on SWT for 3.5 RC4, and I am very happy with the results. In fact, it discovered many places where the old version of the tool missed an update. I will never need to run the old FixCopyrightAction again.

Dani, if you could, please run "Fix Copyrights" on all of your projects and see if you trust the tool. If you do, then that is one more step towards deleting the old tool and clearing up some of this annual confusion.
Comment 21 Dani Megert CLA 2009-06-08 10:14:57 EDT
>Dani, if you could, please run "Fix Copyrights" on all of your projects and see
>if you trust the tool.
I tried it and it works for me.
Comment 22 Carolyn MacLeod CLA 2009-06-08 17:02:23 EDT
Thanks, Dani - that's great.
Comment 23 Kim Moir CLA 2010-06-02 16:11:00 EDT
Can this bug be closed?
Comment 24 Martin Oberhuber CLA 2010-06-02 16:22:11 EDT
Given that there have been no complaints about the Copyright tool in the Helios time frame, I agree that this can be closed.

I'm going to open a new bug for SVN support.
Comment 25 Kim Moir CLA 2010-06-02 16:45:30 EDT
closing.
Comment 26 Carolyn MacLeod CLA 2010-06-02 18:21:20 EDT
Opened bug 315509 to finally delete the older action. (see comment 12)