Use Ant to make you programs (4)

xiaoxiao2021-03-06  106

[Home, Previous, Next]

4 cooperation with Checkstyle

Summary: Introduction Checkstyle_Checks.xml, Java.Header

Now there is a directory structure. It has build_common.xml, common.xml, usage.txt, build.xml, build.properties, etc. You can already complete most of the tasks. Now you will introduce how to make a secondary task, such as code check.

The code check has this task in build_common.xml, but also to download the Checkstyle's JAR package to http://checkstyle.sf.net and put it in the work / common / lib / directory. Finally, two configurations File fit.

These two profiles are the checkstyle_checks.xml file in the work / common / template / build / directory. Checkstyle_Checks.xml file Description How to check the Java file, the java.header file points out each Java file Head structure.

The checkstyle_checks.xml file is as follows, which is a one-time modification. The specific description of each of them gives a link. If you don't understand, you can take a closer look.

Copyright 2004 Johan Kng, http://dev.kanngard.net

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 2 of the license, OR

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, Write to the Free Software

Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

->

"- // puppy crawl // DTD Check Configuration 1.2 // en"

"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

Based on the checkstyle configuration file sun_checks.xml with some minor

Modifications ..

CHECKSTYLE IS VERY CONFIGURBLE. Be Sure To Read The Documentation AT

http://checkstyle.sf.net

->

"- to have access to ant profmentness. in this case->

Name = "Headerfile"

Value = "$ {basedir} /build/java.header" />

->

->

->

"- Miscellaneous Other Checks. ->

There will be such a troublesome place when using this checkstyle: it does not allow excess spaces at the end. For programmers, who cares about such spaces, but the program is such a dead :) Users who use Vim can be It is found to easily eliminate the endless space. The following is my Java file head constructor, of course, each team can have its own agreement. Because the 3rd, 5th, 8 lines change, I ignore it. For them, this can be seen from the checkstyle_checks.xml file above. / *

* ------------------------------------------------- ------------

* file name: _filename_

* Authors: wuh (wuh@vitular.com)

* Created: _datetime_

* Copyright: (c) 2003 Vitular Inc. All Rights Reserved.

*

* Modifications:

*

* ------------------------------------------------- ------------

* /

Some friends may feel that every time I write such ahead, I don't have any trouble, but for me, this is very easy to make Vim. When I use Vim to create a Java file, it will automatically Add this header, and replace the _filename_ and _datetime_ these parameters with the appropriate file name and time. Here, how to do this.

[Home, Previous, Next]

转载请注明原文地址:https://www.9cbs.com/read-103098.html

New Post(0)