Getting Oracle artifacts into a Maven environment

If you want to build an application to run on the Fusion Middleware platform, you may find that you want to use some Oracle provided JAR files in your build process.  These may be things like API’s (interfaces) that are needed to compile, or client libraries that need to be bundled into the deployable application, or perhaps tools that are needed during build time, e.g. WLST or appc.

If you are using Maven to manage your build, it would be ideal to be able to use Maven coordinates to reference these Oracle artifacts, just like you do for any other kind of dependency.  But Oracle does not provide POM files for these artifacts – so what can we do?

Maven provides the ability to load any artifact into a Maven repository and to give it a set of coordinates.  This means that you can easily add the Oracle provided artifacts to your own Maven repository, or to a shared repository in your environment (e.g. a Maven Repository Manager) so that they can be used by yourself and other developers.

Maven will even generate the POM file for you, so all you need to do is create the coordinates.  Normally coordinates follow the same reverse URL scheme that Java packages uses, but it might be a good idea not to use com.oracle in this case – as it is possible that Oracle might one day release their own POMs, and then you could have some name clashes.  So it is probably better to use a different name, you might add ‘custom’ for example.

Suppose you want to add the wlthint3client.jar into your Maven environment, and give it the following coordinates:

  • groupId: custom.com.oracle
  • artifactId: wlthint3client
  • versionId: 10.3.6

You could use a command like this (which would be entered all on one line):

mvn install:install-file 
    -Dfile=/fmwhome/wlserver_10.3/server/lib/wlthint3client.jar
    -DgeneratePom=true
    -DgroupId=custom.com.oracle
    -DartifactId=wlthint3client
    -DversionId=10.3.6
    -Dpackaging=jar

This will install the JAR into your local Maven repository.  You can use a different goal to install into a remote repository (like a Maven Repository Manager for example).  In this command you either need to give the repository URL in the url property, or specify the repositoryId the matches the repository definition in your Maven settings.xml.

mvn deploy:deploy-file
    -Dfile=/fmwhome/wlserver_10.3/server/lib/wlthint3client.jar
    -DgeneratePom=true
    -DrepositoryId=internal
    -DgroupId=custom.com.oracle
    -DartifactId=wlthint3client
    -DversionId=10.3.6
    -Dpackaging=jar

After running these commands, you will have this artifact in your Maven repository and you will be able to use it like any other artifact.  For example, to include it in a project as a dependency, you can just refer to it using its coordinates:

<dependency>
  <groupId>custom.com.oracle</groupId>
  <artifactId>wlthint3client</artifactId>
  <version>10.3.6</version>
  <packaging>jar</packaging>
</dependency>

Armed with this knowledge you could go and create POMs for any Oracle (or other) artifacts that you want to use in your build.  You could also create dependency hierarchies between them if you wanted or needed to.

About Mark Nelson

Mark Nelson is an Architect (an "IC6") in the Fusion Middleware Central Development Team at Oracle. Mark's job is to make Fusion Middleware easy to use in the cloud and at home, for developers and operations folks, with special focus on continuous delivery, configuration management and provisioning - making it simple to manage the configuration of complex environments and applications built with Oracle Database, Fusion Middleware and Fusion Applications, on-premise and in the cloud. Before joining this team, Mark was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

One Response to Getting Oracle artifacts into a Maven environment

  1. jvzoggel says:

    Reblogged this on Jan van Zoggel and commented:
    Nice explanation and necessary command examples from Mark Nelson on his blog RedStack how to get Oracle artifacts into a Maven repository and refer to these artifacts as a dependency during your builds.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s