Architektur

Effective Use of Apache Maven in Oracle Fusion Middleware 12c – Part 2

The first part of this series dealed with how to populate the Oracle FMW libraries into a Maven repository. The second part will explain how to configure and use Maven in JDeveloper 12c. This includes create a new application/project based on archetypes and importing existing Maven projects.

Configure Apache Maven in JDeveloper 12c

1. Navigate in the main menu  to Tools > Preferences in JDeveloper 12c. Afterwards select the entry “Maven” in the preferences tree on the left side.

In this dialog it is possible to change the Maven version used by JDeveloper. JDeveloper delivers Maven in version 3.0.5. At the time of writing this article the latest Maven version available is 3.3.1. So change the version in this dialog when you would like to use features offered by the latests version of Maven.

Maven configuration in JDeveloepr 12c

2. Select Maven > Logging/Errors.
In this dialog configure color definitions for various Maven output settings. The color settings are used in the output window of JDeveloper, when Maven is running.

Maven configuration in JDeveloepr 12c

Example output from Maven when it runs inside JDeveloper. It uses the previously defined color settings, e.g. blue for “Info Output”.

Maven configuration in JDeveloper 12c

3. Select Maven > Phases/Goals.

This dialog allows to manage goal profiles and the corresponding Phases/Goals. The goal profile is displayed in the context menu activated when clicking on a pom.xml file.

Maven configuration in JDeveloepr 12c

Context menu opened when clicking on a pom.xml in a project. The menu shows the configured goal profile and defined phases/goals.

Maven goals in JDeveloper 12c

4. Select Maven > Repositories
Configure additional Maven repositories to find libraries and archetypes. Every functionality in JDeveloper 12c that lookup resources in a Maven repository uses only the repositories configured in this dialog! The configuration made in this dialog is independent from the configuration settings in the file settings.xml from Maven. However there exists two options which offers a kind of a synchronization mechanism:

When registering a new repository the option “Include in Settings XML” can be used to automatically add the new repository also to the settings.xml. Be in mind that when modifying the settings.xml it does not reflect these changes in JDeveloper!

Maven configuration in JDeveloper 12

The other option is “When a repository is added to a POM file, also add it to Preferences”. This enables to automatically add new repositories in JDeveloper configuration based on changes made in a pom.xml

Maven configuration in JDeveloper 12c

I don’t recommend using either of these two options. I prefer a clean separation between the JDeveloper configuration and settings.xml from Maven.

Typically you use a Maven repository manager like Artefactory or Nexus. The repository manager should be configured as repository in JDeveloper.

Note: When the repository is secured, it can’t be registered in JDeveloper! JDeveloper does’t provide the ability to specify the security credentials for a Maven repository. This was already confirmed by Oracle. Due to this also the Oracle Maven repository can be configured in JDeveloper.

5. Select Maven > Settings

Enables to specify various other Maven settings. For example you can define the location of the settings.xml file.

Create a new Maven project based on a archetype

Project templates in Maven are called archetypes. In this section the steps of creating a new application/project based on a Maven archetype in JDeveloper 12c will be explained.

1. Navigate in the main menu New > From Gallery, In the Categories pane select “Maven“ and the items pane select „Generate from Archetype”. Then click on <OK>

Create Maven project in JDeveloper 12c

2. Enter artifact and group Id. Define the right default package and afterwards click on the magnifier icon behind “Maven Archetype“

Create Maven project in JDeveloper 12c

3. Enter the word “soa” in the search field. Now the registered Maven repository will be search for archetypes containing “soa”. Select the SOA application archetype from Oracle. This archetype is only available when all FMW libraries are populated. Any archetype registered in a configured Maven repository can be used in this dialog!

Create Maven project in JDeveloper 12c

5. Enter the required archetype parameters and confirme the other dialogs from the wizard. Afterwards JDeveloper will start to create a new application and project based on the selected archetype.

Create Maven project in JDeveloper 12c

Afterwards JDeveloper starts Maven and prepares the appliation/project based on the selected archetype.

Create Maven project with JDeveloper 12c

Import a Maven project into JDeveloper 12c

A good approach is to design the build process independently from the IDE. Furthermore a long-term objective could be “let the developer use there preferred IDE”. Maven does support this objectives perfectly. However the Maven support within common IDE’s differs from IDE to IDE. In JDeveloper 12c it is necessary to import a Maven project before working on it. In this section the steps how to import a Maven project in JDeveloper 12c will be explained.

1. Navigate in the main menu New > Import and select “Maven project” in the Import dialog.

Import Maven project in JDeveloper 12c

2. Define the Root Directory and select the corresponding Maven project from the list of available projects. Also enable the option …

Import Maven project into JDeveloper 12c

3. Enter the name for the new application/project and start the import process.

The screen below shows a SOA project imported as Maven project into JDeveloper.

Import Maven project into JDeveloper 12c

Application/project of type soa successfully imported.  

Summary

The Apache Maven support in JDeveloper has been increased in this release. However a Maven project in JDeveloper already needs a workspace and project files. So synchronization issues between the JDeveloper files and Maven pom.xml can occur.

In the next part of this series I will describe the SOA Maven plugin in more detail, including MDS configuration etc.

Links

Oracle Maven Repository – Index now available – more to come by Mark Nelson