cxf-codegen-plugin to exclude XSD files

3.1k views Asked by At

I use cxf-codegen-plugin to generate a series of WS clients using Maven, on construction time. These WSDL reference some XSD schema definitions using a relative path like so: ../someService/schema.xsd

Now when I trigger a construction from Eclipse this works properly since my XSD files are placed in the right path.

But when I launch a construction job from Jenkins, it fails because it seems it's using Jenkins workspace as the root of the construction.

I don't even know if you can change this behavior of Jenkins, but since I have no control over my Jenkins instance, what I would like to know is for cxf-codegen-plugin to exclude XSD processing altogether, and then generate those classes explicitly using a different execution phase with a different plugin.

I've read you can do it like this:

<defaultOptions>
    <extraargs>
        <extraarg>-nexclude</extraarg>
        <extraarg>http://*.ws.cntxes.emprego.xunta.es</extraarg>
    </extraargs>
</defaultOptions>

But this assumes I know those namespaces prior to constructing, which I don't (WSDL files are taken from external dependencies using maven dependency plugin).

I also tried:

<wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
<includes>
    <include>
    **/*.wsdl
    </include>
</includes>
<excludes>
    <exclude>
     *.xsd
    </exclude>
</excludes>

But this does not work, the plugin just keeps parsing the XSD files and generating the related classes.

Is there any other way I'm missing to prevent the parsing of XSD files and just process the WSDL definitions?

EDIT: this is the error Jenkins is giving me:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources-wsclient-cxf) on project my-project: Execution generate-sources-wsclient-cxf of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : file:/var/lib/jenkins/workspace/MYPROJECT/myproject-webservice/src/main/resources/wsdl/Descriptor/serviceDescriptor.wsdl
[ERROR] Caused by : WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing '../xsd/schema.xsd'.: java.io.FileNotFoundException: /var/lib/jenkins/workspace/xsd/actividadFormativa.xsd (No such file or directory)

It is looking on the root of jenkins' workspace instead of /var/lib/jenkins/workspace/MYPROJECT/myproject-webservice/src/main/resources/wsdl/xsd/schema.xsd

1

There are 1 answers

0
Lonzak On

I had the same problem (only with the wsdl files). After long research I figured out that the problem was a case sensitivity issue - windows (local CLI and eclipse builds) and the linux/unix hudson/jenkins build environment:

The problematic wsdl had a big letter S

<wsdlOption>
 <wsdl>${basedir}/src/main/resources/Some.wsdl</wsdl>
</wsdlOption>

But on the filesystem the file was some.wsdl So it was not the path issue (.../workspace/...) as I also initially expected...