Stuart winchester in Java 34 minutes

The Java Dependency Ecosystem

I decided to write about this when finding out from a number of graduates that they had not even heard of Maven, so this article aims to break down the basics so you can have a deeper understanding on how this stuff works..!

More or less every Java project in the real world relies on a dependency management system. I suspect as of writing that most use Maven, then Gradle, and falling hopefully in last place would be Ant. The main goal of each of these tools is to be able to assist the compilation, build, and even deployments of your codebase.

The basics

Many Java artifacts are stored with the following style artifactid-version.type, this example artifact could belong to nullendpoint.com, and therefore the groupid would likely be com.nullendpoint. By default a type is “.jar”. To reference this artifact in a maven pom.xml the following snippet could be used

<dependency>
	<groupid>org.apache.camel</groupid>
	<artifactid>camel-core</artifactid>
	<version>2.17.0.redhat-630187</version>
</dependency>

Maven will attempt to resolve the the artifact by looking at maven central and/or any mirors or repositories configured in the maven settings.xml or in the project pom.xml.

For example, https://maven.repository.redhat.com/ga/, based on the above dependency will attempt to resolve to https://maven.repository.redhat.com/ga/org/apache/camel/camel-core/2.17.0.redhat-630187/camel-core-2.17.0.redhat-630187.jar.

$repository/$groupid/$artifactid/$version/$artifactid-$version.$type