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 PMF CLI. The adapter code can then be edited in any IDE, and later built and deployed using either Maven or the PMF 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.
Jump to
- Creating a new adapter Maven project
- Importing an existing adapter Maven project
- Building and deploying an adapter Maven project
Prerequisites
- First get familiarized with adapters by reading the Adapters tutorials.
- 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 instructions to add Maven support listed in the M2Eclipse.
Creating a new adapter Maven project
Follow the bellow instructions to either create a new adapter Maven project or import an existing one.
- To create a new adapter Maven project, select: File → New → Other… → Maven → Maven Project and click Next.
- Specify project name and location. Ensure that Create a simple project check box is not selected, and click Next.
-
Select or add the adapter Archetype. 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
oradapter-maven-archetype-sql
Archetype Version: You can find the latest available version in the Maven Central.
- Specify
Group Id
,Artifact Id
,Version
andpackage
(Maven project) parameters, and click Finish.
Importing an existing adapter Maven project
Follow the bellow instructions to import an existing one.
- 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 PMF CLI or from Eclipse. For more information, see 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 consistent development environment. From this window Maven or PMF 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.
- Specify a Name: “
Maven deploy
”. - Set as a Goal: “
adapter:deploy
”. - Click Apply, and then clcik 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 adapters tutorial.
▲