书到用时方恨少

maven 管理JAR包

上一篇 / 下一篇  2007-07-21 00:19:19 / 个人分类:maven

   过完5.1之后,我就忙给公司建私服,因为老板说要用maven对JAR包进行,而在网络上那些JAR包之间有着复杂的依赖关系,有时候会影响到工程的运行,所以我只能慢慢地修改掉它们之间的依赖关系.然后给开发人员写使用说明,并辅导他们将maven插件给使用起来.经过两个月的磨练,好象步入正轨了.

   当我在做编译和打WAR包的时候,我需要那些JAR从何而来呢?

  

<target name="maven-all" descrīption="将pom.xml所引用的JAR包从本地仓库拷贝到lib目录下">

<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
<classpath>
<pathelement location="lib/maven-artifact-ant-2.0.4-dep.jar"/>
</classpath>
</typedef>
<artifact:dependencies pathId="maven.classpath" filesetId="maven.fileset">
<artifact:pom file="pom.xml"/>
</artifact:dependencies>

<copy todir="lib/">
<fileset refid="maven.fileset"/>
<mapper type="flatten"/>
</copy>

</target>

   当开发人员增加了新的JAR包,而私服中不存在该JAR时,该怎么处理呢?

   假如:开发人员需要添加的是 ecside-1.25.jar

  在私服中 添加 ecside/ecside/1.25 目录

    新增ecside-1.25.pom 文件,然后用ANT

<target name="checksum" descrīption="为maven私服上的文件生成CHECKSUM">
<checksum file="ecside-1.25.pom" algorithm="SHA" fileext=".sha1"/>
</target>

   在工程中的引用

  

<?xml version="1.0" encoding="UTF-8"?>
<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>oss</groupId>
   <artifactId>oss</artifactId>
   <version>0.0.1</version>
   <descrīption>libs</descrīption>
   <repositories>
     <repository>
       <id>maven-rep</id>
       <name>maven-server</name>
       <url>http://maven-server/libs</url>
     </repository>
   </repositories>
   <dependencies>
     <dependency>
       <groupId>ecside</groupId>
       <artifactId>ecside</artifactId>
       <version>1.25</version>
     </dependency>
   </dependencies>
</project>

   至于maven插件如何安装,就不详细说明了.

 


TAG: maven ant eclipse

 

评分:0

我来说两句

Open Toolbar