我有一个maven项目。
在该项目中,我有一个带有jar 的.zip依赖项,我需要从zip依赖项中提取该jar并让 Maven 使用该jar作为依赖项。我目前可以下载并解压 zip,但是无法找到在构建过程中将解压的jar添加为项目依赖项的方法。
这是我目前正在做的拆包工作:
<dependency>
<groupId>com.bar</groupId>
<artifactId>foo</artifactId>
<version>${foo.version}</version>
<type>zip</type>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>validate</phase>
<configuration>
<includeGroupIds>com.bar</includeGroupIds>
<includeArtifactIds>foo</includeArtifactIds>
<outputDirectory>${basedir}/target</outputDirectory>
<type>jar</type>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我阅读了其他一些帖子,您可以尝试使用它将 jar 添加到类路径中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
即使这样做,我仍然无法在我的项目中引用foo.jar中的包。
有人能帮我吗?