Search code examples
javaeclipselines-of-code

Java LOC counting by comparing two project


I have two Java projects in eclipse. Same project but different versions.

Now I want to compare these projects and find out the Inserted, Modified, Deleted LOCs of each java project.

Is there any plugins are available for this same purpose? Or is there any such tools are available? Please advise me.


Solution

  • You can click to projects/folders/packages in Eclipse, right click and select Compare With > Each Other. That will give you an overview of the differences between them. It does not give it on a line basis however, nor does it recurse into subdirectories.

    On Linux, you could use diff and diffstat together like follows.

    diff -rN old-dir new-dir | diffstat
    

    Argument -r will make the diff recursive (i.e. look in subdirectories), and -N will treat missing files as empty (to report lines as added, rather than the file as added).

    This will produce a list like:

    directory/some-file  |    5 +++++
    directory/other-file |   18 +++++++++-------
    2 files changed, 14 insertions(+), 7 deletions(-)
    

    It doesn't report number of modified files, but inserted and deleted.