一:ivy管理jar包
1)设置ivysetting.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivysettings>
<ivy:configure>
<credentials host=" service ip" realm="Sonatype Nexus Repository Manager" username="deployment" passwd="deployment123" />
</ivy:configure>
<settings defaultResolver="defaultChain" defaultConflictManager="latest-revision" />
<caches defaultCacheDir="d:/.ivy2" />
<property name="nexus-public" value="http:// service ip:7002/nexus-webapp-1.8.0.1/content/groups/public/" />
<property name="nexus-releases" value="http:// service ip:7002/nexus-webapp-1.8.0.1/content/repositories/releases/" />
<property name="nexus-snapshots" value="http:// service ip:7002/nexus-webapp-1.8.0.1/content/repositories/snapshots/" />
<resolvers>
<chain name="defaultChain" checkmodified="true" changingPattern=".*SNAPSHOT">
<ibiblio name="public" m2compatible="true" usepoms="true" root="${nexus-public}"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" />
<ibiblio name="releases" m2compatible="true" usepoms="true" root="${nexus-releases}"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" />
<ibiblio name="snapshots" m2compatible="true" usepoms="true" root="${nexus-snapshots}"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" />
</chain>
</resolvers>
</ivysettings>
2) 设置ivy.xml
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="com.XXX.XXX" module="projectName" />
<configurations>
<conf name="default" visibility="public" extends="runtime,master" />
<conf name="master" visibility="public" />
<conf name="compile" visibility="public" />
<conf name="provided" visibility="public" />
<conf name="runtime" visibility="public" extends="compile" />
<conf name="test" visibility="private" extends="runtime" />
</configurations>
<dependencies defaultconfmapping="compile->compile(*),master(*);runtime->master(*),compile(*),runtime(*)">
<!-- log4j -->
<dependency org="log4j" name="log4j" rev="1.2.17" conf="compile;runtime" />
<!-- httpclient -->
<dependency org="org.apache.httpcomponents" name="httpclient" rev="4.2.5" conf="compile;runtime" />
<dependency org="org.apache.httpcomponents" name="httpmime" rev="4.0.1" conf="compile;runtime" />
<dependency org="org.apache.httpcomponents" name="httpcore" rev="4.1.2" conf="compile;runtime" />
<dependency org="org.apache.httpcomponents" name="httpclient-cache" rev="4.1.2" conf="compile;runtime" />
<!-- others -->
<dependency org="com.google.code.gson" name="gson" rev="2.2.4" conf="compile;runtime" />
<dependency org="net.sf.ezmorph" name="ezmorph" rev="1.0.6" conf="compile;runtime" />
<dependency org="net.sf.json-lib" name="json-lib" rev="2.4" m:classifier="jdk15" conf="compile;runtime" />
<dependency org="org.aspectj" name="aspectjweaver" rev="1.6.11" conf="compile;runtime" />
<dependency org="org.apache.poi" name="poi" rev="3.9" conf="compile;runtime" />
<dependency org="net.sourceforge.jexcelapi" name="jxl" rev="2.6.3" conf="compile;runtime" />
<dependency org="net.sourceforge.jexcelapi" name="jxl" rev="2.6.3" conf="compile;runtime" />
<dependency org="javax.servlet" name="servlet-api" rev="2.5" conf="compile;runtime" />
<dependency org="org.apache.tomcat" name="jsp-api" rev="6.0.37" conf="provided->compile(*),master(*)" />
<dependency org="jdom" name="jdom" rev="1.0" conf="compile;runtime" />
<dependency org="com.oracle" name="ojdbc14" rev="10.2.0.4.0" conf="compile;runtime" />
<dependency org="commons-beanutils" name="commons-beanutils-core" rev="1.8.0" conf="compile;runtime" />
<dependency org="commons-net" name="commons-net" rev="2.0" conf="compile;runtime" />
<!-- Axiom 对象模型 -->
<dependency org="org.apache.ws.commons.axiom" name="axiom-api" rev="1.2.8" conf="compile;runtime" />
<dependency org="org.apache.ws.commons.axiom" name="axiom-impl" rev="1.2.8" conf="compile;runtime" />
<!-- axis2 -->
<dependency org="org.apache.axis2" name="axis2-adb" rev="1.5" conf="compile;runtime" />
<dependency org="org.apache.axis2" name="axis2-java2wsdl" rev="1.5" conf="compile;runtime" />
<!-- spring -->
<dependency org="org.springframework" name="spring-asm" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-aspects" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-aop" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-core" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-beans" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-context" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-context-support" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-jdbc" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-expression" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-orm" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-oxm" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-web" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-instrument" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-jms" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-test" rev="3.1.4.RELEASE" conf="compile;runtime" />
<dependency org="org.springframework" name="spring-tx" rev="3.1.4.RELEASE" conf="compile;runtime" />
<!-- hibernate -->
<dependency org="org.hibernate" name="hibernate-core" rev="3.6.4.Final" conf="compile;runtime">
<exclude module="xml-apis" />
</dependency>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.2.0.ga" conf="compile;runtime" />
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.6.4.Final" conf="compile;runtime" />
<dependency org="org.hibernate" name="hibernate-ehcache" rev="3.6.4.Final" conf="compile;runtime" />
<!--quartz -->
<dependency org="org.quartz-scheduler" name="quartz" rev="2.2.0" conf="compile;runtime" />
</dependencies>
</ivy-module>
3)具体的ant插件安装,详情见百度,主要一点是要把ivy的两个jar包copy到ant的lib中,在eclipse中配置ant路径 。具体的jar 包可在mvn 中查询 http://mvnrepository.com/search.html
4)编写build.xml ant编译文件
<?xml version="1.0" encoding="UTF-8"?>
<project name="ebg-service" default="generwar" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="src.dir" value="${basedir}" />
<property name="webRoot" value="${basedir}/webroot" />
<property name="build.lib" value="${webRoot}/WEB-INF/lib" />
<property name="build.dir" value="${basedir}/deploy" />
<property name="build.classes" value="${build.dir}/classes" />
<!--加载ivy文件-->
<ivy:settings file="ivysettings.xml" />
<target name="resolve" description="--> parse ivy.xml">
<ivy:resolve file="ivy.xml" conf="*" />
<ivy:cachepath pathid="ivy.libs.compile" type="jar,bundle" conf="compile,provided" />
<ivy:cachepath pathid="ivy.libs.test" type="jar,bundle" conf="test,provided" />
<ivy:cachepath pathid="ivy.libs.runtime" type="jar,bundle" conf="runtime" />
</target>
<target name="ivy-report" depends="resolve" description="--> resolve and retrieve dependencies with ivy">
<ivy:report />
</target>
<!--1、删除编译target目录-->
<target name="clean" description="delete directory">
<echo message="clean deploy directory" />
<delete dir="${build.dir}" />
</target>
<!--2、创建编译target目录-->
<target name="init" description="create target directory" depends="clean">
<echo message="create deploy directory" />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes}" />
</target>
<!--3、编译java源文件-->
<target name="compile" description="compile source files" depends="init,resolve">
<echo message="compile source files" />
<javac target="1.5" encoding="utf-8" debug="true" srcdir="${src.dir}" destdir="${build.classes}">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
<classpath>
<path refid="ivy.libs.compile" />
</classpath>
</javac>
</target>
<!--4、 复制资源文件 -->
<target name="copyRes" depends="compile" description="copy resources to classes path">
<echo message="copy resources to classes path" />
<copy todir="${build.classes}">
<fileset dir="src/resources">
<exclude name="build/" />
<!--排除build 文件夹-->
</fileset>
</copy>
</target>
<!-- 5.复制生产环境资源文件覆盖掉原开发资源文件-->
<target name="copyResProd" depends="copyRes" description="copy resources to classes path">
<echo message="copy resources to classes path" />
<copy todir="${build.classes}" overwrite="true">
<fileset dir="src/resources/build" />
</copy>
</target>
<!--6、打成WAR包-->
<target name="generwar" depends="copyResProd">
<echo message="generate war" />
<war destfile="${build.dir}/${ant.project.name}.war" webxml="${webRoot}/WEB-INF/web.xml">
<fileset dir="${webRoot}">
<include name="**/*.jsp" />
<include name="**/*weblogic.xml" />
</fileset>
<classes dir="${build.classes}" />
<mappedresources>
<restrict>
<path refid="ivy.libs.runtime" />
<type type="file" />
</restrict>
<chainedmapper>
<flattenmapper />
<globmapper from="*" to="WEB-INF/lib/*" />
</chainedmapper>
</mappedresources>
</war>
<echo message="clean deploy directory" />
<delete dir="${build.classes}" />
</target>
</project>
ivy的插件自行到网上获取