Building a CI System With Java 9 Modules and Vert.x Microservices (JNNC Technologies)


Key Takeaways

  • Java 9 and Vert.x microservices are compatible for building applications
  • Many Java libraries are still not available as modules
  • Some care is needed with "automatic modules" (libraries not packaged as modules yet)
  • Java's built-in Nashorn Javascript environment is useful for scripting Vert.x applications
  • This article walks you through the design and development of a modern, responsive, resilient and message driven continuous integration (CI) system using the Eclipse Vert.x toolkit. We will leverage the Java Platform Module System (JPMS)––prototyped under Project Jigsaw––to construct the application from a host of loosely coupled modules that communicate over well defined interfaces.
    The intention is that JPMS should provide Java architects and developers with confidence that they can use modules to handle large legacy codebases as well as to create new applications. However, it’s not always easy to use existing Java libraries with the module system. So, along the way, we will talk about the various challenges encountered while working with the Java module system and the workarounds employed to get the system running.
    Let’s begin by defining the minimum viable product (MVP) of this new CI system, which we are going to build as a Docker native system. The product should provide the following core features as REST APIs:
    1. Support CRUD on repositories. A repository represents a project under version control. It specifies the connection details to either a git repository or a perforce depot.
    2. Support the “pipeline as code” philosophy. A pipeline defines the workflow to build code artifacts. Pipelines are defined in JavaScript. The script file can be stored along with your codebase in the source code repository.
    3. Provide an API to start and stop pipelines. An instance of a given pipeline is what constitutes a build.
    Now that we defined our MVP, we can go ahead and start building the system. The first step is to  create the project skeleton. We can use the IntelliJ multi module gradle project template for this purpose. Since we are going to use JDK 9, it would benefit us to use the latest and greatest gradle version (4.4.1 at time of writing). Seeing that we will be creating modular jars, we need to add the experimental jigsaw plugin and ensure that the source compatibility is set to Java 9. The project’s main “build.gradle” file should be similar to this snippet:
    Like most systems, ours will have a common core library that hosts entity objects, utility classes, shared constants, query parsers and so forth. Let’s define this core library as a Java 9 module.

Post a Comment

0 Comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();