Custom Types

1.  What Are Custom Types?
2.  Type Definition Structure
3.  Properties Definition
4.  Target Templates
5.  Type Inheritance

1. What Are Custom Types?

Each Component specifies its Type. A Type is similar to a class, while a component is its instance. Invicta contains a few built-in Types (JAR, WAR, Libraries, etc.). These Types are simply XML files consisting of code that will be used in the dumping process. Invicta's framework allows easily creating your own additional types, either by extending existing ones (using the inheritance mechanism) or by developing new ones from scratch. 
Types are mainly ANT build script templates that consist of ANT targets. The template allows inserting project or component-specific information by accessing the data structures of the information processed from the project definition. 
Custom Types' XML files can be stored at any location; its location (file name or directory) simply needs to be added to Invicta's list of Type locations.

Return to top

2. Type Definition Structure

The XML files that define the Types have to comply with a DTD. To view the DTD defining the structure, click here.

XML structure:

invictaType   - A single required root element.

Attributes:

Elements:

Return to top

3. Properties Definition

Each Type may define multiple properties that act as class members. Target Templates may refer to the defined properties.

Attributes:

There are 4 types of properties:

Example:
<defineProperty type="component" name="compilation.debug"/>

Example
<defineProperty type="project" name="dist.dir" defaultValue="dist."/>

Examples:
<defineProperty type="general" name="src.dir" valueTemplate="%{componentDir}/%{value}" defaultValue="src"/> 
<defineProperty type="general" name="src.java.dir" valueTemplate="%{property;src.dir}/%{value}" defaultValue="java"/>

Return to top

4. Target Templates

Target Templates have the same definition structure of standard ANT targets, except having the body as a Template instead of an actual ANT build script code, and having type inheritance mode attributes. Target Templates are equivalent to class methods.

Attributes:

Standard ANT target attributes (see ANT documentation):

Inheritance mode attributes:

Target Template example:


 <targetTemplate name="compile" depends="init"><![CDATA[

     
<echo message="Compiling '%{componentName}'..." />
      <javac destdir="%{property;build.classes.dir}">
            <src path="%{property;src.java.dir}"/>
            <include name="%{property;src.java.filter}"/>
      </javac>

 ]]
></targetTemplate>

 

Return to top

5. Type Inheritance (Type Extension)

A Type may extend one or more existing types. This inheritance is similar to standard class inheritance (including multiple inheritance).
Specifying the Type or Types to extend is done using the attribute extends of the invictaType element. This attribute contains a comma-separated list of type names. For example: <invictaType name="MyType" extends="JAR, Test" ...>

When extending Types, conflicts may occur: properties with the same name but different values, targetTemplate with the same name but different content or settings.

Solving property conflicts: define in the new type a property with the conflicting name.

Solving targetTemplate conflicts:

Return to top