产品打包工具的制作,ant,编译源码,打jar包,打tag,打war包,备份release版本等
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版本等的更多相关文章
- win10下通过编译源码方式在chrome中成功安装react-devtools开发工具插件
win10下通过编译源码方式在chrome中成功安装react-devtools开发工具插件 1.去git上下载react-devtools文件到本地,https://github.com/fac ...
- 【流媒体开发】VLC Media Player - Android 平台源码编译 与 二次开发详解 (提供详细800M下载好的编译源码及eclipse可调试播放器源码下载)
作者 : 韩曙亮 博客地址 : http://blog.csdn.net/shulianghan/article/details/42707293 转载请注明出处 : http://blog.csd ...
- Hadoop编译源码
Hadoop编译源码 克隆一个虚拟机 然后一步一步安装就行 安装所需:链接: https://pan.baidu.com/s/1jIZlQmi 密码: gggv 5.1 前期准备工作 1)CentOS ...
- LINUX下编译源码时所需提前安装的常用依赖包列表
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-deve ...
- 转】MyEclipse使用总结——使用MyEclipse打包带源码的jar包
原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4136303.html 感谢! 平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不 ...
- MyEclipse使用总结——使用MyEclipse打包带源码的jar包
平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...
- CentOS 编译源码安装MySQL-5.6.16
mysql5.6.16的安装和之前的5.5.5.1有些不同,编译的时候不再使用./configure来进行了,使用了cmake命令来进行编译项目. 1.准备编译环境 yum -y installmak ...
- MyEclipse打包带源码的jar包
平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...
- Eclipse使用总结——使用Eclipse打包带源码的jar包
平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...
随机推荐
- 读书笔记-《Maven实战》-2018/4/18
第五章:坐标和依赖 1.每个依赖中可以包含的元素有: groupId,artifactId,version: 这三个元素是Maven项目最重要的元素.Maven需要根据这三个坐标找到需要的依赖. ty ...
- javascrpt_数组学习
1.构造函数 var arr = new Array(); Array 构造函数有一个很大的缺陷,就是不同的参数,会导致行为不一致. 因此,不建议使用它生成新数组,直接使用字面量是最好的做法. 2.静 ...
- Django笔记--模型
ORM是"对象-关系-映射"的简称,在Django当中,ORM就是模型类的管理器对象.操作顺序是先定义模型类,再定义模型类管理器,然后在模型类中实例化一个模型类管理器的对象,作为模 ...
- ACM 人见人爱A^B
求A^B的最后三位数表示的整数. 说明:A^B的含义是"A的B次方" Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10 ...
- leetcode之Find All Numbers Disappeared in an Array
问题来源:Find All Numbers Disappeared in an Array 很久没有刷题了,感觉大脑开始迟钝,所以决定重拾刷题的乐趣.一开始不要太难,选一些通过率高的题目做,然后就看到 ...
- flowable设计器插件安装
原文地址:http://www.shareniu.com/ 工欲善其事必先利其器,要想使用flowable,必须搭建一套环境,本文以Eclipse中安装flowable插件为例详细说明整个安装过程. ...
- CDH 5.x 集群安装及卸载
上次写了CDH安装测试总结,由于那个博客篇幅略长, 但是主要集中在第二章,所以单独把CDH安装.卸载这块的内容拉出来在一篇记录一下. 一.搭建远程yum源 1.启动http服务: service ht ...
- Oracle常用语句语法汇总
第一篇 基本操作 --解锁用户 alter user 用户 account unlock; --锁定用户 alter user 用户 account lock; alter user sco ...
- iOS 动态 Framework 对App启动时间影响实测
最近看到的Slow App Startup Times里提到: The dynamic loader finds and reads the dependent dynamic libraries ( ...
- ROS机器人程序设计(原书第2版)补充资料 (陆) 第六章 点云 PCL
ROS机器人程序设计(原书第2版)补充资料 (陆) 第六章 点云 PCL 书中,大部分出现hydro的地方,直接替换为indigo或jade或kinetic,即可在对应版本中使用. RGBD深度摄像头 ...