当前位置: 代码迷 >> Web前端 >> Ant自动封装配置
  详细解决方案

Ant自动封装配置

热度:137   发布时间:2013-03-25 15:43:04.0
Ant自动打包配置
<?xml version="1.0" encoding="UTF-8"?>
<project name="my_ebo" basedir="." default="package-jar">
<property name="my_ebw.name" value="my_ebw" />

<property name="src.dir" value="src/main/java" />
<property name="lib.dir" value="lib" />
<property name="classes.dir" value="bin" />

<property name="my_ebw.webapp.lib.dir" value="../${my_ebw.name}/WebRoot/WEB-INF/lib" />

<property name="build.dir" value="build" />
<property name="dist.dir" value="dist" />

<!-- DEFINE PROJECT CLASSPATH -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${classes.dir}" />
</path>

<target name="prepare">
<echo message="makes sure the needed directory structure is in place..." />

<echo message="delete build folder"/>
<delete dir="${build.dir}" />

<echo message="create build and dist folder"/>
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
</target>

<!-- Compile java src -->
<target name="compile" depends="prepare"
description="Compile main source tree java files into class files">

<echo message="compile java src..."/>
<javac destdir="${build.dir}" fork="true" source="1.5" target="1.5" encoding="utf-8"
debug="false" deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="project.classpath"/>
</javac>
</target>

<!-- Package jar file -->
<target name="package-jar" description="Generate jar files" depends="compile">
<echo>copy orm files...</echo>
<copy todir="${build.dir}" overwrite="true" includeemptydirs="false">
<fileset dir="${src.dir}">
<include name="**/*"/>
</fileset>
</copy>
<echo>pack to jar file...</echo>
<jar jarfile="${dist.dir}/${name}.jar" compress="true">
<fileset dir="${build.dir}">
<include name="**/*"/>
</fileset>
</jar>

<echo>copy my_ebo.jar to my_ebw/WebRoot/WEB-INF/lib...</echo>
<copy todir="${my_ebw.webapp.lib.dir}" overwrite="true" includeemptydirs="false">
<fileset dir="${dist.dir}">
<include name="my_ebo.jar" />
</fileset>
</copy>

<delete dir="${build.dir}" />
</target>

</project>
1 楼 liuweiping 前天  
复制粘贴的吧?
2 楼 quanwsx 前天  
liuweiping 写道
复制粘贴的吧?

应该是
3 楼 huttoncs 昨天  
liuweiping 写道
复制粘贴的吧?
从网上看到后,应用到自己的项目中确实可行,就分享一下
  相关解决方案