2013-03-17 18 views
0

我使用的是IntelliJ 12的Maven 3.0.5,我的pom文件设置为构建一个具有依赖关系的jar。现在,这很好,但我的问题是这样的。我如何告诉pom文件只生成一个jar文件?现在,我得到了一个具有依赖关系的jar,但是我也得到了另一个没有依赖关系的jar,我最终只是通过手工删除它。我在这里检查:http://maven.apache.org/pom.html,它看起来像包装将默认构建一个jar,即使我没有指定它,并在我的部分我告诉Maven建立另一个jar文件。我可以在我的pom中更改哪些内容以仅构建一个具有依赖关系的jar?Maven 3.0.5和IntelliJ 12构建两个jar文件

<?xml version="1.0" encoding="UTF-8"?> 
<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>com.xyz.program.test</groupId> 
    <artifactId>xyz-program-test</artifactId> 
    <packaging>jar</packaging> 
    <version>1.2</version> 
    <dependencies> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.31.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-firefox-driver</artifactId> 
      <version>2.31.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-htmlunit-driver</artifactId> 
      <version>2.31.0</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
     </dependency> 
    </dependencies> 
    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.seleniumhq.selenium</groupId> 
       <artifactId>selenium-firefox-driver</artifactId> 
       <version>2.31.0</version> 
       <exclusions> 
        <exclusion> 
         <groupId>org.seleniumhq.selenium</groupId> 
         <artifactId>selenium-remote-driver</artifactId> 
        </exclusion> 
       </exclusions> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-plugin-plugin</artifactId> 
       <version>3.0</version> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.0</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <configuration> 
        <archive> 
         <manifest> 
          <mainClass>com.setup.test.Setup</mainClass> 
         </manifest> 
        </archive> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
       <executions> 
        <execution> 
         <id>make-assembly</id> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

道歉的格式。

+1

贵根项目具有以下配置'罐子'?如果是,请将其更改为' pom' – Vic 2013-03-17 14:38:23

+0

谢谢!我认为这是完美的。 – cbohannon 2013-03-17 14:55:06

回答

1

作为写入pom reference page要链接到:

聚合(或多模块)

的模块被称为一个多模块,或聚合项目的一个项目。模块是POM列出的项目,并作为一个组执行。 pom打包的项目可以通过将它们列为模块来聚合一组项目的构建,这些模块是这些项目的相对目录。

为了有一个“POM打包项目”标志着你的根项目本身 - 注意到包装pom

<groupId>com.xyz.program.test</groupId> 
<artifactId>xyz-program-test</artifactId> 
<packaging>pom</packaging>