File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes maven2 inheritance & packaging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven2 inheritance & packaging" Watch "maven2 inheritance & packaging" New topic

maven2 inheritance & packaging

Kevin Kilbane
Ranch Hand

Joined: Sep 22, 2008
Posts: 42

Hope someone can help. I am new to maven2 and am having some problems with inheritance and packaging.

I have a parent project and a number of child projects. The child projects have different packaging values - jar, ear, war etc.

The parent project has a plugin org.apache.maven.plugins.maven-antrun-plugin that calls the 'run' goal during the test phase when a certain parameter is passed in to the mvn command at the command line.

I want all child projects to be able to pass this parameter in to the mvn command and trigger the plugin during the test phase.

This is where the problems arise - I have a child project that should produce a jar file when built:

1. I do not specify a packaging value for parentProjetc(defaults to jar) and deploy it. I set the child packaging to jar. I install the parentProject but when I try to build the child project I get the error:

org.apache.maven.reactor.MavenExecutionException: Parent: parentProject:jar:1.0 of project: childProject has wrong packaging: jar. Must be 'pom'. for project childProject

2. I set the parentProject packaging to pom and deploy it. I set the childProject packaging to jar and build it. No errors this time, the project's unit tests are run but the plugin is not run during the test phase. It does not seem to be inheriting the plugin.

3. I set the parentProject packaging to pom and deploy it. I set the childProject packaging to pom and build it. No errors, the plugin is triggered but the childProject's unit tests are not run.

I'm not sure if I am doing something wrong or my whole approach is wrong.

I want to be have the plugin in the parentProject, the childProject to inherit the plugin, the childProject to run it's unit tests and the childProject to produce a jar (or an ear or a war etc.).

I can post pom.xml entries if required.

Thanks in advance for any suggestions.
It is sorta covered in the JavaRanch Style Guide.
subject: maven2 inheritance & packaging
It's not a secret anymore!