1. Directory Structure Division Assumption You have a work directory as: / home / camry / work, hereinafter referred to as Work In order to adapt to multiple projects, I have configured a basic configuration file to be placed under Work / Common. Directory structure is Such:
WORK / Common / Build_common.xml # This file contains basic build operations Common.xml # This file is build_common.xml configured, basically no change. Build_tomcat.xml # This file contains basic operations with Tomcat. Tomcat. XML # This file is configured for build_tomcat.xml, basically only needs to be configured. Build.xml # This file is the build configuration required for each project, but basically does not need to be changed. Build.Properties # This file is Build.xml is configured, related to specific items. Usage.txt # This file illustrates various operations in the build process.
LIB / # This directory is placed in a common JAR package. CheckStyle-all-3.4.jar # is used for code check httpunit.jar # for HTTP unit test junit.jar # for unit test servlet-api.jar # Write a servlet related file
Template / # This directory is a set project template. When a project will copy the data of this directory to the project directory for direct use. BIN / # This directory places the executable bund / # this directory to place the auxiliary file required to build Checkstyle_checks.xml # This file is checkstyle's profile Java.Header # This file is also the checkstyle configuration file to show that your Java file head constructed DIST / # this directory placement destination file classes / # Class file after compiling Class files The JAR file generated after this lib / # packaged this lib / # this directory placement item related JAR file src / # this directory placement source code build.xml # This file is used for configuration files that work with CVS MAIN / # # 目 主要 码 放 测试 测试 测试 测试 测试 测试
Summary: Build_Common.xml, Common.xml and USAGE.txt
2. Introduce Build_Common.xml, Common.xml, and USAGE.txt. The following is the contents of build_common.xml file.
Xml Version = "1.0" Encoding = "ISO-8859-1"?>
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 (at your option) 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 ->
"******************************************************************************************* ********************************************************** ************************ **** One or more tests failed! Check the output ... **** ******* *********************************************************** * ********************************************************** ********
The following is the content of the common.xml file.
XML Version = "1.0" encoding = "ISO-8859-1"?>
root>
The following is the usage.txt file content.
$ {Component.name} build file ---------------------------------------------------------------------------------------------------------------------------------- ---
Available Targets Are:
Prepare -> Initialization Project Environment CheckStyle -> Check Source File Coding Specification Compile -> Compile JAR -> Packing Build -> Built Test -> Test Clean -> Clear Deploy -> Publish to Web Server Run Publish -> Release Product (Source and Target File) Fetch -> Get the latest resource DOCS from CVS -> Create API Document All -> Execute Clean, Fetch, Build, Test, DOC, Deploymain -> Default Build process (self-modification)
Summary: Build.xml, Build.properties, BUILD.PROPERTIES
2. Introduction Build.xml, Build.properties
. The following is the content of build.xml file. XML Version = "1.0" Encoding = "ISO-8859-1"?>
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 (at your option) 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 ->
The following is the content # initializing environment for the build.properties file content #
# # c 文件 文件 位置, if you may write this under Windows: D: /Work/commonpath.common=/home/camry/Work/common
# 项目 项目 相关 = Appcomponent.Package = com.Vitular.appcomponent.title = appcomponent.version = 0.1a
# CVS root location cvsroot =: pserver: Camry@x.x.x.x: / usr / cvsroot
# ftp setting # ftp.server = x.x.x.x # Remote server location # ftp.user = Rat # username # ftp.pass = ***** # User password # remote.dir = / opt / release # Remote publishing directory location
Summary: 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. Code checks in build_common.xml already has this task, but two profiles are needed, but also download the Checkstyle's JAR package here and put it in the work / common / lib / directory.
These two profiles are: Work / Common / Template / Build / ChemStyle_Checks.xml file and java.header file checkStyle_Checks.xml file Description How should I check for Java files, the java.header file points out each Java file Head structure.
The checkstyle_checks.xml file is as follows, which is a source of Johan, which has made a change. The specific instructions for each configuration give a link. If you don't understand, you can take a closer look.
XML Version = "1.0" encoding = "ISO-8859-1">
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 (at your option) 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 the GNU General Public License along with this program of;! If not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ->
target> PROJECT>
The following is the content of Tomcat.xml.
XML Version = "1.0" encoding = "ISO-8859-1"?>
When using, pay attention to the WAR directory before using the WORK / engineering directory / under: WAR directory structure is: WORK / Engineer / WAR Web-INF / CLASSES / # Place the Class file lib / # to place the required JAR package web. XML # web configuration file
With these configurations, just start Tomcat when working with Tomcat, then don't have to take Tomcat, just call Ant Deploy, Ant Stop, Ant Start and other tasks.
Summary: Together with CVS
Many people use CVS as version control tools, but it has a little bit of trouble, there is no -r option when commit, can't pass the child directory data. Don't tighten, you can use Ant to make this gap, but you need to do it first. Some preparations. There is a build.xml file in the work / common / template / src / directory. This file is for CVS tasks. After the new project project, place such a build in each subdirectory of the SRC. The .xml file to operate the current directory and its subdirectory version control command, you can realize the recursive operation. What is the trouble is to create such a file per directory, and the ANT calls CVS not support wildcard, you must write a clear The name of the file. But this is also more security. If a friend has a better way, I hope to tell me .. The following is the content of this build.xml file.
XML Version = "1.0"?>
Summary: How to use this ANT environment
Now there is already an anti-ANT environment, put it in the work / common / directory, the configuration file is also complete, you can start working.
Steps to conduct projects: 1. Give the project a loud name, called Proj bar:) 2. CD to work / down 3. Mkdir Proj4. Copy Work / Common / Build.xml and Build.properties file to Proj 5. Modify Build.Properties to change the items related to the project, such as what is the name. 6. CD to Proj 7. Ant usage (You can see how to use it) 8. Ant Prepare (build the directory structure) 9. Ok, start tapping the code. Create a directory COM / VITULAR / PROJ / 10 in src / main / down. Build a hello.java file in src / main / com / vitular / proj /. Ant Checkstyle Whether or not I have a qualified copy of the catalog and not let me create a PUBLIC constructor. (As long as it contains the main () function it), I have to modify it. I have changed it. 11. Ant compile ( Compiled) 12. ANT JAR (packaged)