【问题标题】:cxf-codegen-plugin to exclude XSD filescxf-codegen-plugin 排除 XSD 文件
【发布时间】:2015-01-31 17:12:08
【问题描述】:

我使用 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>

但这假设我在构建之前知道那些命名空间,而我不知道(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

【问题讨论】:

  • 主要问题是,为什么相对路径在 Jenkins 中表现不同?它可以从命令行与 Maven 一起工作吗?
  • 我不确定,但据我了解,它使用 mvn 命令行控制台来构建项目
  • 我更新了我的问题以反映 Jenkins 的错误信息
  • 我要问的是 - 您是否尝试过在开发人员机器上的 CLI 中使用 Maven 构建项目?在与您在 Eclipse 中完全相同的项目中?问题是 - 如果 Jenkins 与 Eclipse 中的问题,或者命令行中的 Maven 与 Eclipse 中的 Maven 中的问题。
  • 我现在会告诉你

标签: maven jaxb wsdl cxf cxf-codegen-plugin


【解决方案1】:

我遇到了同样的问题(仅限 wsdl 文件)。经过长时间的研究,我发现问题是区分大小写的问题 - windows(本地 CLI 和 eclipse 构建)和 linux/unix hudson/jenkins 构建环境:

有问题的 wsdl 有一个大写字母 S

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

但在文件系统上,文件是some.wsdl 所以这不是我最初预期的路径问题(.../workspace/...)...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 2015-07-10
    • 2012-04-27
    • 2016-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多