1、  在进行打包工具的制作前,需要准备的软件有:

svnant-1.3.1

作用是让ant和svn相关联

apache-ant-1.9.7

需要设置ant_home,path,我的配置是:

ANT_HOME = D:\kaipu\cms4all\app-tpl-pack\apache-ant-1.9.7

Path = %ANT_HOME%\bin

2、准备好上面的操作之后,找个英文的目录,比如:D:\kaipu\cms4all\app-tpl-pack,在目录下创建两个文件build.xml和build.properties,并把上面的svnant-1.3.1和apache-ant-1.9.7同样放到相同目录下,最后的目录如下:

3、编写build.xml文件

<?xml version="1.0" encoding="UTF-8"?>

<!--default="dist"表示当只执行ant的时候,默认执行下面的dist命令-->

<project name="tpl-release" basedir="." default="dist">

<!--表示build.xml中引入的变量是从build.properties中获得的-->

<property file="build.properties" />

<tstamp>

<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" locale="zh" />

</tstamp>

<tstamp>

<format property="date" pattern="yyyyMMdd" locale="zh" />

</tstamp>

<!--ant要和svn相关联,需要配置一个svnant,下面表示相关的内容依赖svnant-->

<path id="svn.classpath">

<fileset dir="${svnant.dir}/lib">

<include name="**/*.jar" />

</fileset>

</path>

<path id="depends.classpath">

<fileset dir="${java.depends.lib.dir}">

<include name="**/*.jar" />

</fileset>

</path>

<!--引用 svnantlib.xml ,其中定义了ANT的SVN命令,见下方详解。-->

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svn.classpath" />

<!--<taskdef name="yui-compressor" classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask" classpathref="depends.classpath"></taskdef>-->

<!--通过ant clean命令能够清除dir.source、dir.compile和dir.release这些文件夹-->

<target name="clean">

<echo message="delete all dirs ..." />

<delete dir="${dir.source}" />

<delete dir="${dir.compile}" />

<delete dir="${dir.release}" />

</target>

<!--定义svnSetting ,新的设置SVN属性方式-->

<!-- 通过JAVAHL模式(即设置为TRUE),而不是SVNKIT模式 -->

<svnSetting id="svn.settings" svnkit="true" javahl="false" username="${svn.user}" password="${svn.pass}" />

<svnSetting id="svn.settings.1" svnkit="true" javahl="false" username="${svn.user}" password="${svn.pass}" failonerror="false" />

<!-- 导出源代码,导出的过程中是从svn上checkout下来的,执行的命令是:ant export-source-->

<target name="export-source">

<echo message="export source" />

<mkdir dir="${dir.source}" />

<svn refid="svn.settings">

<export srcUrl="${trunk.url}/${proj.app-tpl-api}" destPath="${dir.source}/${proj.app-tpl-api}" revision="HEAD" />

<export srcUrl="${trunk.url}/${proj.app-tpl-impl}" destPath="${dir.source}/${proj.app-tpl-impl}" revision="HEAD"/>

<export srcUrl="${trunk.url}/${proj.app-tpl-webapp}" destPath="${dir.source}/${proj.app-tpl-webapp}" revision="HEAD"/>

</svn>

</target>

<!--从tag版本创建tag,在svn上打上标记-->

<target name="create-tag-from-trunk">

<svn refid="svn.settings.1">

<delete url="${tags.url}/${tag.version.label}" message="tags duplicate!" />

</svn>

<echo message="create tags ${tag.version.label}" />

<svn refid="svn.settings">

<mkdir url="${tags.url}/${tag.version.label}" message="Tag created by tuzq on ${TODAY}" />

<copy srcUrl="${trunk.url}/${proj.app-tpl-api}" destUrl="${tags.url}/${tag.version.label}" message="Tag created by toto on ${TODAY}" />

<copy srcUrl="${trunk.url}/${proj.app-tpl-impl}" destUrl="${tags.url}/${tag.version.label}" message="Tag created by toto on ${TODAY}" />

<copy srcUrl="${trunk.url}/${proj.app-tpl-webapp}" destUrl="${tags.url}/${tag.version.label}" message="Tag created by toto on ${TODAY}" />

</svn>

</target>

<!--编译api代码-->

<target name="compile-app-tpl-api">

<echo message="compile app-tpl-api project" />

<!--javac,编译,对应java中的javac命令,其中srcdir定义源文件路径  destdir定义编译文件路径

includeantruntime作用是指定编译任务是否包含ant的classpath,可有可无,不影响编译,但不写可能会出现警告,为了眼不见心不烦,加上吧

-->

<delete dir="${dir.compile}/${proj.app-tpl-api}"/>

<mkdir dir="${dir.compile}/${proj.app-tpl-api}"/>

<javac srcdir="${dir.source}/${proj.app-tpl-api}${java.source.path}" destdir="${dir.compile}/${proj.app-tpl-api}" debug="${option.compile.debug}" optimize="${option.compile.optimize}" deprecation="${option.compile.deprecation}" encoding="${option.compile.encoding}" target="${option.compile.target}" verbose="${option.compile.verbose}" includeantruntime="false">

<classpath>

<!--依赖的lib包下的jar文件-->

<fileset dir="${java.depends.lib.dir}">

<include name="**/*.jar" />

</fileset>

<!--依赖的tomcat中的jar文件-->

<fileset dir="${tomcat.lib.dir}">

<include name="**/*.jar" />

</fileset>

</classpath>

</javac>

</target>

<!--通过ant命令进行打包,打成的包是:app-tpl-api-1.0-SNAPSHOT.jar-->

<target name="app-tpl-api-jar" description="make jar file">

<delete dir="${dir.compile}/${proj.app-tpl-api}/${tpl.jar.app-tpl-api}"/>

<property name="app-tpl-api-jar-filename" value="${dir.compile}/${proj.app-tpl-api}/${tpl.jar.app-tpl-api}" />

<jar jarfile="${app-tpl-api-jar-filename}" basedir="${dir.compile}/${proj.app-tpl-api}">

<!--为jar包指定manifest,如果jar包不需要打成runnable的形式,manifest可以不要-->

</jar>

</target>

<!--编译app-tpl-impl.jar文件-->

<target name="compile-app-tpl-impl">

<echo message="compile app-tpl-api project" />

<!--javac,编译,对应java中的javac命令,其中srcdir定义源文件路径  destdir定义编译文件路径

includeantruntime作用是指定编译任务是否包含ant的classpath,可有可无,不影响编译,但不写可能会出现警告,为了眼不见心不烦,加上吧

-->

<delete dir="${dir.compile}/${proj.app-tpl-impl}"/>

<copy file="${dir.compile}/${proj.app-tpl-api}/${tpl.jar.app-tpl-api}" todir="${java.depends.lib.dir}"/>

<mkdir dir="${dir.compile}/${proj.app-tpl-impl}"/>

<copydir dest="${dir.compile}/${proj.app-tpl-impl}" src="${dir.source}/${proj.app-tpl-impl}${proj.app-tpl-impl-mapper}">

<include name="sqlmaps/**" />

</copydir>

<javac srcdir="${dir.source}/${proj.app-tpl-impl}${java.source.path}" destdir="${dir.compile}/${proj.app-tpl-impl}" debug="${option.compile.debug}" optimize="${option.compile.optimize}" deprecation="${option.compile.deprecation}" encoding="${option.compile.encoding}" target="${option.compile.target}" verbose="${option.compile.verbose}" includeantruntime="false">

<classpath>

<fileset dir="${java.depends.lib.dir}">

<include name="**/*.jar" />

</fileset>

<fileset dir="${tomcat.lib.dir}">

<include name="**/*.jar" />

</fileset>

</classpath>

</javac>

</target>

<!--打包命令,打成的包是:app-tpl-impl-1.0-SNAPSHOT.jar-->

<target name="app-tpl-impl-jar" description="make jar file">

<delete dir="${dir.compile}/${proj.app-tpl-impl}/${tpl.jar.app-tpl-impl}"/>

<property name="app-tpl-impl-jar-filename" value="${dir.compile}/${proj.app-tpl-impl}/${tpl.jar.app-tpl-impl}" />

<jar jarfile="${app-tpl-impl-jar-filename}" basedir="${dir.compile}/${proj.app-tpl-impl}">

<!--为jar包指定manifest,如果jar包不需要打成runnable的形式,manifest可以不要-->

</jar>

</target>

<!-- 需要参数proj.name,主要是编译web工程 -->

<target name="compile-app-tpl-webapp">

<echo message="compile web project ${tpl.war.app-tpl-webapp}" />

<property name="targetpath" value="${dir.compile}/${proj.app-tpl-webapp}" />

<property name="sourcepath" value="${dir.source}/${proj.app-tpl-webapp}" />

<!-- 编译swf web工程 -->

<mkdir dir="${targetpath}" />

<mkdir dir="${targetpath}WEB-INF/classes" />

<copy file="${dir.compile}/${proj.app-tpl-impl}/${tpl.jar.app-tpl-impl}" todir="${java.depends.lib.dir}"/>

<copy todir="${targetpath}" overwrite="true" preservelastmodified="true">

<fileset dir="${sourcepath}${web.source.path}" />

</copy>

<javac srcdir="${sourcepath}${java.source.path}" destdir="${targetpath}WEB-INF/classes"

debug="${option.compile.debug}" optimize="${option.compile.optimize}" deprecation="${option.compile.deprecation}"

encoding="${option.compile.encoding}"

target="${option.compile.target}" verbose="${option.compile.verbose}" includeantruntime="false">

<classpath>

<fileset dir="${java.depends.lib.dir}">

<include name="**/*.jar" />

</fileset>

<fileset dir="${tomcat.lib.dir}">

<include name="**/*.jar" />

</fileset>

</classpath>

</javac>

<copy todir="${targetpath}WEB-INF/classes" overwrite="true" preservelastmodified="true">

<fileset dir="${sourcepath}${config.source.path}" />

</copy>

<copy todir="${targetpath}WEB-INF/lib" overwrite="true" preservelastmodified="true">

<fileset dir="${java.depends.lib.dir}" />

</copy>

</target>

<!-- 需要war的名称 war.name -->

<target name="war.app-tpl-webapp">

<delete dir="${dir.compile}/${tpl.war.app-tpl-webapp}"/>

<war warfile="${dir.compile}/${tpl.war.app-tpl-webapp}" webxml="${dir.compile}/${proj.app-tpl-webapp}/WEB-INF/web.xml">

<fileset dir="${dir.compile}/${proj.app-tpl-webapp}"/>

</war>

</target>

<!-- 发布相关工程及依赖工具包,通过ant dist命令,可以一次性执行清除、checkout源码、打tag、编译、打jar、打war包等操作 -->

<target name="dist" depends="clean,export-source,create-tag-from-trunk,compile-app-tpl-api,app-tpl-api-jar,compile-app-tpl-impl,app-tpl-impl-jar,compile-app-tpl-webapp,war.app-tpl-webapp">

<!--<target name="dist" depends="compile-app-tpl-api,app-tpl-api-jar,compile-app-tpl-impl,app-tpl-impl-jar,compile-app-tpl-webapp,war.app-tpl-webapp">-->

<!-- <target name="dist" depends="create-tag-from-trunk">-->

<!-- target name="dist" -->

<!-- 编译 -->

<!-- compile-web-proj proj.swf,proj.jod,proj.imagemagick-->

</target>

<!--将需要relase的东西copy到dist目录下-->

<target name="copy-to-dist">

<mkdir dir="${dir.release}/${app-tpl.name}" />

<copy todir="${dir.release}/${app-tpl.name}" overwrite="true" preservelastmodified="true" includeEmptyDirs="false">

<!-- copy war文件  -->

<fileset file="${dir.compile}/${tpl.war.app-tpl-webapp}" />

</copy>

</target>

<!--将所有的dist里面的东西放到svn上的release包中-->

<target name="commit-release">

<!-- 提交到release库中 -->

<echo message="commit to release repository."/>

<svn refid="svn.settings.1">

<delete url="${release.url}/${tag.version.label}" message="Release duplicate!"/>

</svn>

<svn refid="svn.settings">

<mkdir url="${release.url}${tag.version.label}" message="Release created by tuzq on ${TODAY}" />

<import url="${release.url}${tag.version.label}" path="${dir.release}" message="Release created by tuzq on ${TODAY}" />

</svn>

</target>

</project>

4、编写build.properties文件

#svn的相关属性

svn.user=这里填写svn的用户名

svn.pass=这里填写svn的用户名和密码

svnant.dir=D:/kaipu/cms4all/app-tpl-pack/svnant-1.3.1

#打tag时的版本信息

tag.version.label=app-tpl-v1.0.0

branch.version.label=app-tpl-v1.0.0

java.depends.lib.dir=./lib

#java.compile.lib.dir=D:/app/alfresco/tomcat-7.0.32/webapps/alfresco/WEB-INF/lib

tomcat.lib.dir=./tomcatlib

#svn服务器上的相关代码位置

trunk.url=这里放svn上trunk版本的url地址

tags.url=这里放svn上tag版本的url地址

branches.url=这里放branches版本的url地址

release.url=这里放置release版本的url地址

#相关工程的信息

proj.app-tpl-api=app-tpl-api/

proj.app-tpl-impl=app-tpl-impl/

proj.app-tpl-impl-mapper=src/main/resources

proj.app-tpl-webapp=app-tpl-webapp/

tpl.jar.app-tpl-api=app-tpl-api-1.0-SNAPSHOT.jar

tpl.jar.app-tpl-impl=app-tpl-impl-1.0-SNAPSHOT.jar

tpl.war.app-tpl-webapp=app-tpl-webapp.war

#本地编译及发布的目录结构

dir.source=./source

java.source.path=src/main/java

web.source.path=src/main/webapp

config.source.path=src/main/resources

#java的编译选项

option.compile.encoding=utf-8

option.compile.deprecation=on

#将这个打开的时候,才认SpringMVC中的注解

option.compile.debug=true

option.compile.optimize=on

option.compile.target=1.7

#通过下面的方式实现打印信息

option.compile.verbose=true

dir.compile=./build

#目录结构

#---------------------------------------------------------------

dir.release=./dist

app-tpl.name=app-tpl

产品打包工具的制作,ant,编译源码,打jar包,打tag,打war包,备份release版本等的更多相关文章

  1. win10下通过编译源码方式在chrome中成功安装react-devtools开发工具插件

    win10下通过编译源码方式在chrome中成功安装react-devtools开发工具插件   1.去git上下载react-devtools文件到本地,https://github.com/fac ...

  2. 【流媒体开发】VLC Media Player - Android 平台源码编译 与 二次开发详解 (提供详细800M下载好的编译源码及eclipse可调试播放器源码下载)

    作者 : 韩曙亮  博客地址 : http://blog.csdn.net/shulianghan/article/details/42707293 转载请注明出处 : http://blog.csd ...

  3. Hadoop编译源码

    Hadoop编译源码 克隆一个虚拟机 然后一步一步安装就行 安装所需:链接: https://pan.baidu.com/s/1jIZlQmi 密码: gggv 5.1 前期准备工作 1)CentOS ...

  4. LINUX下编译源码时所需提前安装的常用依赖包列表

    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-deve ...

  5. 转】MyEclipse使用总结——使用MyEclipse打包带源码的jar包

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4136303.html 感谢! 平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不 ...

  6. MyEclipse使用总结——使用MyEclipse打包带源码的jar包

    平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...

  7. CentOS 编译源码安装MySQL-5.6.16

    mysql5.6.16的安装和之前的5.5.5.1有些不同,编译的时候不再使用./configure来进行了,使用了cmake命令来进行编译项目. 1.准备编译环境 yum -y installmak ...

  8. MyEclipse打包带源码的jar包

    平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...

  9. Eclipse使用总结——使用Eclipse打包带源码的jar包

    平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...

随机推荐

  1. svg和css实现波浪动效

    效果: 截图有点模糊~ 实现: <svg教程> //html <body> <svg class="wave-container" xmlns=&qu ...

  2. 吴恩达深度学习第2课第2周编程作业 的坑(Optimization Methods)

    我python2.7, 做吴恩达深度学习第2课第2周编程作业 Optimization Methods 时有2个坑: 第一坑 需将辅助文件 opt_utils.py 的 nitialize_param ...

  3. TP中的AJAX返回ajaxReturn()

    系统支持任何的AJAX类库,Action类提供了ajaxReturn方法用于AJAX调用后返回数据给客户端.并且支持JSON.XML和EVAL三种方式给客户端接受数据,通过配置DEFAULT_AJAX ...

  4. Radio Station

    B. Radio Station time limit per test:  2 seconds memory limit per test:  256 megabytes input: standa ...

  5. Android Multimedia框架总结(二十)MediaCodec状态周期及Codec与输入/输出Buffer过程(附实例)

    转载请把头部出处链接和尾部二维码一起转载,本文出自逆流的鱼yuiop:http://blog.csdn.net/hejjunlin/article/details/53183718 前言:前面几节都是 ...

  6. [Flask]学习杂记一 Hello程序

    这几天买了本  <Flask Web开发:基于Python的Web应用开发实战>,之前也用过flask 但是不怎么系统,有时候需要搭建一些临时的测试服务,用falsk比较方面,一个文件就可 ...

  7. Java之继承深刻理解

    1.关于私有成员变量 无论父类中的成员变量是私有的.共有的.还是其它类型的,子类都会拥有父类中的这些成员变量.但是父类中的私有成员变量,无法在子类中直接访问,必须通过从父类中继承得到的protecte ...

  8. Java基本语法-----java数据类型的转换

    前言 Java中可以进行不同数据类型的加减乘除运算吗?是可以的.在算术运算符中已经体验过如果两个整数(int)相除会去掉小数部分.如果需要保留小数部分,可以让除数或者被除数变为double类型的(5变 ...

  9. Android实现系统下拉栏的消息提示——Notification

    Android实现系统下拉栏的消息提示--Notification 系统默认样式 默认通知(通用) 效果图 按钮 <Button android:layout_width="match ...

  10. Android中FrameAnimation动画的使用

    Frame Animation 表示帧动画,是顺序播放事先做好的图像,跟电影类似,Android SDK提供了另外一个类AnimationDrawable来定义使用Frame Animation. 下 ...