Showing posts with label MAVEN. Show all posts
Showing posts with label MAVEN. Show all posts

Saturday, 27 December 2014

Create 12c SOA Application and SOA Project by using Maven


Create SOA Application and SOA Project by using Maven

Prerequisite: Maven setup in Jdeveloper 12c

To use maven to create SOA application and SOA project we should setup maven in developer machine.

Step1: In cmd prompt, setup below env variables
                set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
                set PATH=%JAVA_HOME%\bin;%PATH%
                set ORACLE_HOME=D:\Fusion12C\Oracle\Middleware\Oracle_Home
                set M2_HOME=<ORACLE_HOME>\oracle_common\modules\org.apache.maven_3.0.5
                set PATH=%M2_HOME%\bin;%PATH%

Step2: Run below mvn cmd to create soa application and soa project.
mvn archetype:generate -DarchetypeGroupId=com.oracle.soa.archetype -DarchetypeArtifactId=oracle-soa-application -DarchetypeVersion=12.1.3-0-0 -DarchetypeRepository=local

Fill below details in CMD prompt:
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
Define value for property 'groupId': : com.test
Define value for property 'artifactId': : SOA12cApplicationWithMVN
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  com.test: :
[INFO] Using property: adf = .adf
[INFO] Using property: data = .data
Define value for property 'projectName': : SOA12cProjectWithMVN
Confirm properties configuration:
groupId: com.test
artifactId: SOA12cApplicationWithMVN
version: 1.0-SNAPSHOT
package: com.test
adf: .adf
data: .data
projectName: SOA12cProjectWithMVN
Y: :Y

NOTE: If first time you are running "generate" maven goal then you may get error says that "maven goal or respective POM file is not available in maven repositery". If you see this kind of error then execute below maven goal. Below mvn cmd will download all required mvn jar files and pom files.
--> mvn archetype:generate

Step3: If we observe physical folders where we created SOA application and SOA Project , we dont have .jws and .jpr files.
Step4: Now open SOA application in JDeveloper 12c by following below steps.





Now we can see SOA application and SOA project in Jdeveloper12c.
We can see .jws and .jpr files in physical file system.


Step5: Now we can implement required business logic in composite.

Step6: Once we create required business logic we can deploy soa project in to SOA server.
For deployment we can use traditional deployment process by using jdeveloper.
In this post i want to show you steps to deploy soa project with maven goal.

--> mvn pre-integration-test

NOTE: If you are using this mvn cmd first time then it will download all required prerequisite jars and pom files.

If you get this kind of error, then you have to modify project level pom file with required server properties as shown below.

Modify the server details in your project level pom file, in which server you want to deploy the program. I am using integrated SOA server in JDeveloper so i provided local host details, you should provide as per your server environment.

NOTE:
Project level pom file available in "<mywork>\<application name>\<project name>\pom.xml"

Now run the mvn cmd to deploy SOA project.
--> mvn pre-integration-test

Step7: We can see deployed soa project in enterprise manager.




Maven Set up in JDeveloper 12C

Maven Set up in JDeveloper 12C

Prerequisites : First we should install JDK 1.7 and JDeveloper 12.1.3.0.0

Step1: open cmd prompt

Step2: set environment variables in cmd prompt
        set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
        set PATH=%JAVA_HOME%\bin;%PATH%
        set ORACLE_HOME=D:\Fusion12C\Oracle\Middleware\Oracle_Home
        set M2_HOME=<ORACLE_HOME>\oracle_common\modules\org.apache.maven_3.0.5
        set PATH=%M2_HOME%\bin;%PATH%
NOTE: set the variables as per your machine.

Step3: Now we need a way to get the necessary artifacts into developers machines local Maven repository. Oracle provides the Maven Synchronization plug-in for this. So now we need install the plugin to local maven repository by using below MVN cmd.

mvn install:install-file -DpomFile=oracle-maven-sync.12.1.3.pom -Dfile=oracle-maven-sync.12.1.3.jar

NOTE:
"oracle-maven-sync-12.1.3.jar" and "oracle-maven-sync-12.1.3.pom" are available in below location.
These two files comes with JDev12c installation at below location.
%ORACLE_HOME%/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/



Step4: Next step is to execute the plugin in order to import the Oracle Maven artifacts, including the Parent POM necessary for deploying our SOA composite.

mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=D:/Fusion12C/Oracle/Middleware/Oracle_Home



NOTE: After completing execution of above command now we can see Parent POM in below location.
C:\Users\Fusion\.m2\repository\com\oracle\soa\orabpel\12.1.3-0-0
Parent POM file Name : orabpel-12.1.3-0-0.pom
we can use this file as parent for all pom.xml files which created along with SOA 12c projects.
In this file we can store global parameters like deployment server, user and password. Of-course we can discuss this in my next post.



Thats it, now maven is ready in your machine to execute MVN cmd's.

Maven Life cycle:
--> mvn validate
Ensure that the project is correct and all necessary information is available.
--> mvn compile
Compile the source of the project
--> mvn test
Test the compiled source code using a suitable unit testing framework; tests should not require the code to be packaged or deployed.
--> mvn package
Take the compiled code and package it in its distributable format, such as a JAR, WAR, EAR, SAR, or GAR files.
--> mvn integration-test
Process and deploy the package, if necessary, into an environment where integration tests can be run.
--> mvn verify
Run checks to verify whether the package is valid and meets quality criteria.
--> mvn install
Install the package into the local repository for use as a dependency in other projects locally.
--> mvn deploy
For the final release, copy the final package to a remote repository for sharing with other developers and projects.

By using mvn we can execute maven archetypes like below.
--> mvn archetype:generate
To create a SOA application and SOA Project with required SOA package structures and ID's.
--> mvn pre-integration-test
To deploy all soa projects in SOA application.

Few more maven goals and archetypes are available, we can discuss them in my next post.