0

I am using wsImport to create java atrifacts from wsdl files. I have many wsdl files, as of now I am making multiple entries of wsimport plugin in pom for wsdl files which becomes messy.

Is it possible to add plugins to maven dynamically at run time? I am able to invoke maven commands from java with maven embedder and maven-invoker. I am also able to read pom using MavenXpp3Reader but completely unsure about updating pom on the fly.

1 Answers1

0

Try using the JAX-WS Maven Plugin instead.

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <target>2.1</target>
                <!-- use 2.2 for Java SE 8 or Java EE 6+ runtime -->
                <wsdlUrls>
                    <wsdlUrl>...</wsdlUrl>
                    <wsdlUrl>...</wsdlUrl>
                    <wsdlUrl>...</wsdlUrl>
                    ...
                </wsdlUrls>
            </configuration>
        </plugin>

Refer to the linked documentation for more configuration options.

Be aware that this generates source files in target/generated-sources/wsimport which get automatically added to the source files to be compiled by the maven-compiler-plugin.

Steve C
  • 18,876
  • 5
  • 34
  • 37
  • I want to put artifacts of different wsdls in different packages. Is there any way of adding wsdls to pom dynamically at run time? – user2779758 Jun 12 '17 at 06:49