zoukankan      html  css  js  c++  java
  • ant1.9.4之编译、打包、发布、清理



       ant的官方手册  http://ant.apache.org/manual/index.html

              之前一直在有用ant  比在linux用make好用多了 当然和maven比 感觉还是差了一点  感觉好像maven和ant的侧重点稍微有点不一样 所以会有这种感觉吧  记录学习的脚步吧

    比较有用的就是通配符 * ? ** 含义如下

    '*' matches zero or more characters, '?' matches one character.
             When ** is used as the name of a directory in the pattern, it matches zero or more directories


    下面是ant的编译 打包 发布 清理常见的几个任务的一个集合 该解释的地方build.xml中 都解释了 就不多说了  直接看build.xml文件吧

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- ================================================ -->
    <!-- Sample buildfile for jar components -->
    <!-- -->
    <!-- ================================================ -->
    <project name="HelloWorld"  basedir=".">
        <!-- 定义属性 -->
        <property name="src.dir" value="${basedir}src" />
    	<!--  访问操作系统的环境变量  -->
        <property environment="env"  />
    	<!-- 设置jboss的目录 -->
        <property name="jboss.home" value="${env.JBOSS_HOME}"/>
    	<!-- 设置jboss的服务器名 -->
        <property name="jboss.server.home" value="standalone"  />
        <property name="dep" value="deployments"  />
        <property name="build.dir" value="${basedir}uild"  />
    
    	<!--构建path路径  -->
        <path id="build.classpath">
        	<fileset dir="${basedir}lib">
        		<include name="*.jar" />
        	</fileset>
        	<!--<pathelement location="${build.dir}" /> -->
        </path>
    
    	<!-- - - - - - - - - - - - - - -->
    	<!-- target: init -->
    	<!-- - - - - - - - - - - - - - -->
    	<target name="init">
    		<delete dir="${build.dir}"></delete>
    		<mkdir dir="${build.dir}"></mkdir>
    	</target>
    
    	<!-- ========================= -->
    	<!-- target: compile -->
    	<!-- ========================= -->
    	<target name="compile" depends="init"
    		description="--> compile  this component" >
             <!--  编译src目录下以com开头的所有子包中的类 
             '*' matches zero or more characters, '?' matches one character.
             When ** is used as the name of a directory in the pattern, it matches zero or more directories
             -->
    		<javac srcdir="${src.dir}" destdir="${build.dir}" includes="com/**" includeAntRuntime="false">
    			<classpath refid="build.classpath" />
    		</javac>
    	</target>
    	
    	<!-- 打包 -->
    	<target name="ejbjar" depends="compile" description="打包ejb">
    	   <jar jarfile="${basedir}${ant.project.name}.jar">
    	   	<fileset dir="${build.dir}">
    	   		<!-- 将build目录下的所有已class结尾的文件打包进去 -->
    	   		<include name="**/*.class"></include>
    	   	</fileset>
    	   	<!--将src目录下的META-INF目录下的文件打包进去 -->
    	   	<metainf dir="${src.dir}META-INF"></metainf>
    	   </jar>
    	</target>
      
        <!-- 部署 -->
        <target name="delopy" depends="ejbjar" description="部署ejb">
        	<copy file="${basedir}${ant.project.name}.jar"  todir="${jboss.home}${jboss.server.home}${dep}" />
        </target>
        
        <!-- 卸载ejb -->
        <target name="undeploy" description="卸载ejb">
          <delete file="${jboss.home}${jboss.server.home}${dep}${ant.project.name}.jar"></delete>
        </target>
        
    	<!-- 打包接口 -->
    	<target name="package_inter" depends="compile" description="打包接口">
    		<jar jarfile="${basedir}${ant.project.name}Interface.jar">
    			   	<fileset dir="${build.dir}">
    			   		<!-- 将build目录下中impl目录下的已class结尾的文件不打包进去 -->
    			   		<exclude name="**/impl/*.class"></exclude>
    			   	</fileset>
    			   </jar>
    	</target>
    	
    	<!--  删除生成的class和打包的文件 -->
    	<target name="clean" description="清除项目">
    		<delete dir="${build.dir}"></delete>
    		<delete file="${basedir}${ant.project.name}.jar"></delete>
    		<delete file="${basedir}${ant.project.name}Interface.jar"></delete>
    	</target>
    	
    
    </project>
    


      java文件就不写了 根据需要修改即可  上面的build.xml  

    至于还有不清楚的 看上面贴的那个路径 去那里面找到相关的内容 去看 就可以了


  • 相关阅读:
    最近想读的书想做的事
    syslogng 正确配置udp接受端口
    (转)iPhone重绘机制drawRect
    .Net工具整理
    用系统的网格还是用自己的网格
    将主关键字加强为适应多个
    onblur与onbeforedeactivate的区别
    模式窗口中无法转向
    实现获取客户端的MAC地址(3)
    onkeypress、onkeydown、onkeyup三事件的区别
  • 原文地址:https://www.cnblogs.com/liangxinzhi/p/4275551.html
Copyright © 2011-2022 走看看