Developing Adapters in Eclipse

improve this page | report issue

Overview

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.

Prerequisite:

  • 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.

Jump to

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

  1. To create a new adapter Maven project, select: File → New → Other… → Maven → Maven Project and click Next.

    Image showing how to create an adapter Maven project in Eclipse

  2. Provide project name and location.
    • Make sure the option to create a simple project is ticked off and click Next.

    Image showing how to create an adapter Maven project in Eclipse

  3. 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: com.ibm.mfp
      • Archetype Artifact Id: either adapter-maven-archetype-java, adapter-maven-archetype-http or adapter-maven-archetype-sql
      • Archetype Version: you can find the latest available version in Maven Central

    Image showing how to create an adapter Maven project in Eclipse

  4. Specify Maven project parameters.
    • Specify required Group Id, Artifact Id, Version and package parameters, and click Finish.

    Image showing how to create an adapter Maven project in Eclipse

Importing an existing adapter Maven project

To import the adapter Maven project, select File → Import… → Maven → Existing Maven Projects.

Image showing how to import an adapter Maven project to Eclipse

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:

  1. Select Run → Run Configurations…, right-click on Maven Build and select New.
  2. Provide a Name: “Maven deploy”.
  3. Set as a Goal: “adapter:deploy”.
  4. 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”.

Further reading

Learn how to debug Java code in adapters in the Testing and debugging adaters tutorial.

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on December 01, 2017