Monday, September 6, 2010

Maven: instructions on how to mavenize an EAR project

The project will consist of:
1) a EJB Module
2) a EJB Client
3) an EAR
4) some dependencies from external jars.


the POM.xml of the EJBModule is:



 4.0.0
 
  OSBCoherenceFacade
  net.acme.servicelayer
  1.1.0-SNAPSHOT
 
 MY_EJBProject
 MY_EJBProject

 
  
   log4j
   log4j
   1.2.16
   provided
  
  
   com.acme.cache
   coh-sl-wrapper-interop
  
  
   net.acme.servicelayer
   MY_EJBProjectClient
  
 





note the scope=provided, this aims at NOT including the JAR in the deployment, in case it's already available in the classpath.



The EJBClient is piece of cake:



 4.0.0
 
  OSBCoherenceFacade
  net.acme.servicelayer
  1.1.0-SNAPSHOT
 
 MY_EJBProjectClient
 MY_EJBProjectClient

 
  
   com.oracle.weblogic.modules
   javax.ejb
   3.0.1
   provided
  
  
   com.acme.cache
   coh-sl-wrapper-interop
  

 




while the real challenge is correctly configuring the EAR POM.xml



 
  OSBCoherenceFacade
  net.acme.servicelayer
  1.1.0-SNAPSHOT
 
 MY_EJBProjectEAR
 MY_EJBProjectEAR

 4.0.0
 MY_EJBProjectEAR
 ear

 
  
   info.politext.coherence
   coherence-serialization-support
   0.5.0
  
  
   com.acme.cache
   coh-sl-wrapper-interop
  
  
   com.acme.cache
   coh-sl-wrapper-lib
  
  
   com.tangosol
   coherence
   3.5.3.6
  
  
   net.acme.servicelayer
   MY_EJBProject  
   ${project.version}
   ejb
  
 


 
  
   
    maven-ear-plugin
    2.4.1
    
     ${basedir}/EarContent
     APP-INF/lib
      
      
       net.acme.servicelayer
       MY_EJBProject
       MY_EJBProject.jar              
      

     
    
   
 

  
 






The more I look into Maven, the more it seems to me horrific the amount of effort required even to setup a simple thing like an EAR. It's like going back to EJB 1.0... we have EJB 3.1, but the Maven still looks the same as 10 years ago.

No comments: