DPML
Using Module Imports
HomeUtilitiesStationMetro
Using Module Imports

This tutorial introduces the use of external modules as a reliable method of declaring dependencies. In this example we are replacing the somewhere error-prone manual declaration of test-scope dependnecies with a single resource reference defined in an external module.

index.xml

The first update to our index file is the addition of a module import statement. The import statement is directing Depot to load a module defintion for the Ant system which contains information about Ant resources and their respective dependencies. The second change is the replacement of the manual uri-based dependency includes with a single resource reference to org/apache/ant/ant-junit. When Depot resolves the transitive dependencies it will take into account the dependencies declared by the ant/ant-junit resource resulting in a reliable and complete dependency set. We have also include the dpml module in the includes directive (mainly because the Transit core package includes a better log formatter than the default provided in the JDK).

<?xml version="1.0" encoding="ISO-8859-1"?>
<index xmlns="dpml:library">

  <imports>
    <import uri="link:module:ant"/>
    <import uri="link:module:dpml"/>
  </imports>

  <project name="demo" basedir=".">
    <properties>
      <property name="location" value="New York"/>
      <property name="message" value="Hello from ${user.name} in ${location}"/>
    </properties>
    <types>
      <type id="jar" alias="true"/>
    </types>
    <dependencies>
      <test>
        <include ref="org/apache/ant/ant-junit"/>
        <include ref="dpml/transit/dpml-transit-main"/>
      </test>
    </dependencies>
    <filters>
      <filter token="MESSAGE" value="${message}"/>
    </filters>
    <dependencies>

  </project>

</index>
Listing the expanded dependencies ...

The following command request a listing of our sample projects dependencies. The -expand commandline option is telling Depot that we want to see the fully expanded dependencies (i.e. the dependnecies that will end up in the test classloader).

$ cd tutorials\tooling\import
$ build -list -expand

Listing project: demo

project:demo#SNAPSHOT

  version: SNAPSHOT
  basedir: D:\dpml\tutorials\tooling\import
  types: (1)
    jar
  test providers: (6)
    resource:org/apache/ant/ant-launcher#1.6.5
    resource:org/apache/ant/ant-trax#1.6.5
    resource:org/apache/ant/ant-xslp#1.6.5
    resource:org/apache/ant/ant#1.6.5
    resource:junit/junit#3.8.1
    resource:org/apache/ant/ant-junit#1.6.5
    resource:dpml/transit/dpml-transit-main#SNAPSHOT
Summary

This tutorial has presented the benefits arising from the usage of modules - and in-effect, leveraging dependency information from external projects.