Id>
<version>1.2.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
其中commons-codec,log4j是需要打包到lib中的,运行时需要。testng(或者更一般的junit)是用来单元测试的,不需要打包到lib中。请注意它的设置"<scope>test</scope>"。
2. 然后看看build.properties文件,这个内容不多:
M2_REPO=G:/soft/maven/localRepository
path.package=package
path.target.name=anttaskdemo1
path.package.lib=lib
path.package.log=log
path.package.config=config
path.package.bin=
M2_REPO稍后再详谈,后面的path.package之类的是最终打包时使用的几个目录名称,对应于最终打包的结构。
3. build.xml,这个内容比较多。
<?xmlversion="1.0"encoding="UTF-8"?>
<projectname="demo"default="all"xmlns:artifact="urn:maven-artifact-ant">
<description>
</description>
<propertyfile="build.properties"/>
<targetname="init_maven">
<!--
remembertosetM2_REPObeforeusethisbuild.xml,forexampleineclispe:
"Window→Preferences→Ant→Runtime",addanewpropertynamed"M2_REPO"andsetitvaluepointtothepathofyourmaven
localrepository;Oryoucansetitinbuild.properties. Youneeddoone(andonlyone)ofthem.
-->
<pathid="maven-ant-tasks.classpath"path="${M2_REPO}/org/apache/maven/maven-ant-tasks/2.0.9/maven-ant-tasks-2.0.9.jar"/>
<typedefresource="org/apache/maven/artifact/ant/antlib.xml"uri="urn:maven-artifact-ant"classpathref="maven-ant-tasks.classpath"/>
<artifact:pomid="maven.project"file="pom.xml"/>
<artifact:dependenciespathId="classpath.build"filesetid="maven.fileset.build">
<pomrefid="maven.project"/>
</artifact:dependencies>
<artifact:dependenciespathId="classpath.runtime"filesetid="maven.fileset.runtime"useScope="runtime">
<pomrefid="maven.project"/>
</artifact:dependencies>
</target>
<targetname="all"depends="init_path,compile,jar,package,zip"description="doall">
<echo>begintodoalltargettobuildtheresultpackage.</echo>
</target>
<targetname="maven_info"depends="init_maven">
<echo>Mavenbuilddirectoryis${maven.project.build.directory}</echo>
<echo>MavenbuildfinalNameis${maven.project.build.finalNam |