2012-03-02 76 views
-1

我使用maven和外部jar作为其他项目的输出。 当我构建项目来创建一个jar时,不会添加依赖项。我想要添加依赖关系。Eclipse Indigo不包括jar文件夹中的依赖项

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
     <modelVersion>4.0.0</modelVersion> 
     <groupId>Generic.Demo</groupId> 
     <artifactId>Generic.Demo</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
     <dependencies> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.18.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.4</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.mail</groupId> 
      <artifactId>mail</artifactId> 
      <version>1.4.4</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.thoughtworks.xstream</groupId> 
      <artifactId>xstream</artifactId> 
      <version>1.4.2</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>net.sourceforge.jexcelapi</groupId> 
      <artifactId>jxl</artifactId> 
      <version>2.6.12</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>11.0.2</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
     </dependencies> 
     <dependencyManagement> 
     <dependencies> 
     </dependencies> 
     </dependencyManagement> 
     <modules></modules> 
    </project> 

这是我的pom.xml文件看起来像..没有建立/插件部分添加

请帮助。

谢谢。

+0

然后添加构建/插件部分。 – 2012-03-02 16:27:33

+0

在你问这样的问题之前,你需要阅读一下Maven。从http://sonatype.com/Support/Books上的免费书籍开始。查看Maven by Example。 – 2012-03-02 19:08:45

+0

嗨@GuillaumePolet ..谢谢 – 2012-03-05 08:25:26

回答

2

使用Maven Assembly插件使用内置的描述符jar-with-dependencies

在你的pom.xml以下插件添加到您的构建/插件部分:

<plugin> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <version>2.3</version> 
    <configuration> 
     <descriptorRefs> 
     <descriptorRef>jar-with-dependencies</descriptorRef> 
     </descriptorRefs> 
    </configuration> 
    <executions> 
    <execution> 
    <id>build-package</id> 
    <phase>package</phase> 
    <goals> 
     <goal>single</goal> 
    </goals> 
    </execution> 
</executions> 
</plugin> 

看一看他们的网站所有脆弱的细节。

+0

谢谢Guillaume Polet回复。你能否解释在哪里使用以及如何使用该描述符。 – 2012-03-02 15:40:56

+0

嗨@Guillaume Polet。我试着按照你的解释,但结果仍然是一样的。 – 2012-03-05 11:25:04

+0

你是否将目标限制在一个阶段?我刚刚编辑了我的答案并添加了一个例子。然后运行'mvn package',你应该得到你想要的 – 2012-03-05 11:41:52