<?xml version="1.0" encoding="GB2312"?>
<project name="CardInfo-WebApp" default="build_all" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <property file="build.properties"/> <target name="build_all" depends="zip, war, war_patch, zip_library" description="build project and create zip file of publish.">
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" excludes="/*.zip, /*.war" />
</target> <target name="build_app" depends="zip" description="build project and create zip file of publish.">
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" excludes="/*.zip" />
</target> <target name="build_war" depends="war" description="build project and create war file of publish.">
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" excludes="/*.war" />
</target> <target name="build_war_patch" depends="war_patch" description="build project and create war file of publish.">
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" excludes="/*.war" />
</target> <target name="build_library" depends="zip_library" description="copy jar resource and create zip file.">
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" excludes="/*.zip" />
</target> <tstamp prefix="build.">
<format property="time" pattern="yyyy-MM-dd HH:mm" />
<format property="timestamp" pattern="yyyyMMddHHmm"/>
</tstamp> <target name="init_maven">
<echo message="init maven config. local repository is: ${M2_REPO}"/>
<path id="maven-ant-tasks.classpath" path="${M2_REPO}/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" /> <artifact:localRepository id="local.repository" path="${M2_REPO}"/> <artifact:pom id="maven.project" file="pom.xml" /> <artifact:dependencies pathId="classpath.build" filesetid="maven.fileset.build">
<localRepository refid="local.repository"/>
<pom refid="maven.project" />
</artifact:dependencies> <artifact:dependencies pathId="classpath.runtime" filesetid="maven.fileset.runtime" usescope="runtime">
<localRepository refid="local.repository"/>
<pom refid="maven.project"/>
</artifact:dependencies> <artifact:dependencies pathId="classpath.provided" filesetid="maven.fileset.provided" scopes="provided">
<localRepository refid="local.repository"/>
<pom refid="maven.project" />
</artifact:dependencies>
</target> <target name="init_path" depends="init_maven">
<echo>*********************************</echo>
<echo>Maven build project base directory is ${maven.project.basedir}</echo>
<echo>Maven build project source directory is ${maven.project.build.sourceDirectory}</echo> <echo>*********************************</echo>
<property name="project.application.basedir" value="${maven.project.basedir}/Application" />
<echo>Maven build project application directory is ${project.application.basedir}</echo> <property name="project.path.tools" value="${project.application.basedir}}/tools"/>
<echo>Maven build project application tools directory is ${project.path.tools}</echo> <property name="project.path.webapps" value="${project.application.basedir}/webapps"/>
<echo>Maven build project application webapps directory is ${project.path.webapps}</echo>
<property name="project.path.webapps.webinf" value="${project.path.webapps}/WEB-INF"/> <property name="project.path.conf" value="${project.path.webapps.webinf}/conf"/>
<echo>Maven build project application conf directory is ${project.path.conf}</echo> <property name="project.path.lib" value="${project.path.webapps.webinf}/lib"/>
<echo>Maven build project application jar lib directory is ${project.path.lib}</echo> <property name="project.path.log" value="${project.path.webapps.webinf}/log"/>
<echo>Maven build project application log directory is ${project.path.log}</echo> <property name="project.path.workspace" value="${project.path.webapps.webinf}/workspace"/>
<echo>Maven build project application workspace directory is ${project.path.workspace}</echo> <echo>*********************************</echo>
<property name="target.basedir" value="${maven.project.basedir}/target"/>
<mkdir dir="${target.basedir}"/>
<echo>Maven build target base directory is ${target.basedir}</echo> <property name="target.path.build" value="${target.basedir}/build"/>
<mkdir dir="${target.path.build}"/>
<echo>Maven build target build directory is ${target.path.build}</echo> <property name="target.path.classes" value="${target.path.build}/classes"/>
<mkdir dir="${target.path.classes}"/>
<echo>Maven build target classes directory is ${target.path.classes}</echo> <property name="target.path.tools" value="${target.path.build}/tools"/>
<mkdir dir="${target.path.tools}"/>
<echo>Maven build target tools directory is ${target.path.tools}</echo> <property name="target.path.webapps" value="${target.path.build}/webapps"/>
<mkdir dir="${target.path.webapps}"/>
<echo>Maven build target webapps directory is ${target.path.webapps}</echo> <property name="target.path.webapps.webinf" value="${target.path.webapps}/WEB-INF"/>
<mkdir dir="${target.path.webapps.webinf}"/> <property name="target.path.conf" value="${target.path.webapps.webinf}/conf"/>
<mkdir dir="${target.path.conf}"/>
<echo>Maven build target conf directory is ${target.path.conf}</echo> <property name="target.path.lib" value="${target.path.webapps.webinf}/lib"/>
<mkdir dir="${target.path.lib}"/>
<echo>Maven build target lib directory is ${target.path.lib}</echo> <property name="target.path.log" value="${target.path.webapps.webinf}/log"/>
<mkdir dir="${target.path.log}"/>
<echo>Maven build target log directory is ${target.path.log}</echo> <property name="target.path.webapps.classes" value="${target.path.webapps.webinf}/classes"/>
<mkdir dir="${target.path.webapps.classes}"/> <property name="target.path.webapps.template" value="${target.path.webapps.webinf}/template"/>
<mkdir dir="${target.path.webapps.template}"/>
<echo>Maven build target template directory is ${target.path.webapps.template}</echo> <property name="target.path.workspace" value="${target.path.webapps.webinf}/workspace"/>
<mkdir dir="${target.path.workspace}"/>
<echo>Maven build target workspace directory is ${target.path.workspace}</echo>
</target> <target name="init_build_var" depends="init_maven">
<property name="compile.debug" value="false" />
<property name="compile.deprecation" value="false" />
<property name="compile.optimize" value="true" />
<property name="compile.encoding" value="UTF-8" />
<property name="compile.sourceversion" value="1.6" />
<property name="compile.targetversion" value="1.6" /> <property name="build.version" value="${maven.project.version}-Build${build.timestamp}"/>
<echo>Maven build version is ${build.version}</echo> <property name="patch.version" value="${maven.project.version}-Patch${build.timestamp}"/>
<echo>Maven build version is ${build.version}</echo> <property name="build.jar.name" value="${maven.project.artifactId}.jar" />
<echo>Maven build target zip file name is ${build.zip.name}</echo> <property name="build.zip.name" value="${maven.project.artifactId}-${build.version}.zip" />
<echo>Maven build target zip file name is ${build.zip.name}</echo> <property name="build.war.name" value="${maven.project.artifactId}-${build.version}.war" />
<echo>Maven build target war file name is ${build.war.name}</echo> <property name="patch.war.name" value="${maven.project.artifactId}-${patch.version}.war" />
<echo>Maven build target patch-war file name is ${patch.war.name}</echo>
</target> <target name="compile" description="compile java source to target classes path." depends="init_path, init_build_var">
<echo>compile java source.</echo>
<echo>source version is ${compile.sourceversion}</echo>
<echo>target version is ${compile.targetversion}</echo>
<javac srcdir="${maven.project.build.sourceDirectory}" destdir="${target.path.webapps.classes}"
source="${compile.sourceversion}" target="${compile.targetversion}"
description="${compile.deprecation}" optimize="${compile.optimize}"
debug="${compile.debug}" encoding="${compile.encoding}"
>
<classpath refid="classpath.build"/>
<classpath refid="classpath.provided"/>
<classpath refid="classpath.runtime"/>
</javac>
<!-- jar destfile="${target.path.lib}/${build.jar.name}" basedir="${target.path.classes}">
<manifest>
<attribute name="Version" value="${maven.project.version}" />
<attribute name="Build-by" value="${build.timestamp}" />
</manifest>
</jar -->
</target> <target name="copy_library" description="copy jar library to target lib path" depends="init_path">
<copy todir="${target.path.lib}">
<fileset refid="maven.fileset.runtime"/>
<fileset dir="${project.path.lib}" />
<mapper type="flatten" />
</copy>
</target> <target name="copy_resource" description="copy resource file to target classes path" depends="init_path">
<copy todir="${target.path.webapps.classes}" includeemptydirs="false">
<fileset dir="${maven.project.build.sourceDirectory}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copydir dest="${target.path.webapps}" src="${project.path.webapps}" excludes="/WEB-INF/**/*"/>
<copydir dest="${target.path.webapps.webinf}" src="${project.path.webapps.webinf}">
<exclude name="/classes/**/*"/>
<exclude name="/work/**/*"/>
<exclude name="/tmp/**/*"/>
<exclude name="/temp/**/*"/>
</copydir>
<copydir dest="${target.path.build}" src="${project.application.basedir}">
<exclude name="/webapps/**/*"/>
<exclude name="/${target.path.classes}"/>
</copydir>
</target>
<target name="copy_resource_noconfig" description="copy resource file to target classes path" depends="init_path">
<copy todir="${target.path.webapps.classes}">
<fileset dir="${maven.project.build.sourceDirectory}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copydir dest="${target.path.webapps}" src="${project.path.webapps}" excludes="/WEB-INF/**/*"/>
<copydir dest="${target.path.webapps.webinf}" src="${project.path.webapps.webinf}">
<exclude name="/classes/**/*"/>
<exclude name="/work/**/*"/>
<exclude name="/tmp/**/*"/>
<exclude name="/temp/**/*"/>
<exclude name="/conf/**/*"/>
<exclude name="/log/**/*"/>
<exclude name="/workspace/**/*"/>
<exclude name="/lib/**/*"/>
</copydir>
<copydir dest="${target.path.build}" src="${project.application.basedir}">
<exclude name="/webapps/**/*"/>
<exclude name="/${target.path.classes}"/>
</copydir>
</target> <target name="clean" description="clean build directory." depends="init_path">
<echo>clean build directory : ${target.basedir}</echo>
<delete includeemptydirs="true" dir="${target.basedir}" includes="**/*" />
</target> <target name="zip" description="create published zip file" depends="init_path, init_build_var, compile, copy_library, copy_resource">
<zip destfile="${target.basedir}/${build.zip.name}">
<fileset dir="${target.path.build}"></fileset>
</zip>
</target>
<target name="zip_library" description="create published zip file" depends="init_path, init_build_var, copy_library">
<zip destfile="${target.basedir}/library.zip">
<fileset dir="${target.path.lib}"></fileset>
</zip>
</target> <target name="war" description="create published war file" depends="init_path, init_build_var, compile, copy_library, copy_resource">
<war destfile="${target.basedir}/${build.war.name}">
<fileset dir="${target.path.webapps}"></fileset>
<manifest>
<attribute name="Version" value="${maven.project.version}" />
<attribute name="Build-by" value="${build.timestamp}" />
</manifest>
</war>
</target> <target name="war_patch" description="create published war file for update" depends="init_path, init_build_var, compile, copy_resource_noconfig">
<war destfile="${target.basedir}/${patch.war.name}">
<fileset dir="${target.path.webapps}"></fileset>
<manifest>
<attribute name="Version" value="${maven.project.version}" />
<attribute name="Build-by" value="${build.timestamp}" />
</manifest>
</war>
</target>
</project>

使用Maven管理依赖JAR文件,自定义项目布局,利用ANT生成不同的发布包的更多相关文章

  1. WebMagic基础与Maven管理依赖

    2. 快速开始 WebMagic主要包含两个jar包:webmagic-core-{version}.jar和webmagic-extension-{version}.jar.在项目中添加这两个包的依 ...

  2. maven手动增加jar文件

    maven手动增加jar文件 在cmd界面输入: mvn install:install-file -Dfile=D:\com.ibm.mq.jar -DgroupId=com.ibm.mq -Dar ...

  3. Maven打包成Jar文件时依赖包的问题

    我们项目中使用到第三方的库文件,这些jar库文件并没有放到Maven中央库上,导致我们需要在项目中自己配置使用.我们的两三个开发人员对Java都是很熟,因此在使用中遇到了一些问题,表现在:在本地中引入 ...

  4. maven无法下依赖jar文件的解决方案

    问题描述: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be ...

  5. 转】[1.0.2] 详解基于maven管理-scala开发的spark项目开发环境的搭建与测试

    场景 好的,假设项目数据调研与需求分析已接近尾声,马上进入Coding阶段了,辣么在Coding之前需要干马呢?是的,“统一开发工具.开发环境的搭建与本地测试.测试环境的搭建与测试” - 本文详细记录 ...

  6. maven管理本地jar包

    maven作为包管理工具,好处不必多说.但是有些情况,比如需要引入第三方包,如快递鸟,支付宝,微信等jar包(当然有可能直接提供maven依赖),如果直接下载到本地之后,怎么整合到自己的maven工程 ...

  7. Maven 导出依赖Jar,生成source.jar,javadoc.jar

    下载最新版的Maven http://maven.apache.org/download.cgi    解压到本地文件夹 新建环境变量    MAVEN_HOME   maven解压目录 在path加 ...

  8. ssm框架整合配置,用maven配置依赖jar包

    1.创建maven project 首先在pom.xml中指定工程所依赖的jar包 <project xmlns="http://maven.apache.org/POM/4.0.0& ...

  9. maven管理本地jar包注意事项

    今天lucene中集成第三方中文分词器IKAnalyzer的时候遇到了相似的问题:lucene版本4.9.IKAnalyzer版本2012FF_hf1 直接去maven仓库下载,pom配置如下: &l ...

随机推荐

  1. PHP通过OpenSSL生成证书、密钥并且加密解密数据,以及公钥,私钥和数字签名的理解

    一.公钥加密假设一下,我找了两个数字,一个是1,一个是2.我喜欢2这个数字,就保留起来,不告诉你们(私钥),然后我告诉大家,1是我的公钥. 我有一个文件,不能让别人看,我就用1加密了.别人找到了这个文 ...

  2. Git基础教程

    Git是一个分布式的版本控制工具,本篇文章从介绍Git开始,重点在于介绍Git的基本命令和使用技巧,让你尝试使用Git的同时,体验到原来一个版 本控制工具可以对开发产生如此之多的影响,文章分为两部分, ...

  3. c#登录时保存账号密码到cookie

    登陆界面有用户名.密码输入框,一个’记住账号密码‘的复选框. 1.登录时,勾选‘记住账号密码‘复选框,则会把用户名密码保存在客户端cookie里,保存时间为最大值(直到用户清除浏览器缓存或者取消勾选’ ...

  4. - C#编程大幅提高OUTLOOK的邮件搜索能力!

    原文:[原创] - C#编程大幅提高OUTLOOK的邮件搜索能力! 使用OUTLOOK, 你有没有遇到过上图的问题? 多达18419封邮件! 太多了, 每次想找一个邮件都非常耗时, 想办法解决这个问题 ...

  5. [译]Java 设计模式之抽象工厂

    (文章翻译自Java Design Pattern: Abstract Factory) 抽象工厂模式针对工厂模式增加了抽象层.如果我们使用抽象工厂模式和工厂模式比较的话,很明显抽象工厂模式增加了一个 ...

  6. CodeSmith开发系列资料总结

    CodeSmith开发系列资料总结 最近跟同事在研究CodeSmith,感觉中文文档是少之又少,所以我们自己写(翻译)了一些文档,总结如下,希望对使用CodeSmith的朋友有所帮助: “努力学习的熊 ...

  7. Entity Framework,TransactionScope 混合使用的问题讨论

    using (var ts = new TransactionScope()) { string connStr = "Data Source=.;Initial Catalog=Test; ...

  8. dcmtk常用命令

    dump2dcm 把普通文件转换成含有dcm头的文件,参数为源文件,目标文件 例:dump2dcm q1.txt query.dcm 表示把q1.txt文件转换为query.dcm dcmdump 阅 ...

  9. ASP.Net中应用百度编辑器(UEditor)上传图片和上传附件失败-解决方案

    第一步: 第二步: 第三步: 第四步:

  10. 什么是gulp

    gulp:入门简介   本文是gulp的入门级介绍,主要内容包括什么是gulp,gulp与grunt有什么区别,gulp可以解决grunt存在的哪些问题,以及一个简单的说明例子. 什么是gulp gu ...