cxf-codegen-plugin to exclude XSD files

Refresh

December 2018

Views

1.4k time

2

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 answers

0

У меня была такая же проблема (только с WSDL-файлов). После долгих исследований я понял, что проблема была проблема с чувствительностью к регистру - окна (локальный интерфейс командной строки и затмение версии) и Linux / Unix / Hudson Дженкинс создания среды:

Проблематика WSDL был большой буквы S

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

Но в файловой системе файл был some.wsdl так это был не вопрос путь (... / рабочее пространство / ...) , как я изначально ожидал ...