当前位置: 代码迷 >> XML/SOAP >> 一个惯用的ant的build.xml
  详细解决方案

一个惯用的ant的build.xml

热度:526   发布时间:2013-12-28 22:19:33.0
一个常用的ant的build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="all" name="backup">
	<!--this file was created by Eclipse Runnable JAR Export Wizard-->

	<property name="project-name" value="backup" />
	<property name="company-name" value="wanmei" />
	<property name="project-jar-name" value="${project-name}.jar" />
	<property name="project-path" value="E:/workspace_java/backup" />
	<property name="project-destination-path" value="E:/workspace_java/backup/jar" />
	<property name="backup-dir" value="F:/program_backup/backup" />
	<property name="remote-project-path1" value="oracle:oracle@192.168.123.55:/usr/local/backup_program/temp" />


	<tstamp>
		<format property="TODAY" pattern="yyyy-MM-dd" />
		<format property="now-year" pattern="yyyy" />
		<format property="now-time" pattern="yyyy_MM_dd_HH_mm_ss" />
	</tstamp>
	<record name="${project-path}/logs/build_log.txt" loglevel="debug" append="true" action="start" />

	<!-- USB disk: I:/ -->
	<property name="U_DISK_HOME" value="I:/" />
	<available file="${U_DISK_HOME}" property="U_DISK.exist" />
	<echo message="USB disk exist: ${U_DISK.exist}" />

	<!--ANT 1.7 is required                                        -->
	<target name="create_run_jar" depends="javadoc">
		<jar destfile="${project-destination-path}/${project-jar-name}">
			<manifest>
				<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader" />
				<attribute name="Rsrc-Main-Class" value="com.wanmei.backup.action.Bootstrap" />
				<attribute name="Class-Path" value="." />
				<attribute name="Rsrc-Class-Path" value="./ activation.jar antlr-2.7.6.jar aopalliance-1.0.jar aspectjrt.jar aspectjweaver.jar commons-beanutils-1.8.3.jar commons-beanutils-bean-collections-1.8.3.jar commons-beanutils-core-1.8.3.jar commons-codec-1.7.jar commons-collections-3.2.1.jar commons-dbcp-1.4.jar commons-io-2.4.jar commons-lang3-3.1.jar commons-logging-1.1.2.jar commons-net-3.2.jar commons-pool-1.6.jar gson-2.2.3.jar hornetq-core-client.jar hornetq-jms-client.jar jakarta-oro-2.0.8.jar jaxen-full.jar jboss-jms-api.jar jdom.jar jta.jar junique-1.0.4.jar junit-4.11.jar mail.jar netty.jar ojdbc6.jar quartz-all-1.8.6.jar spring-aop-3.2.1.RELEASE.jar spring-aspects-3.2.1.RELEASE.jar spring-beans-3.2.1.RELEASE.jar spring-context-3.2.1.RELEASE.jar spring-context-support-3.2.1.RELEASE.jar spring-core-3.2.1.RELEASE.jar spring-expression-3.2.1.RELEASE.jar spring-instrument-3.2.1.RELEASE.jar spring-jdbc-3.2.1.RELEASE.jar spring-jms-3.2.1.RELEASE.jar spring-oxm-3.2.1.RELEASE.jar spring-tx-3.2.1.RELEASE.jar log4j-1.2.14.jar slf4j-api-1.6.0.jar slf4j-log4j12-1.6.0.jar" />
			</manifest>
			<zipfileset src="jar-in-jar-loader.zip" />
			<fileset dir="${project-path}/bin" />
			<zipfileset dir="${project-path}/lib" includes="*.jar" />
		</jar>
	</target>

	<!-- Generate the API HTML pages -->
	<target name="javadoc" description="Generate the Javadoc HTML pages.">
		<delete dir="${project-path}/javadoc" />
		<mkdir dir="${project-path}/javadoc" />
		<javadoc destdir="${project-path}/javadoc" windowtitle="${project-name} Project Class Library" use="yes" version="true" linksource="yes" splitindex="yes" charset="UTF-8" encoding="UTF-8" docencoding="UTF-8">
			<classpath>
				<fileset dir="${project-path}/lib">
					<include name="*.jar" />
				</fileset>
			</classpath>
			<packageset dir="${project-path}/src" defaultexcludes="yes">
				<include name="com/**" />
			</packageset>
			<doctitle>
				<![CDATA[<h1>${project-name} Project Class Library</h1>]]>
			</doctitle>
		<bottom>
			<![CDATA[<i>@Copyright ${company-name}.com [2004-${now-year}]</i>
		<br/>
		<i>@Author: <span style="color:red;">薛鹏</span>
			<br/>@Date:	${TODAY}</i>]]>
			</bottom>
</javadoc>
</target>

<!-- - - - - - - - - - - - - - - - - - 
          target: backupSource                      
         - - - - - - - - - - - - - - - - - -->
<target name="backupSource">
<mkdir dir="${backup-dir}/${now-time}" />
<copy todir="${backup-dir}/${now-time}" includeemptydirs="false">
	<fileset dir="${project-path}">
		<!-- <include name="src/*" /> -->
		<exclude name="**/*.class" />
		<exclude name="lib/*.jar" />
		<exclude name="bin/config/*" />
		<exclude name="**/*.log" />
		<exclude name=".settings/*" />
		<exclude name=".classpath" />
		<exclude name=".project" />
		<exclude name=".springBeans" />
	</fileset>
</copy>
</target>



<target name="copyConfigureFile">
<delete dir="${project-destination-path}/config" />
<mkdir dir="${project-destination-path}/config" />
<copy includeemptydirs="false" todir="${project-destination-path}/config">
	<fileset dir="${project-path}/src/config">
		<include name="**/*" />
	</fileset>
</copy>
</target>


<target name="scp" depends="create_run_jar,copyConfigureFile">
<scp todir="${remote-project-path1}" trust="true" verbose="true">
	<fileset dir="${project-destination-path}">
		<include name="**/*" />
	</fileset>
</scp>
</target>
<!-- ================================= 
          target: all              
         ================================= -->
<target name="all" depends="javadoc,create_run_jar,copyConfigureFile,scp,backupSource" description="all task" />

</project>

?

  相关解决方案