Maven:从jar中提取文件 [英] Maven: extract files from jar

查看:117
本文介绍了Maven:从jar中提取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发WebService的客户端应用程序,并且在jar中有相应的WSDL文件.

I'm developing a client application of a WebService and I have the corresponding WSDL file inside a jar.

我正在使用ant通过以下build.xml从wsdl生成Java代码:

I'm using ant to generate the java code from the wsdl with the following build.xml:

<project name="wsimport" default="wsimport" basedir=".">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />

  <target name="wsimport">
     <echo message="Starting wsimport"/>
     <mkdir dir="target/generated-sources/jaxws-wsimport"/>
     <wsimport
        wsdl="???"
        sourcedestdir="target/generated-sources/jaxws-wsimport"
        extension="true"
        verbose="true"
        target="2.0"
        xnocompile="true"
        catalog="src/jax-ws-catalog.xml"
        wsdlLocation="/MyWebService/MyWebServiceV1_0?wsdl">
        <binding dir="src/main/resources/bindings/v1_0" includes="*.xml"/>
        <xjcarg value="-XhashCode"/>
        <xjcarg value="-Xequals"/>
        <xjcarg value="-XtoString"/>
     </wsimport>

   </target>
</project>

如何从罐子中加载WSDL文件? WSDL引用了一个XSD,它也位于同一jar中.

How do I load the WSDL file from a jar? The WSDL references an XSD which is also in the same jar.

推荐答案

回答我自己的问题时,我使用的方法是从jar中提取文件.

Answering to my own question, the approach I used was to extract the files from the jar.

实际上,我使用maven来构建项目,并使用antrun插件从wsdl中生成源代码,因此我使用了maven-dependency-plugin从jar中解压缩文件:

Actually I use maven to build the project and the antrun plugin to generate the sources from the wsdl, so I used the maven-dependency-plugin to unpack the files from the jar:

            <!-- extract WSDL and XSD from dependency jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>my.company</groupId>
                                    <artifactId>my.artifact</artifactId>
                                    <version>1.0</version>
                                    <outputDirectory>${project.build.directory}/wsdl</outputDirectory>
                                    <includes>**\/*.xsd, **\/*.wsdl</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

这篇关于Maven:从jar中提取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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