Reputation: 12744
Is there a possibility to distinguish between multiple configurations of wsdl webservices in maven?
I have one application
which can run on test, stage and prod environments
. And I have to use one webservice. The webservice has 3 different wsdl locations
. For test, stage and prod.
Is there a way in maven to say if I want to build my application for prod just use the webservice location for prod. And the same also for stage and test?
I have a wsdl import configuration which works fine for a single non-dynamical part.
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>wsdlFile_live.wsdl</wsdlFile>
</wsdlFiles>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalDTD=all</vmArg>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<packageName>com.example.schema</packageName>
<wsdlLocation>http://liveLocation/?wsdl</wsdlLocation>
</configuration>
<id>wsimport-generate-_live.wsdl</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
Upvotes: 1
Views: 2652
Reputation: 12744
Creating profiles in maven is one possibility to build different applications with different scopes.
<profiles>
<profile>
<id>prod</id>
<build>
....
</build>
</profile>
<profile>
<id>test</id>
<build>
....
</build>
</profile>
</profiles>
In the profile property you can set dependencies, resourves, plugins, configurations and so on.
To build a specific profile you have to type mvn -P
followed by the profile ID
In my case it looks like this: mvn -Ptest clean install
or mvn -Pprod clean install
Upvotes: 2
Reputation: 1043
You can use environment variables to store your wsdl file and pass to maven system properties. For example, say on Linux you want to access environment variable MY_VARIABLE. You can use a system property in your pom file.
<properties>
...
<!-- Default value for my.variable can be defined here -->
<my.variable>foo</my.variable>
...
...
${my.variable}
Set the property value on the maven command line:
mvn clean package -Dmy.variable=$MY_VARIABLE
Upvotes: 1