23

Under Helios/m2eclipse, when I generated jaxb sources they would be put on the Eclipse source path when I did an "Update Project Configuration".

This doesn't happen with Indigo/m2e (initial release of 22 June 2011). What do I need to do to fix this?

I'm using the standard maven-jaxb2-plugin, version 0.75.

Marco
  • 8,958
  • 1
  • 36
  • 56
Ed Staub
  • 15,480
  • 3
  • 61
  • 91
  • 1
    After seeing the votes on this, I should add what else I know. It isn't explicitly said [here](http://wiki.eclipse.org/M2E_plugin_execution_not_covered), but I suspect that an m2e extension is required for any plugin that generates sources. I've put in [a Bugzilla request for maven-jaxb2-plugin](https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299). – Ed Staub Jun 25 '11 at 14:42
  • An extension has been written. I haven't tried it. See [comment 12 on the Bugzilla request](https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299#c12). If anyone else confirms it works, answer and I'll accept. – Ed Staub Jul 05 '11 at 19:44

5 Answers5

25

In Eclipse go to "Install New Software" add the software site: http://bitstrings.github.com/m2e-connectors-p2/releases/

Select the "m2e connector for jaxb2"

Once you get that plugin installed the jaxb2 plugin should integrate correctly with the new version of m2e.

This info is from: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Eric
  • 462
  • 3
  • 7
  • There's also another plugin available - see [comment 16, same bugzilla report](https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299#c16). – Ed Staub Jul 18 '11 at 12:28
  • What is the difference between the two? – quantum Apr 25 '12 at 07:14
  • 1
    The second plugin (http://bitstrings.github.com/m2e-connectors-p2/releases) also supports org.codehaus.mojo:jaxb2-maven-plugin in addition to org.jvnet.jaxb2.maven2:maven-jaxb2-plugin . – Jason Day Aug 21 '12 at 16:27
  • 2
    In my particular case (Eclipse Mars SR1), the currently latest version of `org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0` was not identified by the Bitstrings connector. Downgrading to version `org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.1` helped. – Abdull Nov 02 '15 at 15:35
  • @Abdull I had the same issue, it appears to have been an issue with the plugin itself. It was corrected in 0.13.1. Modify pom.xml to use a version 0.13.1 or higher. – Stephan Mar 15 '18 at 13:42
6

Well, you need to right click on the "target/generated-sources/xjc and select something like "Build Path -> Use as source folder"

Rafał
  • 582
  • 1
  • 9
  • 14
2

As an alternate workaround if you can't get the m2e connector working, you can add the generated sources to the build path with build-helper-maven-plugin:

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
      <executions>
        <execution>
          <id>add-source</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>add-source</goal>
          </goals>
          <configuration>
            <sources>
              <source>target/generated-sources/xmlbeans</source>
            </sources>
          </configuration>
        </execution>
      </executions>
    </plugin>
    ...     
  </plugins>
  ... 
</build>
Shane
  • 4,179
  • 1
  • 28
  • 26
1

While waiting for a fix for this problem, I'm using the following temporary workaround:

We have the jaxb-plugin and generated classes in a separate maven module. In eclipse I can then "disable Maven nature" on that module only. Then I can use Indigo with m2eclipse on the rest of our large maven project and it will depend on the jar for the jaxb module (must be built from the command line). This works well for me since our project was allready organized this way.

froden
  • 21
  • 6
0

For those who are suffering with maven-jaxb2-plugin and Eclipse not having source attached. The author has switched from the Sun to the Glassfish JAXB artifacts and the dependency tree has changed. Previously many JARs where shaded into jaxb-xjc without transitive ones. Now, this has been removed and the previous transitive dependency to tools.jar breaks Eclipse execution. Start your Eclipse with a JDK VM and it will work. (Tested most recent Maven 3.3.9, Maven JAXB2 Plugin 0.13.1, recent m2e JAXB2 connector and Eclipse Mars.2)

Community
  • 1
  • 1
Michael-O
  • 18,123
  • 6
  • 55
  • 121