Developing Adapters in Eclipse
As taught in previous Adapters tutorials, adapters are Maven projects that are created by using either Maven directly or via the MobileFirst CLI. The adapter code can then be edited in any IDE, and later built and deployed using either Maven or the MobileFirst CLI. A developer may also choose to create, develop, build and deploy all inside a supported IDEs, such as Eclipse or IntelliJ. In this tutorial an adapter is created and built from the Eclipse IDE.
For instructions how to use IntelliJ see the Using IntelliJ to Develop MobileFirst Java Adapters Blog Post.
- Get familiarized with adapters by reading the Adapters tutorials first.
- Maven integration in Eclipse. Starting Eclipse Kepler (v4.3), Maven support is built-in in Eclipse. If your Eclipse instance does not support Maven, follow the m2e instructions to add Maven support.
- Creating a new adapter Maven project
- Importing an existing adapter Maven project
- Building and deploying an adapter Maven project
- Further reading
Create or import an Adapter Maven project
Follow the bellow instructions to either create a new adapter Maven project or import an existing one.
Creating a new adapter Maven project
To create a new adapter Maven project, select: File → New → Other… → Maven → Maven Project and click Next.
- Provide project name and location.
- Make sure the option to create a simple project is ticked off and click Next.
- Select or add the adapter Archetype.
- If you installed the archetypes locally and they are not appearing in the list of archetypes, select Configure → Add Local Catalog → Browse to the /.m2/repository/archetype-catalog.xml in the home directory.
- Click on Add Archetype and provide the following details:
- Archetype Group Id:
- Archetype Artifact Id: either
- Archetype Version:
8.0.2016061011(you can find the latest available version in Maven Central)
- Archetype Group Id:
- Specify Maven project parameters.
- Specify required Group Id, Artifact Id, Version and package parameters, and click Finish.
Importing an existing adapter Maven project
To import the adapter Maven project, select File → Import… → Maven → Existing Maven Projects.
Building and deploying an adapter Maven project
An adapter project can be built and deployed by using either Maven command-line commands, the MobileFirst CLI or from Eclipse.
Learn how to build and deploy adapters.
Tip: Eclipse can also be enhanced to ease the deployment step by integrating a Command-line window using a plug-in, creating a consistant development environment. From this window Maven or MobileFirst CLI commands can be run.
Building an adapter
To build an adapter, right-click on the adapter folder and select Run As → Maven install.
Deploying an adapter
To deploy an adapter, first add the deploy Maven command:
- Select Run → Run Configurations…, right-click on Maven Build and select New.
- Provide a Name: “Maven deploy”.
- Set as a Goal: “adapter:deploy”.
- Click Apply followed by clicking on Run to have an initial deploy.
You can now right-click on the adapter folder and select Run As → Maven Deploy
Building and deploying an adapter
You can also combine the “build” and “deploy” Maven Goals to a single “build and deploy” Goal: “clean install adapter:deploy”.
Learn how to debug Java code in adapters in the Testing and debugging adaters tutorial.▲