2个插件无法在Pom中同时工作

时间:2018-11-23 16:02:21

标签: java maven soap wsdl pom.xml

我在build标签下添加了2个插件,这两个插件的功能都是在目标文件夹下生成一些类。每当我尝试使用clean install maven应用程序时,默认情况下,目标每次都会清理,然后将新内容安装到目标文件夹中,这是理想的方法。

但是在以下代码中,仅当只有一个插件时才生成Java类。我必须手动注释任何一个插件,然后我需要安装maven目标,然后为单个插件生成Java类,对于第二个插件,我需要重复同样的事情。

 <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${project.build.directory}/generated-sources/somefolder</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>somefolder</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>myfirstwsdl.wsdl</wsdlFile>
                </wsdlFiles>
                <wsdlLocation>/WEB-INF/wsdl/*</wsdlLocation>
                <extension>true</extension>
                <target>2.2</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>wsimport</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>mysecondwsdl.wsdl</wsdlFile>
                </wsdlFiles>
                <wsdlLocation>/WEB-INF/wsdl/*</wsdlLocation>
                <extension>true</extension>
                <target>2.2</target>
            </configuration>
        </plugin>
    </plugins>
</build>

我的问题是,如何在不注释目标文件夹下的任何插件的情况下同时生成Java类?

1 个答案:

答案 0 :(得分:3)

您两次指定相同的插件,将无法正常工作。您需要像这样合并两者(在<configuration>内移动<execution>):

     <plugin>
        <groupId>org.jvnet.jax-ws-commons</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <executions>
            <execution>
             <id>somefolder</id>
             <phase>generate-sources</phase>
             <goals>
                <goal>wsimport</goal>
             </goals>
             <configuration>
               <wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
               <wsdlFiles>
                  <wsdlFile>myfirstwsdl.wsdl</wsdlFile>
                </wsdlFiles>
                <wsdlLocation>/WEB-INF/wsdl/*</wsdlLocation>
                <extension>true</extension>
                <target>2.2</target>
              </configuration>
            </execution>
            <execution>
                <id>wsimport</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>wsimport</goal>
                </goals>
                <configuration>
                  <wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
                  <wsdlFiles>
                    <wsdlFile>mysecondwsdl.wsdl</wsdlFile>
                  </wsdlFiles>
                  <wsdlLocation>/WEB-INF/wsdl/*</wsdlLocation>
                  <extension>true</extension>
                  <target>2.2</target>
              </configuration>
            </execution>
        </executions>
    </plugin>