Jan Tacci
Jan Tacci

Reputation: 3211

How To Include Xml Schemas/Resources In Target Jar File When Compiling With Maven Jaxb?

I took over ownership of a Java project that uses the maven-jaxb2-plugin. Everything compiles fine, however, it's not putting the xsd files in the generated .jar file.

The only thing I can think of that's different is my .xsd files used to live the folder src/main/resources and now they reside in a folder called xsd.

Is src/main/resources folder the default folder name where maven (or jaxb?) looks for content when packing up the .jar file? If so, how can I add to/change the defaults?

Here is my plugin configuration for jaxb:

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <configuration>
                <catalog>xsd/catalog.xml</catalog>
                <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                <extension>true</extension>
                <schemaDirectory>${basedir}/xsd</schemaDirectory>
                <schemaIncludes>
                    <include>core-types.xsd</include>
                </schemaIncludes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Thank you.

Upvotes: 3

Views: 2599

Answers (1)

jtahlborn
jtahlborn

Reputation: 53694

yes, "src/main/resources" data is included in the jar by default.

You can add other resources following the example here (first hit on google for "maven resources folder").

Upvotes: 2

Related Questions