我正在将一个netbeans示例项目从ant转换为要在其中创建具有依赖关系的jar文件的maven。我正在使用此pom文件:
<?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>org.todivefor.myselenium</groupId>
<artifactId>MySelenium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.13.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.13.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.todivefor.myselenium.MySelenium</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
当我使用mvn assembly:single运行此命令时,得到以下输出:
PWRMacbookPro:MySelenium peterr$ mvn assembly:single
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< org.todivefor.myselenium:MySelenium >-----------------
[INFO] Building MySelenium 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:3.1.1:single (default-cli) @ MySelenium ---
[WARNING] Cannot include project artifact: org.todivefor.myselenium:MySelenium:jar:1.0-SNAPSHOT; it doesn't have an associated file or directory.
[INFO] Building jar: /Users/peterr/Documents/NetBeansProjects/MySelenium/target/MySelenium-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.173 s
[INFO] Finished at: 2019-05-02T11:58:17-04:00
[INFO] ------------------------------------------------------------------------
PWRMacbookPro:MySelenium peterr$
如果我这样更改pom文件:
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
为了消除maven-assembly-plugin的版本,maven使用了plugin:2.2-beta-5,并且构建工作正常:
PWRMacbookPro:MySelenium peterr$ mvn assembly:single
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< org.todivefor.myselenium:MySelenium >-----------------
[INFO] Building MySelenium 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ MySelenium ---
.
.
.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.963 s
[INFO] Finished at: 2019-05-02T11:54:25-04:00
[INFO] ------------------------------------------------------------------------
PWRMacbookPro:MySelenium peterr$
我有两个问题,如果我在未标识版本的pom上运行mvn,为什么maven使用plugin:2.2-beta-5?为什么2.2-beta-5插件不能工作,而3.1.1不能工作?