我正在使用 Maven 3.0.5 和 IntelliJ 12,并且我的 pom 文件设置为构建具有依赖项的 jar。现在效果很好,但我的问题是这样的。如何告诉 pom 文件只构建一个 jar?现在我得到了一个带有依赖项的 jar,这是我想要的,但我也得到了另一个没有依赖项的 jar,我最终只是手动删除它。我在这里查看:http://maven.apache.org/pom.html看起来打包将默认构建一个 jar,即使我没有指定它,并且在 pom 的我的部分中我告诉 Maven 构建另一个 jar 文件。我可以在我的 pom 中更改什么来仅构建一个具有依赖项的 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>
对格式表示歉意。
最佳答案
如 pom reference page 中所写您正在链接到:
Aggregation (or Multi-Module)
A project with modules is known as a multimodule, or aggregator project. Modules are projects that this POM lists, and are executed as a group. An pom packaged project may aggregate the build of a set of projects by listing them as modules, which are relative directories to those projects.
为了让“pom 打包项目”标记您的根项目 - 请注意打包中的 pom
:
<groupId>com.xyz.program.test</groupId>
<artifactId>xyz-program-test</artifactId>
<packaging>pom</packaging>
关于java - Maven 3.0.5 和 IntelliJ 12 构建两个 jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15461503/