3

I would like to generate schema from JAXB annotated classes. For this, I am using jaxb2-maven-plugin. The plugin by default scans src/main/java folder for included sources. I would like to specify an extra folder to scan for java classes which is not maven source path.

Can anyone please help?

  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>${maven.plugin.jaxb2}</version>
        <executions>
           <execution>
              <id>schemagen</id>
              <goals>
                 <goal>schemagen</goal>
              </goals>
              <phase>process-classes</phase>
              <configuration>

                 <includes>
                    <include>SomeFolderWhichIsNotInMavenSourcePath/*.java</include>
                 </includes>
                 <outputDirectory>${project.build.directory}/schemas</outputDirectory>
              </configuration>
           </execution>
        </executions>
     </plugin> 
White Roses
  • 309
  • 1
  • 6
  • 16

2 Answers2

0

Includes should be absolute paths to directories:

<includes>
    <include>${basedir}/src/main/java</include>
</includes>

You may run maven in debug mode to see which source directories are being used.

0

You need to use sources instead of includes:

<sources>
   <source>${basedir}/src/main/java/<YourPath></source>
</sources>

In this way it will only scan the path you write between the sources tags.

Stefania
  • 641
  • 1
  • 12
  • 34