Rom*_*las 11 build-process maven-2
我有两个项目,my-lib和my-webapp.第一个项目是依赖my-webapp.因此,当要求Maven2构建我的WAR时,my-libJAR将添加WEB-INF/lib/到Web应用程序的目录中.
但是,我希望将my-libJAR直接解压缩到WEB-INF/classes目录中,就像my-lib源代码包含在项目中一样my-webapp.
换句话说,而不是具有以下WAR内容:
my-webapp/
...
WEB-INF/
lib/
my-lib-1.0.jar
... (others third libraries)
Run Code Online (Sandbox Code Playgroud)
我想拥有:
my-webapp/
...
WEB-INF/
classes/
my-lib files
lib/
... (others third libraries)
Run Code Online (Sandbox Code Playgroud)
有没有办法配置my-webapp或Maven2战争插件来实现这一目标?
正如blaufish的回答所说,你可以使用maven-dependency-plugin的unpack mojo解压缩一个工件.但是,为了避免jar出现在WEB-INF/lib中,您不需要将其指定为依赖项,而是将插件配置为解压缩特定工件.
以下配置将在process-resources阶段将some.group.id:my-lib:1.0:jar的内容解压缩为目标/类,即使工件未定义为依赖项.这样做时要小心,因为有可能破坏你的实际内容,这可能会导致很多调试.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-my-lib</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>some.group.id</groupId>
<artifactId>my-lib</artifactId>
<version>1.0</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)