0

We have 2 different projects each having their own XSDs to generate classes using JAXB. Each project has the same maven plugin configuration for doing this which is

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
        <execution>
            <id>generate-pojo</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <extension>true</extension>
                <args>
                    <arg>-Xsetters</arg>
                    <arg>-Xsetters-mode=direct</arg>
                </args>
                <forceRegenerate>false</forceRegenerate>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>${jaxb2-basics.version}</version>
                    </plugin>
                </plugins>
            </configuration>
        </execution>
    </executions>
</plugin>

The problem is, after I run the mvn install command in Eclipse and refresh the project tree, I can see the newly generated classes as a source folder in only one of the projects but not the other. What could be the issue with other project?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Mukund Jalan
  • 1,145
  • 20
  • 39
  • Maybe one project declares the `buildhelper-maven-plugin` and not the other? – Tunaki Dec 31 '15 at 15:26
  • One project has this plugin only in pluginManagement without any configuration. I tried the same with the other with no luck. – Mukund Jalan Dec 31 '15 at 15:29
  • Please post the full POM of the two concerned projects. – Tunaki Dec 31 '15 at 15:30
  • cannot post the full POM due to security reasons. It won't make much sense as well as both the projects are children of 2 different parents providing lots of configurations inherited by children. I could find the `build-helper-maven-plugin` in the `pluginManagement` tag of project1 in effective POM so I tried the same in project2 – Mukund Jalan Dec 31 '15 at 15:33
  • Hi you need to declare a similar, config (as the one above) to the second pom as well. The fact that a plugin is configured in the plugin Management section - does not make it active by default (but I think you know that). Similar [issue](http://stackoverflow.com/questions/10483180/maven-what-is-pluginmanagement) for the difference . Can you verify that you have in both cases the plugin defined? – javapapo Dec 31 '15 at 16:13
  • @javapapo as you said, I do know use of `pluginManagement`, & so was I unsure on the usage of `build-helper-maven-plugin` in case.of project1. Regarding the configuration, both the projects have this `plugin` declared under `build` & not under `pluginManagement` with same set of configurations. In fact the config was copy-pasted from proj1 when creating proj2 – Mukund Jalan Dec 31 '15 at 16:20
  • Do these project have the same parent? Are there any profiles involved? It would really help if you could provide some of the related pom(s) to be honest as [tunaki](http://stackoverflow.com/users/1743880/tunaki) suggested. – javapapo Dec 31 '15 at 16:22

1 Answers1

0

Disclaimer: I am the author of maven-jaxb2-plugin.

If you don't show your pom.xml, it is hard to impossible to tell what the problem is. I'd suggest that the plugin is not active. For instance, it may be declared in the pluginManagement but not in build/plugins. Or this may be a pom (vs. jar) packaging etc. The fragment of the pom.xml you show seems perfectly fine to me.

As the plugin authors, my primary response would be that you should post the mvn clean install -e -X log of your project as well as pom.xml, or, better, send me a pull request with the reproducing project here:

https://github.com/highsource/maven-jaxb2-plugin-support

ps. Unlike @Tunaki suggests, if you use my maven-jaxb2-plugin, you don't need to declare buildhelper-maven-plugin. maven-jaxb2-plugin automatically adds generated sources folder as a Maven source folder.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • I am sorry that I can't post any of the poms. Also reproducing the same problem may not be possible. I'll try with some other settings and get back if I get something notable here. – Mukund Jalan Dec 31 '15 at 17:40
  • BDW could it be possible that some other plugin in proj2 is blocking the source folder attachment? IS there any chance for it so that I can check which plugin might be doing this. – Mukund Jalan Dec 31 '15 at 17:42
  • @Mukund Consider anonymizing your poms. I can't really imagine anything blocking source folder attachment, but Maven/m2e ecosystem is very complex, anything can happen. Does it work from the command line? Do you get all your generated sources compiled? Maybe m2e in Eclipse isn't picking the source folder attachment at once. Hard to say, no repro - no way to solve it, sorry. – lexicore Dec 31 '15 at 20:27