How does one get JAXB-generated sources onto the Eclipse build path under m2e/Indigo?

后端 未结 5 1014
眼角桃花
眼角桃花 2020-12-24 07:45

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 ha

相关标签:
5条回答
  • 2020-12-24 07:54

    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)

    0 讨论(0)
  • 2020-12-24 08:00

    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>
    
    0 讨论(0)
  • 2020-12-24 08:03

    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

    0 讨论(0)
  • 2020-12-24 08:10

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

    0 讨论(0)
  • 2020-12-24 08:12

    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.

    0 讨论(0)
提交回复
热议问题