我使用 cxf-codegen-plugin 在构建时使用 Maven 生成一系列 WS 客户端。这些 WSDL 使用相对路径引用一些 XSD 架构定义,如下所示:../someService/schema.xsd
现在,当我从 Eclipse 触发构造时,它可以正常工作,因为我的 XSD 文件位于正确的路径中。
但是当我从 Jenkins 启动构建作业时,它失败了,因为它似乎使用 Jenkins
工作空间作为构建的根。
我什至不知道你是否可以改变 Jenkins 的这种行为,但由于我无法控制我的 Jenkins
实例,我想知道的是 cxf-codegen -plugin
完全排除 XSD 处理,然后使用不同插件的不同执行阶段显式生成这些类。
我读过你可以这样做:
<defaultOptions>
<extraargs>
<extraarg>-nexclude</extraarg>
<extraarg>http://*.ws.cntxes.emprego.xunta.es</extraarg>
</extraargs>
</defaultOptions>
但这假设我在构建之前就知道那些 namespace ,而我不知道(WSDL 文件是使用 Maven 依赖插件从外部依赖项中获取的)。
我也试过:
<wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
<includes>
<include>
**/*.wsdl
</include>
</includes>
<excludes>
<exclude>
*.xsd
</exclude>
</excludes>
但这不起作用,插件只是不断地解析 XSD 文件并生成相关的类。
我是否缺少任何其他方法来阻止 XSD 文件的解析并仅处理 WSDL 定义?
编辑:这是 Jenkins
给我的错误:
[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)
它正在寻找 jenkins 工作区的根而不是 /var/lib/jenkins/workspace/MYPROJECT/myproject-webservice/src/main/resources/wsdl/xsd/schema.xsd
最佳答案
我有同样的问题(只针对 wsdl 文件)。经过长时间的研究,我发现问题是区分大小写的问题 - Windows(本地 CLI 和 eclipse 构建)和 linux/unix hudson/jenkins 构建环境:
有问题的wsdl有一个大字母S
<wsdlOption>
<wsdl>${basedir}/src/main/resources/Some.wsdl</wsdl>
</wsdlOption>
但是在文件系统上文件是 some.wsdl
所以这不是我最初预期的路径问题 (.../workspace/...)...
关于maven - cxf-codegen-plugin 排除 XSD 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27266651/