Maven-将XSD作为依赖项 [英] Maven - Have an XSD as a dependency

查看:103
本文介绍了Maven-将XSD作为依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个项目来定义它使用XSD文件生成的消息格式.

We have one project that defines the message formats it produces with XSD files.

使这些XSD文件成为另一个项目的依赖项的最简单方法是什么?

What is the easiest way to make these XSD files as dependencies of another project?

我正在使用 maven-build-帮助程序attach-artifact 目标是附加我的XSD文件.

I was looking at using the maven-build-helper attach-artifact goal to attach my XSD files.

有更好的机制吗?

推荐答案

我不知道attach-artifact目标,但我做了您要求的操作.我有wsdl和xsd文件,可使用axis2编写Web服务工件及其客户端工件.

I don't know the attach-artifact goal but I did something like you asked for. I had wsdl and xsd files to write Webservice artifacts and its client artifacts with axis2.

  1. 我将wsdl和xsd放在一起 名为"wsdl"的项目 src/main/resources/META-INF和 没有其他的.
  2. 我做了一个自己的项目 为生成的命名为"soap" Java SOAP代码.在这个项目中,我 将wsdl项目添加为 依赖关系并解压缩wsdl和 xsd文件通过 maven-dependency-plugin到 目标文件夹中的 初始化阶段.所以我可以用它来 生成SOAP代码.
  3. 肥皂 我用作依赖项的项目 Webservice项目和 客户项目.
  1. I put my wsdl and xsd in an own project named 'wsdl' to src/main/resources/META-INF and nothing else.
  2. I made a own project named 'soap' for the generated Java-SOAP-Code. In this project I added the the wsdl project as dependency and unpacked the wsdl and xsd files via maven-dependency-plugin to the target folder in the initialize-phase. So I can use it to generate the SOAP-Code.
  3. The soap project I used as dependency for the Webservice project and for the client project.

我将所有这些项目都放在一个多模块项目中,以便可以将它们全部构建在一起. 我认为对您来说重要的是依赖项插件的配置:

I put all these projects to a multi module project so that I can build all together. I think the important part for you is the configuration of dependency-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>unpack-wsdl-dependency</id>
        <phase>initialize</phase>
        <goals>
          <goal>unpack</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <artifactItems>
        <artifactItem>
          <groupId>${groupId}</groupId>
          <artifactId>wsdl</artifactId>
          <outputDirectory>target/wsdl</outputDirectory>
          <includes>META-INF/*.wsdl,META-INF/*.xsd</includes>
        </artifactItem>
      </artifactItems>
      <!-- other configurations here -->
    </configuration>
  </plugin>

希望有帮助.

迈克尔的问候

这篇关于Maven-将XSD作为依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆