Skip to main content

What is Apache Maven?



Apache Maven is a cool java project management tool that I recently came across at work. I was asked to set-up a test suite for our low latency Market Data System project using an existing test framework built using TestNG. I was handed over something called a pom.xml file and that was it! Using IntelliJ IDE you can import this pom.xml as a Maven project and everything is basically set-up for you. The folder structure is pretty standard in Maven so that every developer get the same same project structure. I think the main advantage of maven is that it is a great way of managing dependencies. Imagine that something changes in the the so called test framework. The framework developers update the repository and when I re-export the pom file updates the correct jar file will already be in my project. By changing the SNAPSHOT version of the pom.xml file I can switch through different versions of the test framework and other dependencies. Maven will first look for dependencies in the internal repository and then go for global repository to find the specified dependencies. You can set different configurations in the POM file, per user or globally using different settings files.

The other cool thing is the maven's ability to easily invoke TestNG test suites. Maven is reliant on plug-ins which are configured appropriately via the pom file. For example a maven project has a default life-cycle with different phases such as compile, test, package, deploy etc. Each plug-in can be configured with one or more goals to be executed. We call it a mojo. A mojo is a Maven plain Old Java Object!!! Each mojo is an executable goal in Maven, and a plug-in is a distribution of one or more related mojos. For example the test phase plug-in is called surefire.


For our work, we didn't really use all the life cycle phases of maven because we only really needed to run the TestNG test suite as the Market Data System was written in C++ and was running on back-end servers. Separate connections has to be made to these back-end via the test framework to enable testing. However it will be pretty cool if a fully fledged end-to-end project can be built for java based project with all the TestNG unit tests integrated and you can end up with deploying your jar to the client using the deploy plug-in! (Note that mvn-test in the image should point to test phase not package in the image)

Comments

Popular posts from this blog

Detaching a process from terminal - exec(), system(), setsid() and nohup

Linux processes are created by fork() and exec(). The very first process of POSIX systems is init and subsequent processes are derived from the init as parent. These subsequent processes are child processes. During forking the parent process copies itself - with all I/O, address space, stack, everything. The only thing that is different is the process ID. The parent and child will have 2 different process IDs. The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as follows: execl("/bin/sh", "sh", "-c", command, (char *) 0); system() returns after the command has been completed. system() executes a command specified in command by calling /bin/sh -c command , and returns after the command has been completed. During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.  system() calls are often made within programs to execut

Vaadin vs GWT

From Chapter 1 of book of Vaadin I quote the following. Vaadin Framework is a Java web application development framework that is designed to make creation and maintenance of high quality web-based user interfaces easy. Vaadin supports two different programming models: server-side and client-side . The server-driven programming model is the more powerful one . It lets you forget the web and program user interfaces much like you would program a desktop application with conventional Java toolkits such as AWT, Swing, or SWT. But easier. While traditional web programming is a fun way to spend your time learning new web technologies, you probably want to be productive and concentrate on the application logic. The server-side Vaadin framework takes care of managing the user interface in the browser and the AJAX communications between the browser and the server . With the Vaadin approach, you do not need to learn and deal directly with browser technologies, such as HTML or JavaScript.

C++ Callbacks using function pointers vs boost bind +boost function

In C, the most common uses of callbacks are as parameters to library functions like qsort , and as callbacks for Windows functions, etc. For example you might have a library that provides some sorting functions but you want to allow the library user to provide his own sorting function. Since the arguments and the return values do not change depending on the sorting algorithm, this can be facilitated in a convenient manner using function callbacks. Callbacks are also used as event listeners. onMouseClick(), onTerminalInput(), onData(), onConnectionStatus(), onRead() are probably some examples you've already seen in different libraries. The libraries have these callback functions and the users of the library are supposed to implement them. The library has a function pointer to these functions and calls them on their event loop which will invoke the code of the inherited classes of the library user. The implementation of function pointers is simple: they are just "code p