For many projects it might be desirable to use Apache Maven to update DataPower configuration or to upload files to a device.
This has several benefits:
This can be accomplished by invoking dpbuddy's Ant tasks using Maven's AntRun plugin.
Following is the example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<configuration>
<target xmlns:dp="antlib:com.myarch.dpbuddy">
<taskdef uri="antlib:com.myarch.dpbuddy"
resource="com/myarch/dpbuddy/antlib.xml">
<classpath>
<fileset dir="${dpbuddy.home}/lib" includes="*.jar"/>
</classpath>
</taskdef>
<dp:copy flatten="true">
<dpFileset prefix="service-wsdl" dir="${resourcesDir}" includes="**/wsdl"/>
</dp:copy>
</target>
</configuration>
</plugin>
Note how you can define a prefix for custom dpbuddy tasks as part of the "target".
You should be using Maven instead of Ant for managing properties, so "dpbuddy.home" and "resourcesDir" can be defined in the POM itself (or you can use properties plugin if you want storing properties in a separate file) :
<properties>
<resourcesDir>${project.build.sourceDirectory}/../resources</resourcesDir>
<dpbuddy.home>/home/dpbuddy</dpbuddy.home>
</properties>
You can use Maven profiles to define DataPower connection properties:
<profile>
<id>dev</id>
<properties>
<dp.username>user</dp.username>
<dp.password>EXAMPLE ONLY</dp.password>
<dp.domain>dev</dp.domain>
<dp.xmlmgm.url>https://10.0.0.1</dp.xmlmgm.url>
</properties>
</profile>
To execute our dpbuddy tasks simply run
mvn antrun:run -P dev
Note that we did not attach our configuration to any Maven phase; you can do it by defining the target as part of the plugin's "execution" element, there are numerous examples in the plugin's documentation.