Kornelito Benito
Kornelito Benito

Reputation: 1107

JAXB2-maven only builds in target

I'm on my first Java-Spring project. I need to communicate with a couple of webservices. I have some WSDL's provided, so i'm using Jax2B to autogenerate classes.

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.9.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>hello.wsdl</generatePackage>
                    <forceRegenerate>true</forceRegenerate>
                    <schemas>
                        <schema>
                            <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>

                </configuration>
</plugin>

My project is a web project. The problem here is, my classes are generated in the targets folder, and not in my project. Does somebody have ideas how to fix this? Classes are generated properly, but not at the proper directory. As you can see, i'm using a test wsdl and mockup names at the moment. I followed this tutorial: http://spring.io/guides/gs/consuming-web-service/

Many thanks in advance

Upvotes: 4

Views: 1665

Answers (2)

lexicore
lexicore

Reputation: 43671

Author of the maven-jaxb2-pugin here.

target/generated-sources/xjc IS the proper directory. This is how generated code is handled in Maven builds, you never generate anything into src/main/java.

The maven-jaxb2-plugin also adds this directory to the Maven's sources directories. You just have to make sure that this directory is considered a source directory by your IDE. In Eclipse, m2eclipse plugin does this automatically when you do "Update project".

See this part of the docs.

Upvotes: 7

Xstian
Xstian

Reputation: 8272

I use this plugin to add the classes generated to source....

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/xjc</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Upvotes: 3

Related Questions