Egor
Egor

Reputation: 1409

Maven dependency plugin does not rebuild dependencies

I have multi-module project with structure like:

my-project
 - moduleA
 - moduleB
 - moduleC

pom.xml for moduleA configured like:

<profiles>
    <profile>
        <id>withArtifacts</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>

                    <dependencies>
                        <dependency>
                            <groupId>com.ekiryuhin</groupId>
                            <artifactId>moduleB</artifactId>
                            <version>${project.version}</version>
                        </dependency>

                        <dependency>
                            <groupId>com.ekiryuhin</groupId>
                            <artifactId>moduleC</artifactId>
                            <version>${project.version}</version>
                        </dependency>
                    </dependencies>

                    <executions>
                        <execution>
                            <phase>install</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeArtifactIds>
                                    moduleB,moduleC
                                </includeArtifactIds>
                                <outputDirectory>
                                    ${project.build.directory}/lib
                                </outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Then:

  1. Add some code in classes inside moduleB and moduleC.
  2. cd to my-project/moduleA.
  3. Run mvn clean install -PwithArtifacts -DskipTests -am

And finally I have jar files in ${project.build.directory}/lib but they do not contain my edits from (1).

Why maven may do not rebuild dependencies before copy?

UPD:

pom.xml from moduleB:

Upvotes: 0

Views: 684

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35805

You need build all the modules for that. Go the main project my-project and call mvn clean install. You also need to make sure that moduleA depends on moduleB and moduleC so that the build order will be correct.

Upvotes: 1

Related Questions