maven dependencies

Improving Maven's dependency:analyze... or not

Recently, my good friend Richard Fichtner advised using the mvn dependency:analyze command to get rid of declared but unused dependencies: There is another use case for mvn dependency:analyze It can show you the dependencies you use in your code but have not declared in your pom.xml. This works because you have a transitive dependency on your classpath. Either don't use the dependency or declare it.[image or embed]— Richard Fichtner 💻☕ (@richard.fichtner.dev) December 10, 2024 at 2:

ant maven gradle build

My final take on Gradle (vs. Maven)

I tweet technical content that I consider interesting, but the funny tweets are the ones that get the most engagement. I attended the JavaLand conference in March, stumbled upon the Gradle booth, and found this gem: Things have changed a lot 😂😂😂“When you can’t beat them, join them” pic.twitter.com/SnX3KN57o8— Nicolas Fränkel 🇪🇺🇺🇦🇬🇪 (@nicolas_frankel) March 22, 2023 Of course, at some point, a fanboy hijacked the thread and claimed the so-called superiority of Gradle. In this post, I

maven plugin pom

The Flatten Maven plugin

One of the Apache Maven committers recently wrote about their plans for Maven 5. I consider the following one of the most significant changes: In summary, we need to make a distinction between two POM types: the build POM, stored in the project source control, that uses v5 schema for build time, requiring a new Maven version able to use the new features associated to the new schema,the consumer POM, that is published to Maven Central in the good old v4 schema, so every past or future build t

maven build performance maven daemon docker buildkit

Faster Maven builds in Docker

Last week, I described different techniques to fasten your Maven builds. Today, I’d like to widen the scope and do the same for Maven builds inside Docker. Between each run, we change the source code by adding a single blank line; between each section, we remove all built images, including the intermediate ones that are the results of the multi-stage build. The idea is to avoid reusing a previously built image. Baseline To compute a helpful baseline, we need a sample project. I create

maven build performance maven daemon surefire

Faster Maven builds

Builds require a few properties, chief among them reproducibility. I would consider speed to be low on the order of priorities. However, it’s also one of the most limiting factors to your release cycle: if your build takes T, you cannot release faster than each T. Hence, you’ll probably want to speed up your builds after you’ve reached a certain maturity level to enable more frequent releases. I want to detail some techniques you can leverage to make your Maven builds faster i

jar assembly shade spring boot maven

Creating self-contained executable JARs

When your application goes beyond a dozen of lines of code, you should probably split the code into multiple classes. At this point, the question is how to distribute them. In Java, the classical format is the Java ARchive, better known as the JAR. But real-world applications probably depend on other JARs. This post aims to describe ways to create self-contained executable JARs, also known as uber-JARs or fat JARs. What is an executable JAR? A JAR is just a collection of class files. To be

maven logging log4j2 slf4j spring boot

Feedback on the Log4J2 hack in Spring Boot

Last week, I wrote a post that described how to hack the Maven dependency resolution system. I admit it was a dirty hack, it’s even in the post name. But I got it wrong. Thanks Stéphane Nicoll for pointing it out: "It boils down to excluding the spring-boot-starter-logging in every Spring Boot starter"Since you've put every in bold, I assume you meant it. That's actually wrong and not what the documentation states.Here is an example: https://t.co/JKgPXCh0Nb— Stéph

maven hack logging log4j2 slf4j spring boot

A dirty hack to ease the usage of Log4J2 in Spring Boot

Logging is one of the fundamental components of any application which runs in production. Yet, between performance and logging in critical environments, I’d favor the former. For that reason, modern logging frameworks should implement at least two requirements: Async appenders: the write operation shouldn’t be blocking the execution of the programLazy computation: the framework doesn’t run expensive computations until they are needed - or never if that’s the case. The fi

github actions continuous integration maven release management

GitHub Actions and Maven releases

I like GitLab a lot. Yet, there’s no denying that GitHub has become the de facto standard to host Open Source projects. With GitHub Actions, it’s now possible to implement entire Continuous Integration pipelines without leaving GitHub. In this post, I’d like to highlight how to release Maven artifacts using GitHub Actions. Maven prerequisites Before creating the CI pipeline - and running it, it’s necessary to configure the underlying Maven project. A quick Maven pr

spring devtools maven jib intellij idea tip

Spring DevTools with Jib and IntelliJ IDEA

I’ve been recently developing a Spring Boot application, and to speed up my development speed, I added Developer Tools as a dependency. By default, classes loaded in the HotSpot JVM can be updated only if the later runs in debug mode, and only for changes regarding method implementation. This means adding an attribute to an class requires a full restart. DevTools is an improvement over that. It works by tweaking the standard classloading mechanism: one classloader is dedicated to librar

maven build docker maintenance

Truly immutable builds

It sometimes happen that after a few years, an app is stable enough that it gets into hibernating mode. Though it’s used and useful, there are no changes to it and it happily runs its life. Then, after a while, someone decides to add some new features again. Apart from simple things such as locating the sources, one of the most important thing is to be able to build the app. Though it may seem trivial, there are some things to think about. Here are some advices on how to make apps that can

build maven polyglot

Polyglot everywhere - part 1

This is the era of polyglot! Proponents of this practice spread the word that you’ve to choose the language best adapted to the problem at hand. And with a single team dedicated to a microservice, this might make sense. My pragmatic side tells me it means that developers get to choose the language they are developing with and don’t care how it will be maintained when they go away…​ On the other hand, my shiny-loving side just want to try - albeit in a more controlled env

bintray maven

Better developer-to-developer collaboration with Bintray

I recently got interested in Spring Social, and as part of my learning path, I tried to integrate their Github module which is still in Incubator mode. Unfortunately, this module seems to have been left behind, and its dependency on the core module uses an old version of it. And since I use the latest version of this core, Maven resolves one version to put in the WEB-INF/lib folder of the WAR package. Unfortunately, it doesn’t work so well at runtime. The following diagram shows this situ

configuration maven spring

Spring profiles or Maven profiles?

Deploying on different environments requires configuration, e.g. database URL(s) must be set on each dedicated environment. In most - if not all Java applications, this is achieved through a .properties file, loaded through the appropriately-named Properties class. During development, there’s no reason not to use the same configuration system, e.g. to use an embedded h2 database instead of the production one. Unfortunately, Jave EE applications generally fall outside this usage, as the good

android genymotion gradle maven scala

Scala on Android and stuff: lessons learned

I play Role-Playing since I’m eleven, and me and my posse still play once or twice a year. Recently, they decided to play Earthdawn again, a game we didn’t play since more than 15 years! That triggered my desire to create an application to roll all those strangely-shaped dice. And to combine the useful with the pleasant, I decided to use technologies I’m not really familiar with: the Scala language, the Android platform and the Gradle build system. The first step was to design

ant build gradle maven

Stop the f... about Gradle

Stop the f… about #Spring & #Hibernate migrating to #Gradle. Repeat after me: "my project do NOT have the same requirements" #Maven— Nicolas Fränkel 🇪🇺🇺🇦🇬🇪 (@nicolas_frankel) July 16, 2013 This was my week’s hate, and I take full responsibility for every character in it. While that may seem like a troll, Twitter is not really the place to have a good-natured debate with factual arguments, so here is the follow up. Before going into full-blown rhetoric mode, let m

maven

Maven between different environments

As a consultant, I find myself in different environments in need of different configurations. One such configuration is about the Maven settings file. This file is very important, for it governs such things as servers, mirrors and proxies. When you have a laptop, switching from customer configuration to home configuration and vice versa when you change place quickly becomes a bore. When you have to handle more than one customer, it escalates a nightmarish and tangled configuration mess. In a fo

maven test

Re-use your test classes across different projects

Sometimes, you need to reuse your test classes across different projects. These are two use-cases that I know of: Utility classes that create relevant domain objects used in different modulesDatabase test classes (ans resources) that need to be run in the persistence project as well as the integration test project Since I’ve seen more than my share of misuses, this article aim to provide an elegant solution once and for all. Creating the test artifact First, we have to use Maven: I kn

css maven

Empower your CSS in your Maven build

People who know me also know I’ve interest in the GUI: that means I’ve sometimes to get my hands dirty and dig deep into stylesheets (even though I’ve no graphical skill whatsoever). When it happens, I’ve always questions regarding how to best factorize styles. In this regard, the different CSS versions are lacking, because they were not meant to be managed by engineers. A recent trend is to generate CSS from a source, which brings some interesting properties such as nesti

eclipse maven wtp

Why Eclipse WTP doesn't publish libraries when using m2e

Lately, I noticed my libraries weren’t published to Tomcat when I used a Maven project in Eclipse, even though it was standard war packaging. Since I mostly use Vaadin, I didn’t care much, I published the single vaadin-x.y.z.jar to the deployed WEB-INF/lib manually and I was done with it. Then, I realized it happened on two different instances of Eclipse and for the writing of Develop Vaadin apps with Scala, I used 3 different libraries, so I wanted to correct the problem.

maven

Maven doesn't suck, your POM does

Maven bashing is an all-time favorite: there are plenty of articles telling how Maven downloads the whole Internet, or how POMs are bloated and so on. While I agree that Maven could be perfected, I’m also aware that some (if not most) of its shortcomings are not intrinsic but are caused by (very) bad configuration. Worse, even if used correctly in your projects, problems sometimes come from third-party dependencies! You do not believe me? Well, two examples follow, from standard libraries

maven

Free eBook: Apache Maven 3 Cookbook

Dear readers, In order to celebrate the release of Apache Maven 3 Cookbook, Packt Publishing contacted me in order to hold a contest to grab a free copy of the eBook! To be frank, I haven’t a clue toward organizing a contest so the first three who send me a mail at nicolas at frankel dot ch with the subject 'Apache Maven 3 Cookbook' will be sent the eBook for free. Don’t waste your time: on your mark, ready, go! And thanks Packt for these gifts. Update[10h20]: Sorry folks, all

m2eclipse maven

Better Maven integration leads to unforeseen consequences (bugs)

This week, I was faced with what seemed an near-insuperable problem. I was called by one of my dev: as soon as he upgraded his Eclipse (or more precisely, our own already-configured Eclipse), he couldn’t deploy to Tomcat through WTP. Here are the steps I took to resolve the problem and more general thoughts about upgrading and tooling. The log displayed a ClassNotFoundException, one involving Spring. So, the first step is to look under the hood. Provided you used the default configuration

jboss maven repo1

Maven repositories in anger!

Every build systems worth his salt acknowledges Maven dependencies repository. Even those vehemently opposed to the way Maven does things, like Gradle, still uses repo1. Wait, repo1? If there was only repo1. But nowadays, every project publishes its artifacts in its own repository. For some providers, like SpringSource and JBoss, I think it may be for marketing reasons. But whatever the reasons are, it only makes the job of the enterprise repository manager harder, since he has to reference all

dry maven

DRY and skinny war

In this article, I will show you how the DRY principle can be applied when using the skinny war configuration of the maven-war-plugin. While packaging an EAR, it is sometimes suitable that all libraries of the different WARs be contained not in their respective WEB-INF/lib folders but at the EAR level so they are usable by all WARs. Some organizations even enforce this rule so that this is not merely desiarable but mandatory. Using Maven, nothing could be simpler. The maven-war-plugin documen

book maven

Maven The complete reference

This review is about Sonatype’s Maven: The complete reference by Tim O’Brien, John Casey, Brian Fox, Jason Van Zyl, Eric Redmond and Larry Shatzer. Disclaimer: I learned Maven from Sonatype’s site 3 years ago. I found it was a great tool to learn Maven. Now that I have a little more experience in the tool, I tried to write this review in an objective manner. Facts 13 chapters, 267 pages, free (see below)This book is intended for both readers who wants to learn Maven from scratch

effective maven

Apache Maven 2 Effective implementation

This review is about Packt’s Apache Maven 2 Effective Implementation by Maria Odea Ching and Brett Porter. Facts 12 chapters, 436 pages, 39.99$This book is intended for people that already have a good experience of Maven. The 'About Maven' part is as small as it can get, it is the opposite of what could be 'Maven for Dummies', where you learn to type mvn something.A good portion of the book is about tools that are part of the Maven ecosystem: Continuum for the CI part and Archiva for the

eclemma eclipse emma ide important m2eclipse maven necessary plugins spring testng top

Top Eclipse plugins I wouldn't go without

Using an IDE to develop today is necessary but any IDE worth his salt can be enhanced with additional features. NetBeans, IntelliJ IDEA and Eclipse have this kind of mechanism. In this article, I will mention the plugins I couldn’t develop without in Eclipse and for each one advocate for it. m2eclipse Maven is my build tool of choice since about 2 years. It adds some very nice features comparing to Ant, mainly the dependencies management, inheritance and variable filtering. Configuring