You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Piero Campanelli <pc...@campanelli.org> on 2000/11/22 11:08:25 UTC

Code formatting task

Hi,

Is there a task in ANT wich formats source code to adhere for
example to Sun Java Coding Standard ?
In my team actually is difficult, at this state, to educate to standard
code formatting.

Bye


Re: JIndent Task (Javac Preprocessor?)

Posted by Stefan Bodewig <bo...@apache.org>.
Paul Hodgetts <pr...@zzyzxtek.com> wrote:

> I don't see any way to hook a preprocessor into the Javac task,
> so I need a new task.  Is this a correct conclusion?

Yes. I'd suggest you take a look at Conor's optional <depend> task,
which has been added shortly after the 1.2 release. It works as some
kind of preprocessor for <javac> - but hasn't been adapted to use the
GlobPatternMapper syntax that is now used by <javac> (because this is
still a very new - and undocumented - feature).

Stefan

Re: JIndent Task (Javac Preprocessor?)

Posted by Jon Stevens <jo...@latchkey.com>.
on 11/26/2000 4:16 PM, "Paul Hodgetts" <pr...@zzyzxtek.com> wrote:

> In other words, any source file whose class file is older (out of date).

I just did something similar with my AnakiaTask. Here is the source code.

<http://jakarta.apache.org/cvsweb/index.cgi/jakarta-velocity/src/java/org/ap
ache/velocity/anakia/AnakiaTask.java?rev=1.10&content-type=text/vnd.viewcvs-
markup>

It essentially comes down to this code and then code in the process method
to do the lastModified checking on the files passed in:


        // find the files/directories
        scanner = getDirectoryScanner(baseDir);

        // get a list of files to work on
        list = scanner.getIncludedFiles();
        for (int i = 0;i < list.length; ++i)
        {
            process( baseDir, list[i], destDir );
        }

More info on Anakia here:

<http://jakarta.apache.org/velocity/anakia.html>

I hope that helps,

-jon

-- 
twice of not very much is still a lot more than not very much


JIndent Task (Javac Preprocessor?)

Posted by Paul Hodgetts <pr...@zzyzxtek.com>.
I'm in the process of writing a task that will call the JIndent
formatter tool.

I'd like this task to process any source file that would be
compiled by the Javac task.  In other words, any source file
whose class file is older (out of date).

I haven't yet laid out the XML for the task, but I suspect I'll
need:
   * source directory for .java files
   * reference directory for .class files
   * destination directory for processed .java files
   * includes and excludes
   * fork (with jvm, maxmemory, dir, and timeout [like Junit task?])
   * JIndent parameters (maybe a subset since there's a bunch)

I don't see any way to hook a preprocessor into the Javac task,
so I need a new task.  Is this a correct conclusion?

 From looking at the Javac task, it looks like there are several
utility classes that can help me make the same file list that
needs to be processed that the Javac task would process (e.g.,
DirectoryScanner, SourceFileScanner, GlobPatternMapper, etc.).
Right now, it looks to me like I need to pretty much imitate
the same general code pattern from the Javac task to build the
file list, and then invoke JIndent on the files.  I think I need
to extend MatchingTask to pick up the include and exclude
features, right?

Am I on the right track?  Any advice or suggestions?  Is there
anything else I can look at (docs or sources) that might help?
I'm having a little difficulty following all the behind the
scenes processing of the file list, but maybe I just need more
time staring at the code.

Thanks in advance,
-Paul


RE: Nightly Builds?

Posted by Conor MacNeill <co...@m64.com>.
Paul,

Nightly builds have not succeeded since 15-Nov-2000. I think the best
option at the moment is to build from CVS, if you can.

Conor


> -----Original Message-----
> From: Paul Hodgetts [mailto:prh@zzyzxtek.com]
> Sent: Saturday, 25 November 2000 15:20
> To: ant-user@jakarta.apache.org; ant-dev@jakarta.apache.org
> Subject: Nightly Builds?
>
>
> I've been trying to locate a nightly build for Ant.  When I go to
>    http://jakarta.apache.org/builds/ant/nightly/
> all the bin and src directories going back to 21 Nov are empty.  Am
> I looking in the right place?
>
> I also tried to go to the IBM ftp mirror at oss.software.ibm.com .
> It asks for a password for the anonjakarta user.  I used to be able
> to just hit return on the password, but now it seems to be looking
> for some particular password.  What is it?
>
> Thanks in advance for any help,
> -Paul
>
>


RE: Nightly Builds?

Posted by Conor MacNeill <co...@m64.com>.
Paul,

Nightly builds have not succeeded since 15-Nov-2000. I think the best
option at the moment is to build from CVS, if you can.

Conor


> -----Original Message-----
> From: Paul Hodgetts [mailto:prh@zzyzxtek.com]
> Sent: Saturday, 25 November 2000 15:20
> To: ant-user@jakarta.apache.org; ant-dev@jakarta.apache.org
> Subject: Nightly Builds?
>
>
> I've been trying to locate a nightly build for Ant.  When I go to
>    http://jakarta.apache.org/builds/ant/nightly/
> all the bin and src directories going back to 21 Nov are empty.  Am
> I looking in the right place?
>
> I also tried to go to the IBM ftp mirror at oss.software.ibm.com .
> It asks for a password for the anonjakarta user.  I used to be able
> to just hit return on the password, but now it seems to be looking
> for some particular password.  What is it?
>
> Thanks in advance for any help,
> -Paul
>
>


Nightly Builds?

Posted by Paul Hodgetts <pr...@zzyzxtek.com>.
I've been trying to locate a nightly build for Ant.  When I go to
   http://jakarta.apache.org/builds/ant/nightly/
all the bin and src directories going back to 21 Nov are empty.  Am
I looking in the right place?

I also tried to go to the IBM ftp mirror at oss.software.ibm.com .
It asks for a password for the anonjakarta user.  I used to be able
to just hit return on the password, but now it seems to be looking
for some particular password.  What is it?

Thanks in advance for any help,
-Paul



Nightly Builds?

Posted by Paul Hodgetts <pr...@zzyzxtek.com>.
I've been trying to locate a nightly build for Ant.  When I go to
   http://jakarta.apache.org/builds/ant/nightly/
all the bin and src directories going back to 21 Nov are empty.  Am
I looking in the right place?

I also tried to go to the IBM ftp mirror at oss.software.ibm.com .
It asks for a password for the anonjakarta user.  I used to be able
to just hit return on the password, but now it seems to be looking
for some particular password.  What is it?

Thanks in advance for any help,
-Paul



Re: Code formatting task

Posted by Stanislas Pinte <st...@wanadoo.be>.
could be great!

I've seen some open-source code-beautifiers, like, I guess, PrettyJ.

Stan.

At 11:08 AM 11/22/00 +0100, you wrote:
>Hi,
>
>Is there a task in ANT wich formats source code to adhere for
>example to Sun Java Coding Standard ?
>In my team actually is difficult, at this state, to educate to standard
>code formatting.
>
>Bye

-------------------------------------------------------

Stanislas Pinte
Software engineer - Trademine-europe
Tel: 00 32 486 67 78 86

-------------------------------------------------------


Re: Code formatting task

Posted by Paul Hodgetts <pa...@zzyzxtek.com>.
Piero Campanelli wrote:

 > Is there a task in ANT wich formats source code to adhere for
 > example to Sun Java Coding Standard ?
 > In my team actually is difficult, at this state, to educate to standard
 > code formatting.

I've been playing around with implementing a JIndent task.  I
want it to process any source file that is about to be compiled.
In other words, only the ones that are out of date and will be
picked up by the Javac task.  Sort of like a preprocessor for
the Javac task.

Short of writing or stealing a lots of code that determines what
files need to be recompiled and adding that code to my new
JIndent task, does anyone have any ideas how to add preprocessor-
like functionality when compiling?  Maybe I'm missing something
easy and obvious?

Thanks,
-Paul Hodgetts


Re: Code formatting task

Posted by Paul Hodgetts <pr...@zzyzxtek.com>.
Piero Campanelli wrote:

 > Is there a task in ANT wich formats source code to adhere for
 > example to Sun Java Coding Standard ?
 > In my team actually is difficult, at this state, to educate to standard
 > code formatting.

I've been playing around with implementing a JIndent task.  I
want it to process any source file that is about to be compiled.
In other words, only the ones that are out of date and will be
picked up by the Javac task.  Sort of like a preprocessor for
the Javac task.

Short of writing or stealing a lots of code that determines what
files need to be recompiled and adding that code to my new
JIndent task, does anyone have any ideas how to add preprocessor-
like functionality when compiling?  Maybe I'm missing something
easy and obvious?

Thanks,
-Paul Hodgetts