Chapter 3. Organizing your Project

Table of Contents

3.1. Overview
3.2. Update the Parent Module
3.3. Create a new Maven submodule for JPA Service (Repository) Implementations
3.4. Reference the JPA Applib from the DOM Project
3.5. Reference the JPA Service (Repository) Implementations from the fixture Project
3.6. Reference the JPA Runtime from the "App" Project
3.7. Alternative Approach

This chapter provides advice on how to organize your project so that you can set up dependencies in Maven. Alternatively, you might want to run the Maven archetype - as described in Appendix A, Using the Maven Archetype. This sets up the same general project structure as described in this chapter, though some of the details as to how dependencies are resolved varies from the approach described below. See Section 3.7, “Alternative Approach” for more details.

3.1. Overview

If you ran the Naked Objects archetype then you'll have a Maven parent module with a number of child modules:

xxx/pom.xml
    xxx-dom/pom.xml          # domain object model
    xxx-fixture/pom.xml      # fixtures for seeding object store
    xxx-service/pom.xml      # in-memory object store implementations of repositories
    xxx-commandline/pom.xml  # for deploying as a commandline, also for prototyping
    xxx-webapp/pom.xml       # for deploying as a webapp

Using JPA Objects means writing new repository implementations which will depend on JPA Objects. In order to isolate those dependencies, we recommend that you create a new Maven submodule:

xxx/pom.xml
    xxx-dom/pom.xml          
    xxx-fixture/pom.xml      
    xxx-service/pom.xml      
    xxx-service-jpa/pom.xml  # JPA object store implementations of repositories
    xxx-commandline/pom.xml  
    xxx-webapp/pom.xml       

In addition, the dom and fixture projects also need updating, the dom project to reference the JPA Objects' applib and the fixture project in order to use the new JPA service implementations.