mavenapache-axiswsdl2code

axis2-wsdl2code-maven-plugin wsdl File in other Artifact


Given Dependency A with WSDL File a.wsdl under src/main/resources/wsdl I'd like to include it in Dependency B which has a compile dependency to A to generate the Axis Classes with

         <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>bar</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <generateServerSide>false</generateServerSide>
                        <packageName>com.foo</packageName>
                        <wsdlFile>/wsdl/a.wsdl</wsdlFile>
                        <databindingName>adb</databindingName>
                    </configuration>
                </execution>
            </executions>
        </plugin> 

when the a.wsdl is stored in Artifact B it works fine but moving it to A does not work the java.io.FileNotFoundException points to the wsdl Folder in Artifact B.

Is there a possibility to include wsdl Files which are in another Artifact as the axis2-wsdl2code-maven-plugin?


Solution

  • You could extract the WSDL file from artifact A during the build of artifact B:

    <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <goals>
                    <goal>unpack-dependencies</goal>
                </goals>
                <phase>generate-sources</phase>
                <configuration>
                    <includes>**/*.wsdl</includes>
                    <outputDirectory>${project.build.directory}/wsdl</outputDirectory>
                    <includeArtifactIds><artifact-a></includeArtifactIds>
                    <includeGroupIds><artifact-a-group-id></includeGroupIds>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>bar</id>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
                <configuration>
                    <generateServerSide>false</generateServerSide>
                    <packageName>com.foo</packageName>
                    <wsdlFile>${project.build.directory}/wsdl/extracted/path/to/a.wsdl</wsdlFile>
                    <databindingName>adb</databindingName>
                </configuration>
            </execution>
        </executions>
    </plugin>