<?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. EasyUI的后台界面

    EasyUI的后台界面搭建及极致重构 〇.前言 要了解一个东西长什么样,至少得让我们能看到,才能提出针对性的见解.所以,为了言之有物,而不是凭空漫谈,我们先从UI说起,后台管理页面的UI我们将使用应用 ...

  2. TextArea中定位光标位置

    原文:TextArea中定位光标位置 在项目中,遇到一个场景:希望能在TextArea中输入某条记录中的明细(明细较简单,没有附属信息,只用记录顺序和值即可,譬如用"+"号来作为明 ...

  3. 学习的例子gcc+gdb+make

    1 小侃GCC 在正式使用gcc之前,我们先来侃侃gcc是啥玩意儿? 历史 如今的GCC是GNU Compiler Collection的简称.既然是Collection,就是指一些工具链的集合. 最 ...

  4. 进击的Android注入术《二》

    继续 在<一>里,我把基本思路描写叙述了一遍,接下为我们先从注入開始入手. 注入 分类 我们平时所说的代码注入,主要静态和动态两种方式 静态注入,针对是可运行文件,比方平时我们改动ELF, ...

  5. wpa_cli P2P 连接相关的调试命令

    在最近的一次客户端上的调试p2p的wifi display, 他们中的一半Android该调整了,整个前所以没有太多的研究p2p过程连接, 客户现在使用的非Android平台架构. 需要协助客户这么多 ...

  6. WCF的简单

    WCF的简单 WCF的学习之旅 一.WCF的简单介绍  Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows ...

  7. Javascript模块化编程之难处

    接着上一篇“Javascript模块化编程之Why”说起,Javascript担子重了之后程序也就复杂了.在大把语言都模块化编程的形势下,Javascript也不可能袖手旁观啊,毕竟这是一条经过实践检 ...

  8. c#中如何跨线程调用windows窗体控件

    c#中如何跨线程调用windows窗体控件?   我们在做winform应用的时候,大部分情况下都会碰到使用多线程控制界面上控件信息的问题.然而我们并不能用传统方法来做这个问题,下面我将详细的介绍.首 ...

  9. PHP gbk转换成utf8

    /** * GBK ASCII 转换成utf8 */ public function to_utf8($str){ $detect = array('ASCII', 'GBK', 'UTF-8'); ...

  10. begin 2~~~

    发觉自己是一个偏向geek的coder 其实自己没有像一个pure coder一样,lost in code world,我总喜欢做一些东西,奇怪的: 联通的多拨破解 openwrt的入门级研究 pf ...