When you use Maven projects to create, deploy, test, and configure adapters, you benefit from Maven's simple project setup, efficient dependency management, and supported IDEs, such as IntelliJ and Eclipse.
Up-to-date Maven artifacts that support MobileFirst adapters are available at The Central Repository under the GroupId com.ibm.mfp. When you build a Maven project, Maven checks your pom.xml file to identify which dependency to download.
If your organization does not permit online access to The Central Maven Repository, your administrator must set up a local repository to hold and share MobileFirst artifacts. For more information, see Setting up an internal Maven repository for offline development.
When you create a new Java™ adapter, a Maven project with the following structure is produced:
When you create a new JavaScript adapter, a Maven project with the following structure is produced:
MobileFirst adapters contain three main artifacts, which are referenced in the pom.xml file:
adapter-maven-api contains the MobileFirst code and third-party dependencies that the adapter needs to compile properly.
adapter-maven-plugin is a Maven plugin that is used to build the adapter and deploy it. It is also used to pull and push adapter configuration. The plug-in is defined in the pom.xml as follows:
<plugin>
<groupId>com.ibm.mfp</groupId>
<artifactId>adapter-maven-plugin</artifactId>
<version>8.0.0</version>
<extensions>true</extensions>
</plugin>
The build goal creates the adapter file by zipping the relevant files from the project and adding the dependencies to the adapter file. The goal creates the adapter file in the target directory with the name <adapter-name>.adapter. The build goal runs automatically as part of the packaging phase of the Maven lifecycle.
The deploy goal deploys the adapter file to the server. To use this goal, ensure that the following values in your pom.xml file are correct.
<properties>
<!-- MobileFirst adapter deployment properties -->
<mfpfUrl>http://localhost:9080/mfpadmin</mfpfUrl>
<mfpfUser>admin</mfpfUser>
<mfpfPassword>admin</mfpfPassword>
<mfpfRuntime>mfp</mfpfRuntime>
</properties>
The parameter mfpfUrl is the URL to the server where the adapter is deployed. If you are using HTTPS as the protocol, the connection to the server is encrypted. The parameters mfpfUser and mfpfPassword are the user name and password of the administration service. The parameter mfpfRuntime defines the target runtime to deploy to.
For more information about deploying adapters with Maven, see Deploying JavaScript adapters and Deploying Java adapters.
mvn adapter:configpull [-DmfpfConfigFile =<path to file>]
mvn adapter:configpush [-DmfpfConfigFile=<path to file>]
<dependency>
<groupId>com.ibm.mfp</groupId>
<artifactId>mfp-security-checks-base</artifactId>
<version>8.0.0</version>
</dependency>
For more information about implementing custom security, see Security-checks implementation.