Tuesday Jul 23, 2013

Java EE 7 Maven Repository Coordinates

For those of us doing Java EE development with Maven (which by my own account as a former consultant is pretty much all Java EE/GlassFish adopters), getting our hands on the repository location for Java EE APIs is critically important. Fortunately, Java EE APIs have long been available via Maven central, Java EE 7 is no exception. The Java EE 7 Maven Coordinates on the GlassFish wiki is an extremely handy reference for navigating the Maven Central maze.

It also helps to know that there is a relatively well established set of guidelines for naming Java EE API Maven artifacts. Generally speaking, Java EE Maven artifacts follow this pattern:

<dependency>
    <groupId>[Java EE API package name]</groupId> 
    <artifactId>[Java EE API package name]-api</artifactId>
    <version>[Java EE API version]</version>        
</dependency> 

For the most part though, this is the only Maven coordinate you should need for Java EE 7 applications:

<dependency>
    <groupId>javax</groupId> 
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>        
</dependency>

If you are using just the Web Profile, you should use this instead:

<dependency>
    <groupId>javax</groupId> 
    <artifactId>javaee-web-api</artifactId>
    <version>7.0</version>        
</dependency>

That being said, for those of you that need/want them, the GlassFish wiki outlines where you can find the Maven artifacts for just Java EE concurrency, JPA 2.1, JAX-RS 2, Servlet 3.1, EL 3.0, JMS 2, JSF 2.2, EJB 3.2, JBatch, JSON-P, WebSocket and others.

It should be pretty straightforward to use - give me a shout if you need help setting up Maven.