2

I run wsgen in its own profile because I don't want it to run every time I build the product. But I'm getting an error about a missing version when I run it:

$ mvn package -P wsgen [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project project-ejb:2.3.15-SNAPSHOT (C:\Projects\MyProject\pom.xml) has 1 error [ERROR]
'build.plugins.plugin[org.jvnet.jax-ws-commons:jaxws-maven-plugin].dependencies.dependency.version' for org.glassfish:javax.javaee:jar is missing. @ line 167, column 41 [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

This is a snippet of the child pom (the pom with the profile):

<packaging>ejb</packaging>
<parent>
    <artifactId>MyProject</artifactId>
    <groupId>project</groupId>
    <version>2.3.15-SNAPSHOT</version>
</parent>
<profiles>
    <profile>
        <id>wsgen</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jax-ws-commons</groupId>
                        <artifactId>jaxws-maven-plugin</artifactId>
                        <version>2.1</version>
                        <executions>
...
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.glassfish</groupId>
                        <artifactId>javax.javaee</artifactId>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</profile>

But, in the parent pom I'm defining this dependency with its version under the dependencyManagement tag.

I think what's happening is the profile doesn't inherit the parent's dependencyManagement tag so it thinks that the dependency is missing a version number. Is there a way to make the profile inherit this from the parent?

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

2 Answers2

4

dependencyManagement applies for dependencies in the pom and child poms. It does not apply to dependencies in plugins (at least, that's what i noticed in several plugins, like maven-dependency-plugin).

A possible solution is defining a property (javax.javaee.version) in your parent pom and using it in your dependencyManagement and in your jaxws-maven-plugin plugin.

asgoth
  • 35,552
  • 12
  • 89
  • 98
  • I think you're right, because when I defined a dependencyManagement tag directly under the profile, the error didn't change. Thanks for the help. – Daniel Kaplan Jan 08 '13 at 19:42
2

You can use the <pluginManagement> tag to configure a plugin in a parent pom, let it be its version number, phase, goal or other configuration.

All inheriting poms will have the same configuration as the parent pom, as long as you declare the same <groupId> and <artifactId> in child poms.

matsev
  • 32,104
  • 16
  • 121
  • 156
  • But, if what @asgoth says is true, I'd still end up using a variable for the version, right? – Daniel Kaplan Jan 08 '13 at 21:27
  • @DanielKaplan You can, but it is not required. Take a look at the example in the link above. As can be seen, there is no `` tag for the maven-jar-plugin in the child pom (neither a hardcoded value, nor a maven property). – matsev Jan 09 '13 at 07:49
  • The child avoids the version, but the parent needs the version. Both the parent pom's `` and `` would use the same dependency, I'd end up using a variable to avoid a DRY violation. At least as far as I can tell. – Daniel Kaplan Jan 09 '13 at 17:59