For one of my experiments I needed to develop a PGX client in Java, connection to a PGX server and performing a bunch of actions.
I remember that in the Tutorials page of PGX there was a full tutorial on how to build a PGX client application with Maven, which could make my life easier.

Oracle Maven repository for PGX is gone
Oracle Maven repository for PGX is gone


What is the benefit of Maven here? All the JARs required by the PGX client itself. For example if you download the PGX 3.2.0 Java Client ZIP the lib folder has 31 JAR files: some are Oracle own PGX specific libraries, others are public available packages.
It’s absolutely fine to manage all that by hand, to add all these JARs in the buildpath and manage things like that. Maven provides an even easier solution: a single dependency in your project and everything else is taken care automatically. No need to care or look which version of which file is used.

No more Oracle Maven for PGX

Sadly for me the tutorial didn’t work! After some debugging and making sure there wasn’t an authentication issue with the Oracle Maven repo, I posted on the ODC forum seeking for feedbacks (the thread is here: https://community.oracle.com/thread/4205246).
Six minutes later I got the answer …

Good catch: we are not publishing new versions of the client to that maven repo any more due to licensing reasons, we should have removed that page from the documentation from version 3.2.0.

We will remove it.

Well …
Not really helping me, I will need to switch back and manage all the dependencies by hand? Having to always extract all the files in the right place and make sure the buildpath is set correctly?
Sorry but although not being a Maven expert I believe there must be another way to do it!

Adding files to a local Maven repository

Over the 31 JARs included in the downloaded PGX 3.2.0 Java Client ZIP file, 5 are custom Oracle PGX packages, 26 are public available packages.
There are definitely a bunch of these which aren’t required for the client itself, but I’m not going to go there for now.

Google helped a lot in telling me how to import a JAR file into the local Maven repository and how to define the various dependencies.
Here are the steps to get Maven managing the PGX 3.2.0 Client packages for you automatically:

Import the 5 Oracle PGX JARs

First step is to add 4 of the 5 files without any special dependency, just load the JARs into the local Maven repository.
From the folder containing the JARs of the PGX client run these commands:

Names used for groupID, artifactId and version follow the tutorial which wasn’t working and the Maven standards.

Define dependencies in a POM file

Once these files are there the important step is to import the last one, the pgx-client-3.2.0.jar, and inform Maven of all the dependencies it has: the 4 JARs just imported above and the 26 coming from public online repositories (which Maven will download automatically when required).
All these things are defined into a POM file, in this case I named it pgx-client-3.2.0.pom as it’s the POM file (Project Object Model, an XML file being the fundamental unit of work in Maven) of that package.

To make it easier for you, here is the content of the file. Listing all the JARs included in the ZIP you download from the Oracle website.
Create a file named pgx-client-3.2.0.pom next to the pgx-client-3.2.0.jar.

Once the POM file is created, in the same folder as the pgx-client-3.2.0.jar file, the last step is to import this missing JAR with the POM file into the local Maven repository:

No need to care about dependencies anymore…

I can now add a PGX 3.2.0 client into any Maven project simply by adding a dependency on :
groupId=oracle.pgx
artifactId=pgx-client
version=3.2.0

Every other JAR will be automatically provided by Maven either by downloading them online or loading them from the local repository (which also contains the 5 PGX JARs not existing in any online repository).

No need to say it but …
Remember you can’t publish these 5 JARs, which aren’t available, in a public Maven repository online. There are licenses not allowing you to make that code public.

From the comments…

Davide Basilio Bartolini posted a great script in the comments. By mixing bash and python it looks into the JARs contained in the PGX Java Client ZIP and check if they comes with a POM file. If they do, the script extract the groupId, artifactId and version directly from there. This allows you to easily write your own pgx-client-3.2.0.pom file telling Maven all the dependencies (and searching online for those not found).
No need to say it works for any version if you update the value of PGX_VERSION in it.

As the formatting in comments is very limited and the script is 100% helpful I post it back here in full text (tried to attach a .sh file, WordPress got scared it could be harmful and kindly denied …).

Share This