I have created an http adapter using mfpdev adapter create
but I found out the adatper.xml configuration file contains server connection configuration which I would like to change accordingly to dev,test,produciton
environment.
So I tried to use maven resource filter by changing the pom.xml as following
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.adapter</groupId>
<artifactId>MYAPIAdapter</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>adapter</packaging>
<name>MYAPIAdapter</name>
<properties>
<!-- Use UTF-8 as the encoding of the adapter -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- MobileFirst adapter deployment properties -->
<mfpfUrl>http://localhost:9080/mfpadmin</mfpfUrl>
<mfpfUser>admin</mfpfUser>
<mfpfPassword>admin</mfpfPassword>
<mfpfRuntime>mfp</mfpfRuntime>
</properties>
<dependencies>
<dependency>
<groupId>com.ibm.mfp</groupId>
<artifactId>adapter-maven-api</artifactId>
<scope>provided</scope>
<version>[8.0.0,9.0.0)</version>
</dependency>
<dependency>
<groupId>com.ibm.mfp</groupId>
<artifactId>mfp-security-checks-base</artifactId>
<version>[8.0.0,9.0.0)</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.ibm.mfp</groupId>
<artifactId>adapter-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
<filters>
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/adapter-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>pc</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>pc</build.profile.id>
</properties>
</profile>
<profile>
<id>sit</id>
<properties>
<build.profile.id>sit</build.profile.id>
</properties>
</profile>
<profile>
<id>uat</id>
<properties>
<build.profile.id>uat</build.profile.id>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<build.profile.id>prod</build.profile.id>
</properties>
</profile>
</profiles>
adapter.xml
<mfp:adapter name="MYAPIAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mfp="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>MYAPIAdapter</displayName>
<description>MYAPIAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol> ${connect.protocol}</protocol>
<domain> ${connect.domain}</domain>
<port> ${connect.port}</port>
<connectionTimeoutInMilliseconds> ${connect.timeout.ms}</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds> ${connect.sockettimeout.ms}</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode> ${max.concurrentconnections}</maxConcurrentConnectionsPerNode>
</connectionPolicy>
</connectivity>
<procedure name="getFeed"/>
<procedure name="unprotected" secured="false"/>
When I run mvn install
, I hit following error , seem like mfp maven plugin validate the adapter xml file. I have no problem running with mvn compile
and the adapter xml values is succesfully replaced with the values in properties file. Is there anyway to specify the configuration from properties file when building the mfp adapter?
ERROR] Failed to execute goal com.ibm.mfp:adapter-maven-plugin:8.0.2016082422:build (default-build) on project MYAPIAdapter: Adapter xml file schema validation encountered errors: [cvc-datatype-valid.1.2.1: '${connect.port}' is not a valid value for 'integer'., cvc-type.3.1.3: The value '${connect.port}' of element 'port' is not valid., cvc-datatype-valid.1.2.1: '${connect.timeout.ms}' is not a valid value for 'integer'., cvc-type.3.1.3: The value '${connect.timeout.ms}' of element 'connectionTimeoutInMilliseconds' is not valid., cvc-datatype-valid.1.2.1: '${connect.sockettimeout.ms}' is not a valid value for 'integer'., cvc-type.3.1.3: The value '${connect.sockettimeout.ms}' of element 'socketTimeoutInMilliseconds' is not valid., cvc-datatype-valid.1.2.1: '${max.concurrentconnections}' is not a valid value for 'integer'., cvc-type.3.1.3: The value '${max.concurrentconnections}' of element 'maxConcurrentConnectionsPerNode' is not valid.] -> [Help 1] [ERROR]