【问题标题】:maven-dependency-plugin unpack not being executed during phasemaven-dependency-plugin unpack 未在阶段执行
【发布时间】:2012-04-08 11:50:42
【问题描述】:

我正在打包一个 ejb,我需要将一些依赖项中的 .classes 包含到 jar 中,我正在尝试使用 ma​​ven-dependency-plugin 来解压工件并将在 package 阶段我的 ${project.build.directory}/classes 目录中的文件,但是当我执行 mvn package 我没有看到任何记录或引用 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:工件模型安装在本地仓库中,我也尝试过其他阶段。

【问题讨论】:

    标签: maven maven-3 maven-dependency-plugin


    【解决方案1】:

    如果您删除包含文本 的行,插件应该会执行。只有那两条线,而不是中间的线。 pluginManagement 是一个稍微高级的功能。

    PluginManagement 为从该 POM 继承的 POM 提供配置详细信息。但是,本节仅提供配置详细信息。要实际执行,插件必须在 pluginManagement 部分之外显式引用。

    POM Reference

    【讨论】:

    • 这解决了我的问题!我想知道&lt;pluginManagement&gt; 是如何到达那里的...一定是从某个地方复制的...
    • 在使用 pluginManagement 时执行父 pom 时是否忽略所有插件或仅忽略某些插件?
    • 哇,2021年还有效。谢谢分享。
    猜你喜欢
    • 2019-05-30
    • 2012-02-01
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    相关资源
    最近更新 更多