完整的ant脚本,包含javac、javadoc、checkstyle、findbugs等等脚本命令。如果你还没有完整的ant脚本来管理工程,请参考使用此脚本,肯定给项目的管理带来很多好处。Ant脚本在手,管理工具不求。
静态代码检查工具三剑客,Checkstyle、findbugs、pmd的task都包含了,呵呵。请注意看清楚命令中的版本,这三个工具都可以从网络下载。
目录的结构个人喜好不一样,如果你的目录结构和我的不一致,请修改脚本中对应的参数。
目录结构说明图:
Ant脚本如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Framework" default="build" basedir=".">
<!--
src:java source code
test:java test source code folder
resources:configuration file folder
dist:The jar and classes.
-classes
report:Test result report and checkstyle report folder.
-checkstyle
-tests
-findBugs
doc:Do not delete the folder.
Javadoc and checksyle configuration files.
-javadoc
-pmd
-codestyle
-findBugs
-->
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/WebRoot/WEB-INF/lib"/>
<property name="test.lib.dir" value="${basedir}/testlib"/>
<property name="dist.dir" value="${basedir}/dist"/>
<property name="dist.classes" value="${dist.dir}/classes"/>
<property name="docs.dir" value="${basedir}/doc"/>
<property name="report.dir" value="${basedir}/report"/>
<property name="jar.file" value="framework-core-1.0.jar"/>
<!-- All Need jar-->
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${test.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${dist.dir}" excludes="**/.svn" />
<delete dir="${report.dir}" excludes="**/.svn" />
<delete dir="${dist.classes}" excludes="**/.svn" />
</target>
<target name="prepare" depends="clean" description="Create the target directories">
<mkdir dir="${dist.dir}" />
<mkdir dir="${report.dir}" />
<mkdir dir="${report.dir}/tests" />
<mkdir dir="${report.dir}/checkstyle" />
<mkdir dir="${dist.classes}" />
</target>
<!--
=================================src下面java文件到指定class目录=====================
请注意一些配置文件需要全部拷贝过去,不要遗漏
-->
<target name="compile" depends="prepare" description="========WEBFUSW COMPILE=====">
<javac encoding="utf-8" destdir="${dist.classes}" debug="true">
<src path="${src.dir}" />
<classpath>
<path refid="classpath" />
</classpath>
</javac>
<copy todir="${dist.classes}">
<fileset dir="resources">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<!--================================= 产生javadoc===================== -->
<target name="javadoc">
<mkdir dir="${docs.dir}/javadoc" />
<javadoc encoding="utf-8" sourcepath="${src.dir}" destdir="${docs.dir}/javadoc">
<classpath refid="classpath"/>
</javadoc>
<echo message="...........Javadoc command complete...."/>
</target>
<!--================================= test and create report===================== -->
<!--
<target name="tests" depends="compile">
<junit printsummary="on" fork="true" haltonfailure="false" failureproperty="tests.failed" showoutput="true">
<classpath>
<fileset dir="${classpath}" includes="**/*.jar" />
<pathelement path="${dist.classes}" />
</classpath>
<formatter type="xml" />
<batchtest todir="${report.dir}/tests">
<fileset dir="${dist.classes}">
<include name="**/*Test.*" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${report.dir}/tests">
<fileset dir="${report.dir}/tests">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.dir}/tests" />
</junitreport>
</target>
-->
<!--
================================= create checkstyle report=====================
Please notify:modify the param of checkstyle-frames-errors.xsl and checkstyle-frames.xsl files as below
<xsl:param name="output.dir" select="'report/checkstyle'"/>
-->
<taskdef resource="checkstyletask.properties" classpath="${docs.dir}/checkstyle/checkstyle-all-5.0.jar"/>
<target name="checkstyle" depends="prepare" description="Generates a report of code convention violations.">
<mkdir dir="${report.dir}/checkstyle" />
<checkstyle
config="${docs.dir}/checkstyle/checkstyle_checks.xml"
failOnViolation="false">
<fileset dir="${src.dir}" includes="**/*.java" excludes="**/*Test.java" />
<formatter type="xml" toFile="${report.dir}/checkstyle/checkstyle_result.xml" />
</checkstyle>
<style in="${report.dir}/checkstyle/checkstyle_result.xml" out="${report.dir}/checkstyle/blank_report.html" style="${docs.dir}/checkstyle/checkstyle-frames-errors.xsl"/>
</target>
<!--
================================= findBugs report=====================
Run Error:javaheap is over,need modify the configure.
-->
<taskdef name="findbugs" classpath="${docs.dir}/findBugs/findbugs.jar" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
<property name="findbugs.home" value="${docs.dir}/findbugs" />
<target name="findbugs" description="Running findBugs......">
<mkdir dir="${report.dir}/findBugs" />
<findbugs home="${findbugs.home}"
output="xml"
outputFile="${report.dir}/findBugs/findBugs-report.xml" jvmargs="-Xmx512m">
<auxClasspath path="${docs.dir}/findBugs/jakarta-regexp-1.5.jar" />
<!-- dist.classes
<class location="${docs.dir}/findBugs/bcel.jar" />
-->
<class location="${dist.classes}" />
<!-- show findBugs -->
<sourcePath path="${src.dir}" />
</findbugs>
</target>
<!--
================================= PMD report=====================
PMD means from pmd.sourceforge.net:
Pretty Much Done.
Programming Mistake Detector.
<ruleset>basic</ruleset>
-->
<target name="pmd" description="Running PMD......">
<mkdir dir="${report.dir}/pmd" />
<taskdef name="pmd" classpath="${docs.dir}/pmd/pmd-4.2.5.jar" classname="net.sourceforge.pmd.ant.PMDTask"/>
<pmd shortFilenames="true">
<ruleset>${docs.dir}/pmd/springside3_ruleset.xml</ruleset>
<formatter type="html" toFile="${report.dir}/pmd/pmd_report.html" linkPrefix="../../doc/javadoc/"/>
<formatter type="xml" toFile="${report.dir}/pmd/pmd.xml" />
<fileset dir="${src.dir}">
<!--<include name="java/lang/*.java"/>-->
</fileset>
</pmd>
</target>
<!--
================================= JAR Task=====================
checkstyle,pmd,javadoc,compile
${dist.classes}
-->
<target name="jar" depends="compile,checkstyle,pmd,findbugs">
<jar destfile="${dist.dir}/${jar.file}">
<fileset dir="${dist.classes}">
<include name="**/*.class"/>
<include name="**/*.xml" />
<include name="**/*.conf" />
<include name="**/*.sql" />
<include name="**/*.properties" />
<include name="**/*.dtd" />
<exclude name="**/*Test.class" />
<exclude name="**/Test*.class" />
</fileset>
</jar>
</target>
<target name="build" depends="jar,javadoc" description="build project" />
</project>
- 大小: 12.5 KB
分享到:
相关推荐
ant build脚本代码,自动化多渠道打包,自定义任务打包 具体看一下这篇博客 http://blog.csdn.net/lsmfeixiang/article/details/49681583
ant build脚本代码,自动化多渠道打包,自定义任务打包 具体看一下这篇博客 http://blog.csdn.net/lsmfeixiang/article/details/49681583
java项目ant打包脚本,包括环境变量设置,打包脚本等信息,共有三个文件 ant.bat、build.xml、setEnv.cmd
用于jenkins+ant部署jmeter脚本,用于jenkins+ant部署jmeter脚本,
gwt_ant_build脚本研习 目录 build.xml源文件 构建工程war的分析 自定义的build工程文件
ant脚本例子,一个build.xml模板, 修改后直接运行。
ant脚本构建工具,有详细的注释、用于构建程序war包,执行编译、修改、拷贝、远程上传程序war包、远程发布程序、远程重启服务器(tomcat)
实际开发中的ant编译脚本代码,拥有完善的结构,只需要修改开始几个字段即可使用。
jmeter+ant 持续集成build.xml文件,直接使用ant命令执行jmeter脚本文件,得到图形测试报告
xdocet ant 生成HIBERNATE映射文件。 部署EJB项目。
jmeter+ant+jenkins---build.xml文件,下载运行即可成功
build_with_bat是基于bat脚本实现的。 build是在build_with_bat的基础上实现的,主要是在compile和dex部分增加了第三jar的打包。 build_mulity_channel是多渠道打包脚本。该脚本需要ant-contrib-1.0b3.jar的支持。...
Ant 是著名Java开源组织Apache的一个项目,是一个基于java的build工具。它可以使你通过ant脚本语言,自动你的项目拷贝到某个目录,发布项目,或者生成一些代码,执行SQL语言。总之它可以帮助你完成项目开发中除了...
通常利用Ant工具来对程序源代码进行编译(当然也可以利用IDE工具编译),通常build.xml文件执行默认“compile”任务来完成编译过程。
ant运行jmeter脚本的build.xml文件
配合ant使用,可以让jmeter飞起来,文件中对生成的文件进行了备份归档整理,同时调用两个测试报告模版,让功能更加强大
Ant脚本打包Android程序的demo(含打包第三方jar)。 build_with_bat是基于bat脚本实现的。 build是在build_with_bat的基础上实现的,主要是在compile和dex部分增加了第三jar的打包。
每个ant脚本(缺省叫build.xml)中设置了一系列任务(target):比如对于一个一般的项目可能需要有以下任务。 * 任务1:usage 打印本脚本的帮助信息(缺省) * 任务2:clean 清空初始化环境 * 任务3:javadoc <-- ...
Ant Design Pro提供了一些有用的脚本,可帮助您快速启动和构建Web项目,代码样式检查和测试。 package.json提供的脚本。 修改或添加其他脚本是安全的: 开始项目 npm start 建立项目 npm run build 检查代码样式 ...
open-deploy-iib-buildscripts IIB 部署 ANT 脚本