我正在打包一个 ejb,我需要将依赖项中的一些 .classes 包含到 jar 中,我正在尝试使用 Maven 依赖插件在打包阶段解压缩 Artifact 并将文件放在我的 ${project.build.directory}/classes 目录中,但是当我执行时 mvn 包 我没有看到任何日志或对 maven-dependency-plugin 的引用(什么也没发生),我什至尝试放置一个无效版本的插件,它甚至没有抛出异常。
在我的 pom.xml 下面
....
<packaging>ejb</packaging>
<name>myapp</name>
...repository and props
<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.myapp</groupId>
<artifactId>model</artifactId>
<version>1.0.0</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**/shared/*.class</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.myapp</groupId>
<artifactId>model</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
我错过了什么?
PS: Artifact 模型安装在本地存储库中,我也尝试过其他阶段。
最佳答案
如果删除包含文本
PluginManagement 向从该 POM 继承的 POM 提供配置详细信息。但是,本节仅提供配置详细信息。要实际执行,必须在 pluginManagement 部分之外显式引用插件。
见 POM Reference
关于maven-dependency-plugin unpack 在阶段没有被执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9847340/