标签:maven
一般的我创建的项目都是基于Maven的,但是很多人也喜欢用Ant打包jar,或者war.我一般都会在项目中既包含Maven的pom.xml,也会有ant的build.xml
只要在控制台执行:
1
|
mvn dependency:copy-dependencies |
1
|
ant OR ant javadoc |
打包的程序一般在:${project.path}/target/dist/${version}/
JavaDoc文档一般在${project.path}/target/ant/javadoc/
一般执行mvn dependency:copy-dependencies会把依赖的jarcopy到${project.path}/target/dependency/目录下.可以很容易的利用好Ant.
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<? xml
version = "1.0"
encoding = "UTF-8" ?> < project
name = "dsolrcloud"
default = "default"
basedir = "." > < description >Builds, tests, and runs the project dsolrcloud.</ description > < property
environment = "env" /> < property
name = "version"
value = "1.0" /> < property
name = "project"
value = "dsolrcloud" /> < property
name = "package"
value = "dsolrcloud" /> < property
name = "domain"
value = "net" /> < property
name = "author"
value = "ZhenQin" /> < property
name = "vendor"
value = "ZhenQin" /> < property
name = "src.dir"
location = "src/main/java" /> < property
name = "build.dir"
location = "target/ant/classes"
/> < property
name = "dist.dir"
location = "target/dist" /> < property
name = "config.dir"
location = "src/main/resources"
/> < property
name = "doc.dir"
location = "target/ant/javadoc" /> < property
name = "web.root"
location = "src/main/webapp"
/> < property
name = "lib.dir"
location = "target/dependency" /> < property
name = "test.dir"
location = "src/test/java" /> < path
id = "classpath" > < fileset
dir = "${lib.dir}"
includes = "**/*.jar" /> </ path > < target
name = "makedir"
description = "建立文件夹" > < mkdir
dir = "${dist.dir}" /> < mkdir
dir = "${build.dir}" /> < mkdir
dir = "${lib.dir}" /> < mkdir
dir = "${test.dir}" /> </ target > < target
name = "compile"
depends = "makedir"
description = "编译代码" > <!-- 编译所有的代码,Server and client --> < javac
srcdir = "${src.dir}" destdir = "${build.dir}" encoding = "UTF-8" includeantruntime = "no" excludes = "**/test/*,**/test/bean/*,**/*.svn,*.svn" includes = "**/*.java" source = "1.6" target = "1.6" deprecation = "true" failonerror = "true" debug = "true" > < classpath
refid = "classpath"
/> </ javac > <!-- 把所有文件copy到build目录 --> < copy
todir = "${build.dir}" > < fileset
dir = "${config.dir}"
includes = "**/*" /> </ copy > </ target > <!--生成Javadoc 文档 --> < target
name = "javadoc"
description = "生成Javadoc文档." > < delete
dir = "${doc.dir}" /> < mkdir
dir = "${doc.dir}" /> < javadoc
destdir = "${doc.dir}"
windowtitle = "${project} Javadoc"
use = "yes" linksource = "no"
splitindex = "yes"
encoding = "UTF-8" docencoding = "UTF-8"
locale = "zh_CN" > < classpath
refid = "classpath" /> < packageset
dir = "${src.dir}"
defaultexcludes = "yes" > < include
name = "${domain}/${package}/**" /> </ packageset > </ javadoc > </ target > < target
name = "package"
depends = "compile"
description = "打包成Jar"
> < mkdir
dir = "${dist.dir}/${version}"
/> < tstamp > < format
property = "TODAY"
pattern = "yyyy-MM-dd HH:mm:ss" /> < format
property = "TIME"
pattern = "yyMMddHHmm" /> </ tstamp > < manifest
file = "${web.root}/META-INF/MANIFEST.MF" > < attribute
name = "Created-By"
value = "${author}" /> < attribute
name = "Built-Date"
value = "${TODAY}" /> < attribute
name = "Implementation-Title"
value = "${project}" /> < attribute
name = "Implementation-Version"
value = "${version}" /> < attribute
name = "Implementation-Vendor"
value = "${vendor}" /> </ manifest > <!-- 打包所有的编译文件 --> < jar
jarfile = "${dist.dir}/${version}/${domain}.${package}.${project}.bin.${version}.v${TIME}.jar" basedir = "${build.dir}"
manifest = "${web.root}/META-INF/MANIFEST.MF" > </ jar > <!-- 生成Web配置及部署文件 --> < war
destfile = "${dist.dir}/${version}/${project}.v${TIME}.war" webxml = "${web.root}/WEB-INF/web.xml"
manifest = "${web.root}/META-INF/MANIFEST.MF" > < fileset
dir = "${web.root}"
excludes = "${web.root}/WEB-INF/classes/*" ></ fileset > < classes
dir = "${build.dir}"
/> < lib
dir = "${lib.dir}"
includes = "**/*.jar"
/> </ war > <!-- <jar jarfile="${dist.dir}/${version}/${domain}.${package}.${project}.client.bin.${version}.v${TIME}.jar" basedir="${client.build.dir}" manifest="${web.root}/META-INF/MANIFEST.MF"> </jar> <jar jarfile="${dist.dir}/${version}/${domain}.${project}.sources.${version}.jar" basedir="${src.dir}" manifest="${web.root}/META-INF/MANIFEST.MF"> </jar> <jar jarfile="${dist.dir}/${version}/${domain}.${project}.testsource.${version}.jar" basedir="${test.dir}" manifest="${web.root}/META-INF/MANIFEST.MF"> </jar> <jar jarfile="${dist.dir}/${version}/${domain}.${project}.javadoc.${version}.jar" basedir="${doc.dir}" manifest="${web.root}/META-INF/MANIFEST.MF"/> --> </ target > < target
name = "destory"
description = "最后的清理"
> < delete
includeemptydirs = "true" > < fileset
dir = "${build.dir}"
includes = "**/*"
/> </ delete > </ target > < target
name = "default"
depends = "package, destory" > </ target > </ project > |
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:maven
原文地址:http://blog.csdn.net/xiaole0313/article/details/47254647