我有一个遗留的蚂蚁项目,它需要第三方战争,解开它,然后使用其中的资源和库(100+ jar(进行构建。
在Maven中,我能够从存储库中获取此战争文件并将其解压缩。但是如何将 jar 包含在解压缩的目录中以进行编译呢?
另外,如何确保在解压缩后进行编译?
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="[http://maven.apache.org/POM/4.0.0](http://maven.apache.org/POM/4.0.0)" xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)" xsi:schemaLocation="[http://maven.apache.org/POM/4.0.0](http://maven.apache.org/POM/4.0.0) [http://maven.apache.org/xsd/maven-4.0.0.xsd](http://maven.apache.org/xsd/maven-4.0.0.xsd)">
<modelVersion>4.0.0</modelVersion>
<groupId>project1</groupId>
<artifactId>project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project1 Maven Webapp</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.abc.third-party</groupId>
<artifactId>externalWar</artifactId>
<version>1.0.0</version>
<type>war</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
作为第一步,尝试将依赖插件绑定到编译前运行的生命周期阶段,例如:generate-sources
.因此,您可以确保解压缩的源在compile
阶段运行时存在。