Break New Ground

More options for consuming Oracle JDBC drivers from Maven Central

Version of the Oracle JDBC drivers and related binaries have been recently posted to Maven Central. There are quite a good number of goodies and features found in this release, however, in terms of distribution things have changed for the better: POM files for all binaries are now available in minimal form (i.e. with their minimum set of required dependencies). Additionally, a BOM file has also been published, whose responsibility is to define the set of binaries that belong to the same release. If this were not enough the release also provides a set of POMs that include all dependencies required to fulfill certain scenarios; we call these scenarios "flavors". Allow me to demonstrate.

Previously to release you had to use dependency exclusions to limit the set of dependencies resolved by Maven when including the ojdbc8 or ojdbc10 JARs. This is no longer the case as the POM files for these and other dependencies have been minified. Here's a POM file for a project that consumes the ojdbc8 dependency

Resolving the dependency graph for this project results in the following output

As you can appreciate there's a single dependency and nothing more. This setup lets you micromanage dependencies as needed. If you happen to include several OJDBC dependencies then it might be a good idea to rely on the ojdbc-bom BOM file as it constraints dependencies to the set that belongs together. Let's take for example a project that requires ojdbc8 and ucp (the Universal Connection Pool) and xdb (XML type support); consuming these dependencies with the BOM can look like this

Resolving the dependency graph shows that chosen dependencies being selected

As you may know, the use of the <dependencyManagement> block allows versions of transitive dependencies to be set regardless of the location of said dependencies in the graph. This means that if your project integrates other dependencies that depend on OJDBC then those dependencies will match the versions set in the BOM you included.

Finally, the flavor POMs provide a predefined subset of dependencies given a particular scenario. For example, the ojdbc8-production POM delivers all dependencies required to connect to an Oracle database whether it's found on-premises or in the cloud (such as Autonomous Database). A project consuming this dependency would only need a few changes to its configuration files & properties to switch from on-premises to cloud and vice versa. Here's an example project that consumes this dependency

Resolving the dependency graph shows the following results

As you can appreciate now there are more options to configure a project that integrates with Oracle Databases. We expect the singular POMs, the BOM, and the flavor POMs to cover most cases. Of course, you can still tweak the consumed dependencies by means of explicit dependencies, dependency exclusions, and other Maven capabilities.

You can find more information about the all new POM files and their relationships at the Oracle JDBC Maven Central Guide. We welcome your feedback if any of these POMs does not fulfill the scenario you seek, please post a comment on this blog entry and/or let us know on Twitter @kmensah (Kuassi Mensah), @geraldvenzl (Gerald Venzl), @aalmiray (Andres Almiray).

Photo by Jignesh Makwana

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.