davidmontoyago
davidmontoyago

Reputation: 1833

maven-dependency-plugin unpack not being executed during phase

I'm packaging an ejb and I need to include some .classes from a dependency into the jar, I'm trying to use the maven-dependency-plugin to unpack the artifact and put the files in my ${project.build.directory}/classes directory during the package phase, but when I execute mvn package I dont see any log or reference to the maven-dependency-plugin (nothing happens), I even tried putting a invalid version of the plugin and It doesn't even throw exceptions.

Below my 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>

what am I missing?

PS: the artifact model is installed in the local repo and I have tried with other phases too.

Upvotes: 3

Views: 5639

Answers (1)

mikemay
mikemay

Reputation: 4657

If you remove the lines containing the text <pluginManagement> and </pluginManagement> the plugin should execute. Just those two lines, not the lines in between. pluginManagement is a marginally advanced feature.

PluginManagement provides configuration details to POMs that inherit from this POM. However this section provides only the configuration details. To actually be executed, the plugin must be explicitly referred to outside of a pluginManagement section.

See POM Reference

Upvotes: 14

Related Questions