Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Felix' Maven Implementation Experience

Fi0x edited this page Dec 1, 2020 · 4 revisions

Reason

Because we use multiple external libraries for the encryption, json-parsing and message creation, we needed a method to add these libraries to our project, without changing the project structure in the IDE every time. Maven enables us to add libraries that don't require a change in the IDE, which is perfect for multiple developers working on the same project.

Implemented

General structure

Maven can build our project and compile it as jar. To do so, maven requires the libraries our project uses to be installed. This is done with the dependencies and repositories we specified. We also use a proto file that we got from the wire-xenon repository on github to create the generic messages. This proto file is used to generate a "Messages" class in the generated sources folder from maven.

Build

To build our project properly, we require several plugins to be executed during the build process

  • maven-compiler-plugin: Used to select to which java version to compile
  • maven-jar-plugin: Selecting the main class of the project
  • maven-dependency-plugin: Copies dependencies to the target directory before creating the final jar. Also required to test the project in the IDE
  • protoc-jar-maven-plugin: Required to create a class out of the proto file we provide. The class gets saved in the generated-sources folder
  • maven-assembly-plugin: This plugin adds the dependencies that our program needs to the final jar. Without it the compiled jar would not run

Libraries

  • protobuf-java: Contains the structure we send as messages
  • json-simple: Used to parse json formatted Strings, which we mainly have in HTTP response and request bodies
  • cryptobox: Required to decrypt and encrypt every message we receive or send

Problems

  • Using maven disables us to test the program without installing all the dependencies that maven provides
  • If we need to add a new dependency or another repository, we have to change it in the maven file, which can be tricky sometimes, because not everything you need is added in the same way, like for example the proto file we use