This page is for collecting best practices when using Maven in combination with JDeveloper ADF projects.
Maven Support in JDeveloper 11g
See OTN Forum thread
Maven Support in JDeveloper 11.1.1 .
Folder Structure
A
typical ADF project has a Model project and a ViewController project.
So, for example, you would have a folder structure similar to below:
Since the deliverable from an ADF project is an ear file, in the maven
way of working, it is recommended to have another artifact (module)
called "ear" alongside the Model and ViewController projects like below:
This "ear" folder need not be a part of the JDeveloper projects. It is a maven specific folder.
You will have to create the Maven script file pom.xml in all of the above folders.
To
avoid mixing design time files with files needed for building the
application, you can keep all files that are only needed for JDeveloper
design time in a separate jdeveloper folder outside of the Model and
ViewController projects:
- appname
- ear
- jdeveloper
- Model
- ViewController
You don't need a pom.xml file in the jdeveloper folder.
Now,
you will have to create the folder structure that suits maven.
Remember, you have no need to go into JDeveloper as yet. Following is
the maven suited folder structure you need to have in both the Model
and the ViewController folder before starting to use JDeveloper to
develop ADF components.
- Model/ViewController
- src
- main
- java
- resources
- webapp (only in ViewController)
- test
Project setup
There is a maven plug-in that will generate a JDeveloper project file for a maven structured project.
See info here:
http://www.oracle.com/technology/products/jdev/howtos/1013/maven/maven.html http://kingsfleet.blogspot.com/2008/12/jdeveloper-and-maven-2x.htmlIf
you want to use Maven with a JDeveloper ADF Fusion application using
the above mentioned folder structure, you can also follow the approach
below:
Let's assume you have a new empty folder for your new
JDeveloper application called [ApplicationHome]. Create new empty
JDeveloper projects (create all jpr's in [ApplicationHome]\jdeveloper,
not in Model or ViewController subfolder) with properties as follows:
- Model project:
- Project Source Paths - Java Source Paths: remove existing and add path to [ApplicationHome]\Model\src\main\java
- Project Source Paths - Output Directory: [ApplicationHome]\Model\target\classes
- Project Source Paths - Default Package: com.mycompany.appname.model
- Project Source Paths/Modelers - Model Path: [ApplicationHome]\jdeveloper\diagramMetaData
- Project Source Paths/Offline Database - Database Path: [ApplicationHome]\database\diagrams
- Technology Scope: ADF Business Components (and Java)
- ModelTest project:
- Project Source Paths - Java Source Paths: remove existing and add path to [ApplicationHome]\Model\src\test\java
- Project Source Paths - Output Directory: [ApplicationHome]\Model\target\test-classes
- Project Source Paths - Default Package: com.mycompany.appname.model
- Dependencies: Model.jpr
- Technology Scope: Java
- ViewController project:
- Project Source Paths - Java Source Paths: remove existing and add path to [ApplicationHome]\ViewController\src\main\java
- Project Source Paths - Output Directory: [ApplicationHome]\ViewController\target\classes
- Project Source Paths - Default Package: com.mycompany.appname.view
- (not
in 10g) Project Source Paths/ADFm Sources - ADFmSource directory:
remove existing and add path to
[ApplicationHome]\ViewController\src\main\java
- Project Source Paths/Modelers - Model Path: [ApplicationHome]\jdeveloper\diagramMetaData
- Project Content/Web Application - HTML Root Folder: [ApplicationHome]\ViewController\src\main\webapp
- Dependencies: Model.jpr
- 10g Technology Scope: JSF (and Java, and JSP and Servlets), XML, HTML, Web Services
- 11g Technology Scope: ADF Faces, ADF Page Flow, Java, JSP and Servlets, XML, HTML, Web Services
- ViewControllerTest project:
- Project Source Paths - Java Source Paths: remove existing and add path to [ApplicationHome]\ViewController\src\test\java
- Project Source Paths- Output Directory: [ApplicationHome]\ViewController\target\test-classes
- Project Source Paths - Default Package: com.mycompany.appname.view
- Dependencies: ViewController.jpr
- Technology Scope: Java
Running Maven commands from JDeveloper
Using Ant
To
run maven goals from JDeveloper you can use ant build files as wrappers
for maven goals. Who can provide a more detailed explanation how to do
this?
Using External Tools
Using JDeveloper's
feature of External Tools, you can run Maven commands on pom.xml files
from JDeveloper. You can get it to work by defining an external tool
for each specific maven command you may want to execute (like
mvn clean install) for all XML files. It will only make sense to run it on pom.xml files of course.
Prerequisite: (for Windows) create a file callBat.bat with the following contents:
cd %1
call %2 %3 %4 %5 %6Steps to use define the
- Include the pom.xml file in your JDeveloper project
- In JDeveloper, choose Tools | External Tools | New
- Tool Type = External Program
- Program Executable = callBat.bat
- Arguments = ${file.dir} mvn install
- Caption for Menu Items = mvn install
- Add Items to Menus: also check Navigator Context Menu
- Enabled = When Specific File Types are Selected => XML Document
- Test by right-clicking the pom.xml file and running mvn install. The log window should show the results.
Repeat this for every mvn command you wish, replacing
mvn install in the above steps by for example
mvn clean -Dmaven.test.skip=true install -o
Thanks to Sandra Muller for this page's content.