- an Utility to synchronize all the Oracle Middleware jars to a local ( .m2/repository) or a shared repository like nexus or artifactory
- ojmake maven plugin for just building JDeveloper projects.
- Updated its Weblogic plugin for deploying artifacts or even creating new WebLogic domains, installing the WebLogic software or running WLST scripts.
- Coherence plugin for packaging.
- JDeveloper keeps its application & projects options in sync with the Maven application & projects poms. ( You don't need to lookup all the dependencies jars).
To get started we need to do the following.
first step is to configure the local Maven settings.
I start with making a maven.sh script or put these variables in the .profile of your build user or set all the windows environments variables which should contain the java_home and set the maven home to the Oracle Middleware Maven home.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
export M2_HOME=/Users/edwin/Oracle/JDevMiddleware12.1.2/oracle_common/modules/org.apache.maven_3.0.4
export PATH=${M2_HOME}/bin:${JAVA_HOME}:$PATH
mvn -v
We start by synchronizing the local or shared repository.
For this we need to install a plugin and need to configure the Maven settings.xml which is default located in the .m2 folder of your user home. You can update or create a new settings.xml
When you only use a local repository which located in the .m2 folder we need to do the following steps
1) Install the oracle maven sync plugin to your local repository
cd $ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2
mvn deploy:deploy-file -DpomFile=oracle-maven-sync.12.1.2.pom -Dfile=oracle-maven-sync.12.1.2.jar
2) Configure the settings.xml, you need to add the following xml snippet to the settings.xml. This will set all the required maven sync plugin parameters.
</profiles>
<profile>
<id>oracle-maven</id>
<properties>
<oracle-maven-sync.oracleHome>/Users/edwin/Oracle/JDevMiddleware12.1.2</oracle-maven-sync.oracleHome>
<oracle-maven-sync.testOnly>false</oracle-maven-sync.testOnly>
<oracle-maven-sync.failOnError>false</oracle-maven-sync.failOnError>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>oracle-maven</activeProfile>
</activeProfiles>
3) Test the plugin
mvn com.oracle.maven:oracle-maven-sync:help
You should see something like this
When you use a shared Maven repository like nexus or artifactory you need to set this in the settings.xml
1) A Maven mirror with the address of your shared Maven repository and provide all the repositories with its passwords
<servers>
<server>
<id>central</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>artifactory</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>internal</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<name>Internal artifactory Mirror of Central</name>
<url>http://hudson:8081/artifactory/repo</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://hudson:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://hudson:8081/artifactory/libs-snapshot</url>
</repository>
<repository>
<snapshots />
<id>internal</id>
<name>libs-snapshot</name>
<url>http://hudson:8081/artifactory/ext-release-local</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://hudson:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://hudson:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>oracle-maven</id>
<properties>
<oracle-maven-sync.serverId>internal</oracle-maven-sync.serverId>
<oracle-maven-sync.oracleHome>/Users/edwin/Oracle/JDevMiddleware12.1.2</oracle-maven-sync.oracleHome>
<oracle-maven-sync.testOnly>false</oracle-maven-sync.testOnly>
<oracle-maven-sync.failOnError>false</oracle-maven-sync.failOnError>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
<activeProfile>oracle-maven</activeProfile>
</activeProfiles>
2) Now we can install the sync plugin
cd $ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2
mvn deploy:deploy-file -DpomFile=oracle-maven-sync.12.1.2.pom -Dfile=oracle-maven-sync.12.1.2.jar -Durl=http://hudson:8081/artifactory/ext-release-local -DrepositoryId=artifactory
3) Test the plugin
mvn com.oracle.maven:oracle-maven-sync:help
The next step is to synchronize the Oracle Middleware home with the local or shared Maven repository
mvn com.oracle.maven:oracle-maven-sync:push
Update the maven catalog
mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml
With as result.
for more complete information how to do this, see this complete Oracle chapter
We are ready to create some JDeveloper projects with Maven as build tool
JDeveloper keeps the libraries in sync with the project libraries and the pom dependencies.
Also you can add a separate JUnit Test project to this pom, it will do all your unit tests and keeps the code outside your project.
Default this test project should contain JUnit 3 code ( no annotations ) else no test will be executed ( be aware of the Java Class Naming conventions ) .
For JUnit 4 tests you should add the JUnit 4 dependency to the pom.
We can also use the maven plugin to do WebLogic actions like appc, create-domain, deploy, distribute-app, install, list-apps, redeploy, start-app, start-server, stop-app, stop-server, undeploy, uninstall, update-app, wlst, ws-clientgen,ws-wsdlc, ws-jwsc
for more information see this Oracle documentation
No comments:
Post a Comment