Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19787

Re: ant task to compute lines of code

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: ant task to compute lines of code
Date Sun, 18 Nov 2012 17:24:40 +0100
Lines 39
Message-ID <agsge8F5o27U1@mid.individual.net> (permalink)
References <k8avks$nl8$1@news.m-online.net>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net RTb93syeikiHdkMW3pImJwNqvK31Ln1jCADFR8q39D+XFoKIGpqUQW/8v9TkcipQo=
Cancel-Lock sha1:6usHD3pGe+UMptNbcLYk2PXIzIw=
User-Agent Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2
In-Reply-To <k8avks$nl8$1@news.m-online.net>
Xref csiph.com comp.lang.java.programmer:19787

Show key headers only | View raw


On 11/18/2012 04:43 PM, Laura Schmidt wrote:
> Hello,
>
> I want to find out the total lines of code of a project using an ant task.
>
> On the commandline I would do this like this:
>
> find src -name *.java | wc -l

No, you wouldn't.  That would give you the number of source files - at 
best.  Worst case is an error from "find" indicating invalid command 
line arguments.  Other variants are also possible, e.g. including 
directories or symlinks in the count.

More successful approaches

find src -type f -name \*.java -exec cat {} + | wc -l

{
   echo 0
   find -type f -name \*.java -exec wc -l {} + \
   | sed -n 's#^ *\([0-9]\+\) \+total$#\1+#p'
   echo n
} | dc

Btw, all these also count empty lines.  For non empty lines something 
like this could work

{
   echo 0
   find -type f -name \*.java -exec egrep -hc '[^[:space:]]' {} + \
   | sed 'a +'
   echo n
} | dc


Kind regards

	robert

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

ant task to compute lines of code Laura Schmidt <ls@mailinator.com> - 2012-11-18 16:43 +0100
  Re: ant task to compute lines of code "John B. Matthews" <nospam@nospam.invalid> - 2012-11-18 11:19 -0500
    Re: ant task to compute lines of code Roedy Green <see_website@mindprod.com.invalid> - 2012-11-19 19:27 -0800
  Re: ant task to compute lines of code Robert Klemme <shortcutter@googlemail.com> - 2012-11-18 17:24 +0100
    Re: ant task to compute lines of code Laura Schmidt <ls@mailinator.com> - 2012-11-19 04:28 +0100
      Re: ant task to compute lines of code Lew <lewbloch@gmail.com> - 2012-11-18 20:35 -0800
        Re: ant task to compute lines of code Robert Klemme <shortcutter@googlemail.com> - 2012-11-19 05:07 -0800
  Re: ant task to compute lines of code Arne Vajhøj <arne@vajhoej.dk> - 2012-11-18 11:52 -0500
  Re: ant task to compute lines of code Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-11-19 00:05 -0600
  Re: ant task to compute lines of code Jeff Higgins <jeff@invalid.invalid> - 2012-11-19 08:44 -0500

csiph-web