This documentation is for WSO2 Developer Studio version 3.7.0. View documentation for the latest release.
Using Maven with Developer Studio - Developer Studio 3.7.0 - WSO2 Documentation
||
Skip to end of metadata
Go to start of metadata

This page describes how to use Maven with Developer Studio. It includes the following sections:

Maven support for deployable artifacts

A pom.xml file is automatically generated for each project created in Developer Studio. This file allows you to build the project using Maven. To build individual deployable artifacts using Maven, go to the project location in the command line and run the command mvn clean install.

One or more of the following deployable artifacts are then created under the target folder of your project location:

Artifact typeProject type
Apache Axis2 ArtifactAxis2 Archive [aar]
Web ApplicationWeb Application Archive [war]
JAX-WS ArtifactJava Archive [jar]
Endpoint Artifactxml
Sequence Artifactxml
Proxy Service Artifactxml
Local Entry Artifactxml
Synapse Configurationxml
Message Storexml
Message Processorxml
ESB MediatorJava Archive [jar]
Registry ResourceRegistry Resource with necessary meta-data
Registry Handler ArtifactOSGI Bundle [jar]
Registry Filter ArtifactOSGI Bundle [jar]
Data Service ArtifactData Services Descriptor file [dbs]
Data Services Validator ArtifactOSGI Bundle [jar]
BPEL WorkflowBPEL Archive [zip]
GadgetDashboard Archive [dar]
Complex Event Processor Artifactxml
Business Rule Server ArtifactAxis2 Archive [aar]
Carbon UI BundleOSGI Bundle [jar]
Third Party Library ArtifactOSGI Bundle [jar]
Composite Application ProjectComposite Application Archive [CAR]

CAR Deploy plug-in

You can generate a CAR file for your Composite Application Project (C-App) and deploy it to one or more servers at once using the CAR Deploy plug-in for Maven. For more information, see Deploying a C-App to multiple servers using the Maven plug-in

Working with Maven Multi Module projects

Developer Studio creates separate projects and a separate Maven pom.xml file for most deployable artifacts. In Maven-centric development, however, you have a parent project and some child modules, including a separate distribution module that is a child module of the parent project. To achieve this model, you can create a Maven Multi Module Project in your workspace, create your artifact projects nested within it, and then create the Composite Application Project for the distribution module. You can also convert an existing project to a Maven Multi Module Project.

Creating a New Maven Multi Module Project

To create a new Maven Multi Module project, take the following steps:

  1. In Developer Studio, click File -> New -> Project.
  2. In the New Project wizard, expand WSO2 -> Maven Project, click Maven Multi Module Project, and then click Next.
  3.  In the Maven Information Settings dialog box, provide Maven information such as GroupID, ArtifactId (also becomes your project name), and Version, and then select the modules to include in project by selecting their projects from the list. Click Finish.

You can now open pom.xml to see the selected projects that are listed as Maven modules.

Convert an existing project to a Maven Multi Module project

To convert an existing project to a Maven multi module project, take the following steps:

  1. Right-click the project and click Generate POM.
  2. Select the modules to include in project by selecting their projects from the list, and then click Finish.

Synchronizing dependencies between Eclipse and Maven

When you are working with software projects in Eclipse, you often need to refer to third-party libraries in your project. Because your source code is using the APIs and utilities exposed by these libraries, you must add them to the Eclipse project classpath (project buildpath) as dependencies to prevent compilation errors in the Eclipse IDE. If you are using Maven as your build tool, you must add these same libraries as Maven dependencies in your Maven pom.xml file. Likewise, if you want to use a Maven project in Eclipse, you need to synchronize the Maven dependencies with the Eclipse project. Developer Studio provides a simple way to synchronize the dependencies, as described in the following sections:

Update the POM file with dependencies from the Eclipse project

You can update your project's Maven pom.xml file with the current set of third-party libraries in your Eclipse project buildpath. If you add another third-party library to your Eclipse project buildpath, right-click the project and click Maven -> Sync Project Dependencies with pom.xml. The POM file will now contain the dependency you added to your Eclipse project.

Update an Eclipse project with dependencies from a POM file

If you want to open a Maven project in Eclipse and continue development, or if your existing Eclipse project maintains its dependencies in a pom.xml file, you can run the command mvn eclipse:eclipse in the Maven eclipse goal against your project to generate your project descriptors or update existing project descriptors. This feature requires that you create a WSO2 Maven project using Developer Studio 3.0.0 or later. You must also use Eclipse M2Eclipse 1.2 or later and Apache Maven 3.0.* or later.

For example, let's assume you have a WSO2 Maven project called CustomMediator where you have only source files and a Maven pom.xml file. Take the following steps:

  1. In a command prompt/shell, go to the file system location of your Maven project, and then enter themvn eclipse:eclipse command as described in the Maven eclipse goal . The Maven project is built as shown in the following image.
  2. In Developer Studio, if the current perspective is not Java EE, click Window -> Open Perspective -> Other -> Java EE.
  3. Click File -> Import.
  4. In the Import wizard, expand WSO2, click Existing WSO2 Projects into workspace, and click Next.
  5. Click Browse and specify the Maven project location in the file system. When you specify the location, Eclipse automatically scans the file system, locates all the projects, and displays them under Projects.
  6. Select the project and click Finish.

You can now open your project and continue development in Eclipse.

Maven Release plug-in

You can use the Maven Release plug-in to package and release your Developer Studio projects. For complete information, see the Maven Release Plug-in page on the Apache website.

  • No labels