Marcelo Tataje
Marcelo Tataje

Reputation: 3871

Add WSDL URL from properties into pom

not sure if this question was already answered, but I've been looking in google and stackoverflow for a while and didn't find something for the requirement I need.

I have a pom.xml file in which I'm defining a property (which is a WSDL URL):

<properties>
    <service.wsdl.url>https://myservice.com/testservice.asmx?wsdl</service.wsdl.url>
</properties>

And then I have a plugin defined for web service components generation using wsimport:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>myservice</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlUrls>
                            <wsdlUrl>${service.wsdl.url}</wsdlUrl>
                        </wsdlUrls>
                        <packageName>com.myservice.generated</packageName>
                        <sourceDestDir>src/main/java</sourceDestDir>
                        <args>
                            <arg>-B-XautoNameResolution</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The question I have is on how can I get the URL from a properties file. I have a properties file called "application.properties" in my src/main/resources folder in which I have a key/value pair:

service.wsdl.url = https://myservice.com/testservice.asmx?wsdl

I'd like to do something like:

<properties>
    <service.wsdl.url>${service.wsdl.url}</service.wsdl.url>
</properties>

I've checking some answers and posts but as mentioned I was not able to find something for my needs.

Any help will be appreciated.

Thanks in advance!

Upvotes: 2

Views: 1263

Answers (1)

Naman
Naman

Reputation: 32028

You can probably make use of the properties-maven-plugin as:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0.0</version>
    <executions>
      <execution>
        <phase>initialize</phase>
        <goals>
          <goal>read-project-properties</goal>
        </goals>
        <configuration>
          <files>
            <file>src/main/resources/application.properties</file>
          </files>
        </configuration>
      </execution>
    </executions>
  </plugin>

Upvotes: 2

Related Questions