Ant自动化构建项目
1 普通java项目
<?xmlversion="1.0"encoding="UTF-8"?><projectdefault="ftp"><propertyname="src.dir"location="src"></property><propertyname="test.src.dir"location="test"></property><propertyname="lib.dir"location="lib"></property><propertyfile="build.properties"></property><propertyname="build.dir"location="build"></property><propertyname="build.classes"location="${build.dir}/classes"></property><propertyname="build.test.dir"location="${build.dir}/test"></property><propertyname="build.test.classes"location="${build.test.dir}/classes"></property><propertyname="build.test.report"location="${build.test.dir}/report"></property><propertyname="build.jar.dir"location="${build.dir}/dist"></property><propertyname="build.zip.dir"location="${build.dir}/zip"></property><propertyname="build.doc.dir"location="${build.dir}/doc"></property><propertyname="build.src"location="${build.dir}/src"></property><propertyname="metadata.dir"location="metadata"/><pathid="compile-classpath"><filesetdir="${lib.dir}"includes="*.jar"></fileset></path><pathid="compile-test-classpath"><pathrefid="compile-classpath"></path><pathelementlocation="${build.classes}"/></path><pathid="run-test-classpath"><pathrefid="compile-test-classpath"/><pathelementlocation="${build.test.classes}"/></path><targetname="clean"><deletedir="${build.dir}"/></target><targetname="init"depends="clean,metadata"><mkdirdir="${build.dir}"/><mkdirdir="${build.classes}"/><mkdirdir="${build.test.dir}"/><mkdirdir="${build.test.classes}"/><mkdirdir="${build.test.report}"/><mkdirdir="${build.jar.dir}"/><mkdirdir="${build.zip.dir}"/><mkdirdir="${build.doc.dir}"/><mkdirdir="${build.src}"/><mkdirdir="${metadata.dir}"/></target><targetname="compile"depends="init"><javacdestdir="${build.classes}"srcdir="${src.dir}"classpathref="compile-classpath"includeantruntime="true"failonerror="true"></javac><copytodir="${build.classes}"><filesetdir="${src.dir}"includes="**/*.*"excludes="**/*.java"></fileset></copy></target><targetname="compile-test"depends="compile"><javacdestdir="${build.test.classes}"srcdir="${test.src.dir}"includeantruntime="true"failonerror="true"classpathref="compile-test-classpath"></javac></target><targetname="run-test"depends="compile-test"><junitfork="true"haltonfailure="false"failureproperty="junit.fail"><classpathrefid="run-test-classpath"></classpath><formattertype="brief"usefile="false"/><formattertype="xml"/><batchtesttodir="${build.test.report}"><filesetdir="${build.test.classes}"includes="${run.test.class}"></fileset></batchtest></junit><junitreporttodir="${build.test.report}"><filesetdir="${build.test.report}"includes="TEST-*.xml"></fileset><reportformat="frames"todir="${build.test.report}/html"/></junitreport><failif="${junit.fail}"message="单元测试失败,具体情况请查询${build.test.report}"/></target><targetname="doc"depends="run-test"><javadocsourcepath="${src.dir}"use="true"packagenames="cn.*"charset="UTF-8"encoding="UTF-8"docencoding="UTF-8"destdir="${build.doc.dir}"><classpathrefid="compile-classpath"></classpath></javadoc></target><targetname="jar"depends="doc"><tstamp><formatproperty="now"pattern="yyyy=MM-ddHH:mm:ss"/></tstamp><jardestfile="${build.jar.dir}/${project.jar.name}"basedir="${build.classes}"duplicate="preserve"><manifest><attributename="Build-By"value="${user.name}"/><attributename="Build-time"value="${now}"/></manifest></jar></target><targetname="copy-src"depends="jar"><copytodir="${build.src}"><filesetdir="${src.dir}"includes="**/*.*"></fileset></copy></target><targetname="metadata"><mkdirdir="${metadata.dir}"/><buildnumber/><propertyfilefile="${metadata.dir}/build.propterties"><entrykey="Build-time"type="date"value="now"pattern="yyyy-MM-ddHH:mm:ss"/><entrykey="build-number"type="int"value="${build.number}"/></propertyfile></target><targetname="zip"depends="copy-src"><zipdestfile="${build.zip.dir}/${project.zip.name}"duplicate="preserve"><zipfilesetfile="${build.jar.dir}/${project.jar.name}"prefix="${project.prefix}"/><zipfilesetdir="${build.src}"includes="**/*.*"prefix="${project.prefix}/src"></zipfileset><zipfilesetdir="${build.doc.dir}"includes="**/*.*"prefix="${project.prefix}/doc/api"></zipfileset><zipfilesetdir="${build.test.dir}"includes="**/*.*"excludes="report/*.*"prefix="${project.prefix}/test"></zipfileset><zipfilesetdir="."includes="build.xml,build.properties"prefix="${project.prefix}"></zipfileset></zip></target><presetdefname="upload"><ftpuserid="${ftp.username}"password="${ftp.password}"server="${ftp.server}"remotedir="${ftp.dir}"></ftp></presetdef><targetname="ftp"depends="zip"><uploadaction="mkdir"/><uploadaction="put"><filesetdir="${build.zip.dir}"includes="${project.zip.name}"></fileset></upload></target></project>
build.properties
ftp.username=khftp.password=123ftp.server=localhostftp.dir=user_managerproject.version=SNAPSHOT-0.1project.prefix=usermanager-${project.version}project.jar.name=${project.prefix}.jarproject.zip.name=${project.prefix}.ziprun.test.class=**/Test*.class
2 web项目
<?xmlversion="1.0"encoding="UTF-8"?><project><propertyname="src.dir"location="src"></property><propertyname="build.dir"location="build"></property><propertyname="build.classes"location="${build.dir}/classes"></property><propertyname="build.war"location="${build.dir}/war"></property><propertyname="web.name"value="hello"></property><propertyname="web.root"value="WebContent"></property><propertyname="web.WEB-INF"location="${web.root}/WEB-INF"></property><propertyname="web.lib"location="${web.WEB-INF}/lib"></property><propertyenvironment="env"></property><pathid="compile"><filesetdir="${web.lib}"includes="*.jar"></fileset><filesetdir="${env.CATALINA_HOME}/lib"includes="*.jar"></fileset></path><targetname="init"><deletedir="${build.dir}"></delete><mkdirdir="${build.dir}"/><mkdirdir="${build.classes}"/><mkdirdir="${build.war}"/></target><targetname="compile"depends="init"><javacdestdir="${build.classes}"srcdir="${src.dir}"classpathref="compile"></javac></target><targetname="war"depends="compile"><wardestfile="${build.war}/${web.name}.war"><filesetdir="${web.root}"includes="**/*.*"></fileset><libdir="${web.lib}"></lib><webinfdir="${web.WEB-INF}"></webinf><classesdir="${build.classes}"></classes></war></target><presetdefname="sql-admin"><sqluserid="root"password="123456"url="jdbc:mysql://localhost:3306/itat_msg?useUnicode=true&characterEncoding=utf-8"driver="com.mysql.jdbc.Driver"><classpathrefid="compile"></classpath></sql></presetdef><targetname="init-mysql"><sql-admin><transaction>dropdatabaseant_test;createdatabaseant_test;GRANTALLONant_test.*TO"ant_test"@"localhost"IDENTIFIEDBY'123'</transaction></sql-admin></target><targetname="deploy"depends="war"><copytodir="${env.CATALINA_HOME}/webapps"><filesetdir="${build.war}"includes="${web.name}.war"></fileset></copy></target></project>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。