Using the plugin is very easy. It has just to be called within the Maven project.
mvn com.cedarsoft.serialization.generator:serializer-generator-maven-plugin:generate \ -Ddialect=JACKSON -Ddomain.class.pattern=src/main/java/com/cedarsoft/MyDomainObject.java
Either add an entry to your
It might be a good idea to add that entry to your $user.home/.m2/settings.xml
<pluginGroups> <pluginGroup>com.cedarsoft.serialization.generator</pluginGroup> </pluginGroups>
Then it is possible to just call the plugin using
mvn serializer-generator:generate -Ddialect=STAX_MATE -Ddomain.class.pattern=src/main/java/com/cedarsoft/MyDomainObject.java
This plugin analyzes the source code of the domain object source file. It then creates a serializer and corresponding unit tests using some simple heuristics.
This serializers are placed in target/generated-sources/cedarsoft-serialization-main
The serializers are compilable and can be used immediately.
There are two unit tests generated for each serializer. They are placed in target/generated-sources/cedarsoft-serialization-test
Placeholder resources are generated in target/generated-sources/cedarsoft-serialization-test-resources
There just contain an XML fragment and should be filled when running the tests.
Two tests are generated for each serializer:
To avoid unnecessary manual work and encourage the creation of this test, those stubs are created immediately.
It is recommended to define the plugin version for each plugin. Therefore that section should be added to the pom.xml:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.cedarsoft.serialization.generator</groupId>
<artifactId>serializer-generator-maven-plugin</artifactId>
<version>4.1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>