What's New in Speedment 3.0?
What's New in Speedment 3.0?
Read this article and learn more on how the new version of Speedment was modularized and how you can benefit from modularizing your own project.
Join the DZone community and get the full member experience.Join For Free
Take 60 minutes to understand the Power of the Actor Model with "Designing Reactive Systems: The Role Of Actors In Distributed Architecture". Brought to you in partnership with Lightbend.
What’s New in Speedment 3.0?
If you have followed my blog you know that I have been involved in the open-source project Speedment for a while. During the summer and fall, I have worked a lot with finishing up the next big 3.0.0 release of the toolkit. In this post, I will showcase some of the cool new features we have built into the platform and also explain how you can get started!
New Module System
The biggest change from the previous version of Speedment, and the one that took us most time to get right, is the new module system. If you have been following the progress of the new JDK 9 project Jigsaw, you will recognize this subject. Previously, Speedment consisted of one big artifact called com.speedment:speedment. In addition to this, we had a few minor projects like the speedment-maven-plugin and speedment-archetypes that made the tool easier to use. There was several issues with this design. First, it was very tedious to develop in it since we often needed to rebuild the entire thing multiple times each day and every build could take minutes. It was also not very plugin-friendly since a plugin had to depend on the entire code base, even if it only modified a small group of classes.
In 3.0 however, com.speedment is actually a multi-module pom-project with a clear build order. Inside it are groups of artifacts, also realized as multi-module projects, that separate artifacts based on when they are needed. We now have the following artifact groups:
- common-parent contains artifacts that are mature, reusable in a number of situations and that doesn’t have any dependencies (except on our own lightweight logging framework). Here you will find some of the core utilities of Speedment like MapStream and CodeGen.
- runtime-parent contains artifacts that are required by the end-user during the runtime of their application. We wanted to separate these into their own group to make sure that the final jar of the user’s app has as small footprint as possible.
- generator-parent contains artifacts related to the code generation and database analyzation parts of Speedment. These classes doesn’t require a graphical environment which is useful if you want to use Speedment as a general purpose code generator in a non-graphical environment.
- tool-parent contains all the artifacts used by the graphical Speedment tool. Here we put all our home-brewed JavaFX-components as well as resources like icons used by the UI.
- build-parent is a meta group that contains various artifacts that we build simply to make Speedment easier to use for the end user. Here we for an example have a number of shaded artifacts that you can use when you deploy your application on a server and the Maven Plugin that users use to launch Speedment as a Maven goal.
- plugins-parent is a whole new group where we put official plugins for Speedment that doesn’t quite fit into the general framework but that many users request. This makes it possible for us to automatically rebuild them in the general build cycle, making sure they are always up-to-date with the latest changes in the platform.
- archetypes-parent is a group of all the official Maven Archetypes for Speedment. This was previously a separate project but has now been lifted into the main project so that they can be automatically reinstalled every time Speedment is built.
All these groups are built in the same order as specified above. This makes it much easier to keep dependencies single-directional and the overall design of the system more comprehensive.
So How Do I Use It?
The beautiful thing is that you barely have to change a thing! We automatically build an artifact that is called com.speedment:runtime that you can depend on in your project. It contains transitive dependencies to the exact set of artifacts that are required to run Speedment.
<dependency> <groupId>com.speedment</groupId> <artifactId>runtime</artifactId> <version>3.0.1</version> <type>pom</type> </dependency>
When it is time for deployment, you simply replace this dependency with com.speedment:runtime-deploy and you will get a shaded jar with all the Speedment-stuff bundled together and ready to ship!
<dependency> <groupId>com.speedment</groupId> <artifactId>runtime-deploy</artifactId> <version>3.0.1</version> </dependency>
For more details about the new release, go to this official GitHub page and fork it!
Published at DZone with permission of Emil Forslund , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.