Basically what i am trying to do is that i will create wsdl folder under resources and i will add my wsdl files in it. Every time when i run mvn clean install command on console, what i expect from cxf plugin is create java files from wsdl.
But, regarding to apache cxf documentation, i apply what it says but nothing happens when i run mvn generate-sources (i will use mvn clean install to create java files instead of using mvn generate-sources next step, if you have any advice it would be great also).
What is wrong with this code?
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.erkan</groupId>
<artifactId>wsClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>wsClient</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/jaxws-maven-plugin -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.2.7</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.7</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/is.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<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>${basedir}/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
3
Answers
You should declare your plugin in plugins.
Links:
It works with:
and
For some reasons,
org.apache.cxf:cxf-codegen-plugin
does not work inside<pluginManagement>...</pluginManagement>
.In my previous CXF projects, I usually put it inside
<plugins></plugins>
. I have already tried with yourpom.xml
and noticed thatcxf-codegen-plugin
has been ignored completed, even though it is still seen in the effective POM.There is another issue with your original
pom.xml
. In the goaladd-source
ofbuild-helper-maven-plugin
, the<source>
(to be added as Java code) should be exactly the folder where the code are generated (i.e. the<sourceRoot>
ofcxf-codegen-plugin
):Here is the full
pom.xml
that works in my test project with similar settings, you can customize to your needs. I have just added the-verbose
option so that you can see some information whencxf-codegen-plugin
is working.You only need to run
mvn clean compile
ascompile
includesgenerate-sources
.