2

I'm using maven cxf-codegen-plugin to generate client files from wsdl but not able to do so.

I want that all the wsdl files in the folder src/main/wsdl should be scanned and corresponding clients should be generated in separate folders. Please help.

My pom.xml is :

<build>
    <finalName>someFileName</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                 <groupId>org.apache.cxf</groupId>
                 <artifactId>cxf-codegen-plugin</artifactId>
                 <version>2.2.3</version>
                 <executions>
                     <execution>
                        <id>generate-sources</id>
                        <phase>process-resources</phase>
                         <configuration>
                             <sourceRoot>src/main/java</sourceRoot>
                             <wsdlRoot>${basedir}/src/main/wsdl</wsdlRoot> 
                        </configuration>
                         <goals>
                             <goal>wsdl2java</goal>
                         </goals>
                     </execution>
                 </executions>
             </plugin>
         </plugins>
    </pluginManagement>
</build>
Bhuvan
  • 2,209
  • 11
  • 33
  • 46
  • what is the error ur getting? – Rajesh May 20 '13 at 07:30
  • I am not getting any error. But the client files are not getting generated – Bhuvan May 20 '13 at 07:51
  • When I remove from the pom.xml, then I am successfully able to generate the files. But eclipse is showing error at tag ie "Plugin execution not covered by lifecycle configuration" but build is success – Bhuvan May 20 '13 at 07:53
  • dont bother eclipse .try cleaning elipse..when build success ur done.. – Rajesh May 20 '13 at 10:35
  • You'll need a MUCH MUCH newer version of CXF for this to work with m2e's lifecycle requirement. 2.2.3 predates m2e entirely. – Daniel Kulp May 20 '13 at 13:50
  • On updating the apache cxf to version 2.7.4, I am still getting the same error – Bhuvan May 21 '13 at 14:35

3 Answers3

4

here's how I'm doing it with version 2.7.4, and having the generated code created in different packages :

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${project.build.directory}/generated/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/MyWsdl1.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>urn:mycompany:myproduct1:v1_0=com.my.project.product1</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>http://www.w3.org/2001/XMLSchema=com.my.project.common</extraarg>
                                </extraargs>
                            </wsdlOption>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/MyWsdl2.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>urn:mycompany:myproduct2:v1_0=com.my.project.product2</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>http://www.w3.org/2001/XMLSchema=com.my.project.common</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

Here's where you can find out more about the extra-args : http://cxf.apache.org/docs/wsdl-to-java.html

For an automatic scan of the wsdl folder, this works good too :

<configuration>
                        <sourceRoot>${project.build.directory}/generated/src/main/java</sourceRoot>
                        <wsdlRoot>${basedir}/src/main/wsdl</wsdlRoot>
<includes>
    <include>**/*.wsdl</include>
</includes>
</configuration>

Hope it helps!

chami
  • 41
  • 3
2

I realize this is an old question, but I just ran into this, so I wanted to reply for the benefit of others. You are right on commenting out the <pluginManagement> tag see here. However for the error in Eclipse that says:

Plugin execution not covered by lifecycle configuration

You will need to install the m2e connector for build-helper-maven-plugin (click on the error, and Eclipse should guide you to install it)

Community
  • 1
  • 1
code4kix
  • 3,937
  • 5
  • 29
  • 44
  • This works for me as well. When I remove the tag although Eclipse give error command line I was able to generate the source. :) – casper Nov 18 '16 at 03:16
0

I put plugins tag inside pluginManagement tag and error disappeared:

<pluginManagement>
   <plugins>
        <plugin>

            ..........................

        </plugin>
   </plugins> 
</pluginManagement>
dk14
  • 22,206
  • 4
  • 51
  • 88