Wednesday, February 25, 2015

WebCenter Content - Component Development Tips and Tricks

Hey all,

There was recently a good discussion on the Oracle Forums about building components ( There was some discussion about different methods people use, but there was an idea to get together to build something useful for the community. I wanted to provide my method and utility.

I have an ant build script that serves two general purposes: create new components and build existing components. Let's first go over the parts and dependencies of the utility.

There are a few pieces expected by the utility:

  • build.xml
  • a "Template Component"
  • fart.exe
Yes, fart.exe.

Let's go ahead and get that one out of the way :)

FART stands for "Find And Replace Text command line utility". The ant script uses this to rename the files and directories inside the template component to whatever actual component name you're cloning.

You need to install that utility ( and update the build.xml to the correct path.

Next is the "Template Component". In order to create components for you to work with, there needs to be a template. this is the core structure of a component with the (more or less) universal defaults in place. This will be your starting point when you're creating a new component. pretty nice to be able to not have to remember the structure, bits, pieces, etc each time you create a new component, in my opinion.

Notice that the Template Component is under a directory called "Components", this will be the parent component for all of your Components for the project. you can separate comnponents into different directories per client or project or whatever, but you'll need to duplicate the build.xml as well. the build.xml and Components directory must be at the same level. Peak at the properties structure in the build.xml for more info.

Finally, the build.xml.

The build.xml has two targets: 'createnew' and 'all'. 

createnew will generate a new component structure for the component name provided. It looks like this when using eclipse to execute:

NewComponent is the name of your new component to be created. 

The default target is 'all', so in can be implied. that will look like this, if your component is named "SenaSampleManageMetadata"

The 'all' target does a few things:

Note that the build number is managed by this file: ${componentName} The build automatically increments the build number by one each time the build is executed. the date is also automatically updated.

The target also cleans the build directory, recreates it, the zips up the component (excluding svn assets).

NOTE: the compilation of the class files is not done by the script since this was originally used with eclipse. I used eclipse's auto-build to make sure the class files were always there when needed. This required modifying the build directory as follows:

Note that the expected structure is as follows:

java source:

Components/<Component Name>/component/<Component Name>/src

java classes:

Components/<Component Name>/component/<Component Name>/classes

The build.xml could easily be modified to include a subtask containing a java compilation job, if needed.

I have not used this with jdeveloper, but I expect it could be adapted to jdeveloper as well. I personally still use eclipse for building components, so I have not taken the time to attempt to adapt to jdev.

here is a link to the public repo housing this code:

Let me know what everyone thinks!