25 February 2011

Using the “weblogic” prefix with the WebLogic Maven Plugin

The documentation for the WebLogic Maven Plugin describes a technique whereby the goals exposed by the plugin can be called using the short name (or prefix) weblogic

http://download.oracle.com/docs/cd/E17904_01/web.1111/e13702/maven_deployer.htm#DEPGD383

This means that instead of calling a goal using this form:

$ com.oracle.weblogic:weblogic-maven-plugin:help

You can use the much more convenient form of:

$ weblogic:help 

Sounds great.  However there is a documentation bug (logged and fixed for next release) which misses out one crucial step in the process. 

After extracting the pom.xml file from weblogic-maven-plugin.jar and editing it to specify the  <build> configuration that maps the plugin goalPrefix as weblogic;

And before
you issue the “mvn install:install-file –Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml”;

You first need to execute a simple “mvn install” command in the directory in which the pom.xml file resides;

Then you use the “mvn install:install-file ….” goal to install the weblogic-maven-plugin.jar file.

Blow by Blow

Let’s recap those steps:

  1. Generate the weblogic-maven-plugin.jar using the MW_HOME/wlserver_10.3/server/lib/wljarbuilder.jar file.

  2. Extract the pom.xml file from weblogic-maven-plugin.jar and copy/move it into the current working directory:

    $ jar xvf weblogic-maven-plugin.jar META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml

    $ mv META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml .

  3. Edit both ~/.m2/settings.xml and pom.xml to add the entries as described in the documentation:

    http://download.oracle.com/docs/cd/E17904_01/web.1111/e13702/maven_deployer.htm#BABGICBH

  4. Execute “mvn install” to initially configure the plugin in the Maven repository:

    $ mvn install

    ** Extra info: if you look at the ~/.m2/repository/com/oracle/weblogic directory, you should now see a file called maven-metadata-local.xml in which the weblogic-maven-plugin is defined and mapped to the prefix weblogic.  If you neglect this step, then this file is not created and the weblogic-maven-plugin is not able to be accessed using the weblogic prefix. 

  5. Execute “mvn install:install-file” to install the weblogic-maven-plugin.jar file into the repository, using the pom.xml to supply the coordinates:

    $ mvn install:install-file –Dfile=weblogic-maven-plugin.jar –DpomFile=pom.xml

With that one extra step done you should now be able to execute a weblogic-maven-plugin goal simply using the weblogic prefix. 

I find a quick test using weblogic:help is the easiest way to verify it is working correctly:

Screen shot 2011-02-25 at 3.21.23 PM

Not working?

It’s crucial that the additional “mvn install” step is performed before you install the actual weblogic-maven-plugin.jar library for this to work. 

If you have installed the weblogic-maven-plugin as documented and either now want to use the short-name or tried the short-name and it didn’t work, then what I’d suggest is that you blow away the ~/.m2/repository/com/oracle directory and start again from scratch.  That should get you a clean install in which the weblogic prefix is mapped correctly to the weblogic-maven-plugin. 

2 comments:

Anonymous said...

Thanks much.! That saved another 1 hour...

Buttso said...

No worries, glad it was of some help.

-steve-