使用 maven 指定特定的 jar 文件

Specifying specific jar files with maven

在 ~/.m2/path/to/jarfiles 中有 jar 文件。一个是 dependencyName.jar,另一个是 dependencyName-runtime.jar 我正在尝试使用 maven-dependency-plugin 来复制 jar 的运行时版本,但它一直在复制 jar 的常规版本。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>${maven.dependency.version}</version>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.jacoco</groupId>
                                <artifactId>org.jacoco.agent</artifactId>
                                <version>${code.coverage.jacoco.version}</version>
                                <type>jar</type>
                                <overWrite>false</overWrite>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

假设runtime是一个分类器,你应该添加

<classifier>runtime</classifier>

给你的 artifactItem.