Skip to content

Basic_Project_Template

Alexey Valikov edited this page Aug 31, 2017 · 1 revision

Basic Project Template

Introduction

Basic project template is intended to help users starting Hyperjaxb3 projects. This is a simple project templates which contains the prepared directory structure, build scripts (for Ant or Maven) and libraries (in case of Ant).

You can download the basic project template here

Usage

  • Unpack.
  • Put your schema (*.xsd) and binding files (*.xjb) into src/main/resources.
  • Put your XML samples (*.xml) into src/test/samples.
  • Run mvn clean install for Maven or ant clean install for Ant.
  • Check target directory for results.

Directory structure

Below is the directory structure of the basic project template.

  • src - source folder;
    • main - main source folder;
      • java - main Java sources folder;
      • resources - main resources folder;
    • test - test source folder folder;
      • java - test Java sources folder;
      • resources - test resources folder;
        • log4j.properties - Log4J properties used during the test;
        • persistence.properties - persistence properties used during the test;
      • samples - test samples folder;
  • lib (Ant only) - library folder;
    • *.jar (Ant only) - libraries;
  • pom.xml (Maven only) - Maven build file;
  • build.xml (Ant only) - Ant build file.

As noted above, the src/main/resources folder is used to store schema and binding files; src/test/samples is used for XML samples used during the roundtrip test.

Build phases

Both Maven and Ant builds execute the following build phases:

clean

This phase clean the project, removes the target directory.

generate-sources

During this phase JAXB schema compiler (XJC) together with Hyperjaxb3 XJC plugin generate source code in target/generated-sources/xjc.

compile

This phase compiles the main Java code in src/main/java and generated Java code target/generated-sources/xjc. Compiled code will be placed under target/classes.

test-compile

This phase compiles the test Java code in src/test/java. Compiled code will be placed under target/test-classes.

test

Executes unit tests from src/test/java and target/generated-sources/xjc. Basic project template instructs Hyperjaxb3 to generate XML-database rountrip test (unmarshall-save-load-marshall-compare) which is used to test if generated ORM annotations or mappings are functional.

Roundtrip test executed during this phase uses persistence properties from src/test/persistence.properties to configure the persistence provider. XML samples used for roundtripping are taken from the src/test/samples folder.

package

Packs the compiled code from target/classes and place the generated jar in the target directory.

Using a different JPA provider

Using a different database

Clone this wiki locally