Question

I have a parent POM with several child modules. For one of these I have added an antrun section under build - at the moment this simply prints a statement. This child module has dependencies on other modules in the overall set (So the parent has 8 children 1 - 8, this module (#5) depends on 2 and 3)

The antrun section is in the form:

<build>...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo>*******************  Running generate </echo>
                     </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

If I perform an action under the parent module (eg, validate or install for example) these work fine, and as expected the echo statement is run for the child (#5) that holds this antrun task.

However, if I go to the child module and try mvn validate from there I get the (legendary)

could not resolve dependencies for project...

failure. But all the modules are present in my local repos, and they are up to date. And the usual fix for this problem of doing mvn install again does not fix it.

It looks like a bug to me, unless anyone else knows (what the hell) is going awry.

Chris

Was it helpful?

Solution 2

OK, my fault this one. I had added an additional POM to parent project. I was hoping to just place common dependencies in there keeping the top level POM with respo, distribution stuff etc.

maven seemed to will work locally with this but will not deploy this POM only artefact to the repo - so this was never found there. Puzzle is why this still worked when performing a build from the parent.

Anyway it's fixed - I have folded the dep stuff into my single parent POM, and all is well. Thanks for the feedback all.

OTHER TIPS

If you call a sub module in maven you have to do it in a particular way.

 +-- root (pom.xml)
       +-- mod-child-1
       +-- mod-child-2
       +-- mod-child-3
       +-- mod-child-4
       ....

If you like to do that for example for mod-child-3 you need first do a mvn install via the root ...after that you can do the following from the root location of your multi-module build:

mvn -pl mod-child-3 package 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top