erp
|-src
|- 一些java文件
|-build
|-build.xml
就是把src打包成一个jar文件
下面还有个webRoot 打包成个war文件
主要问问 怎么把src打包成一个jar文件
3 个解决方案
#1
比较长,还是看看把:
比较长,还是看看把:
用Ant打war包Build.xml全攻略
<project basedir="." default="usage" name="myceaas">
<target name="init">
<property name="Name" value="myceaas" />
<property name="name" value="myceaas" />
<property name="version" value="0.2" />
<property name="year" value="2006" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/myceaas/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/myceaas" />
<property name="packages" value="com.ce.myceaas.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- resin-home路径 -->
<property name="resin.home" value="C:\resin-pro-3.0.17"/>
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="C:\tomcat5.5.12"/>
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
<!-- classpath -->
<path id="classpath">
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}" >
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="myceaas.war" depends="build">
<war warfile="${war.dest}/myceaas.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
<lib dir="${buildwar.dest}/WEB-INF/lib"/>
<classes dir = "${buildwar.dest}/WEB-INF/classes"/>
<fileset dir="${buildwar.dest}">
</fileset>
</war>
</target>
比较长,还是看看把:
用Ant打war包Build.xml全攻略
<project basedir="." default="usage" name="myceaas">
<target name="init">
<property name="Name" value="myceaas" />
<property name="name" value="myceaas" />
<property name="version" value="0.2" />
<property name="year" value="2006" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/myceaas/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/myceaas" />
<property name="packages" value="com.ce.myceaas.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- resin-home路径 -->
<property name="resin.home" value="C:\resin-pro-3.0.17"/>
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="C:\tomcat5.5.12"/>
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
<!-- classpath -->
<path id="classpath">
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}" >
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="myceaas.war" depends="build">
<war warfile="${war.dest}/myceaas.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
<lib dir="${buildwar.dest}/WEB-INF/lib"/>
<classes dir = "${buildwar.dest}/WEB-INF/classes"/>
<fileset dir="${buildwar.dest}">
</fileset>
</war>
</target>
#2
楼上的是对的
#3
#1
比较长,还是看看把:
比较长,还是看看把:
用Ant打war包Build.xml全攻略
<project basedir="." default="usage" name="myceaas">
<target name="init">
<property name="Name" value="myceaas" />
<property name="name" value="myceaas" />
<property name="version" value="0.2" />
<property name="year" value="2006" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/myceaas/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/myceaas" />
<property name="packages" value="com.ce.myceaas.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- resin-home路径 -->
<property name="resin.home" value="C:\resin-pro-3.0.17"/>
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="C:\tomcat5.5.12"/>
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
<!-- classpath -->
<path id="classpath">
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}" >
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="myceaas.war" depends="build">
<war warfile="${war.dest}/myceaas.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
<lib dir="${buildwar.dest}/WEB-INF/lib"/>
<classes dir = "${buildwar.dest}/WEB-INF/classes"/>
<fileset dir="${buildwar.dest}">
</fileset>
</war>
</target>
比较长,还是看看把:
用Ant打war包Build.xml全攻略
<project basedir="." default="usage" name="myceaas">
<target name="init">
<property name="Name" value="myceaas" />
<property name="name" value="myceaas" />
<property name="version" value="0.2" />
<property name="year" value="2006" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/myceaas/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/myceaas" />
<property name="packages" value="com.ce.myceaas.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- resin-home路径 -->
<property name="resin.home" value="C:\resin-pro-3.0.17"/>
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="C:\tomcat5.5.12"/>
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
<!-- classpath -->
<path id="classpath">
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}" >
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="myceaas.war" depends="build">
<war warfile="${war.dest}/myceaas.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
<lib dir="${buildwar.dest}/WEB-INF/lib"/>
<classes dir = "${buildwar.dest}/WEB-INF/classes"/>
<fileset dir="${buildwar.dest}">
</fileset>
</war>
</target>
#2
楼上的是对的