Skip to Content.
Sympa Menu

notify-dpml - r1379 - in trunk/main: . central/src/docs/about/download central/src/docs/depot central/src/docs/depot/library central/src/docs/depot/tools central/src/docs/metro central/src/docs/transit depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info station/exec

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1379 - in trunk/main: . central/src/docs/about/download central/src/docs/depot central/src/docs/depot/library central/src/docs/depot/tools central/src/docs/metro central/src/docs/transit depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info station/exec
  • Date: Tue, 18 Apr 2006 20:09:22 +0200

Author: mcconnell
Date: 2006-04-18 20:09:02 +0200 (Tue, 18 Apr 2006)
New Revision: 1379

Added:

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/BuilderError.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ProcessorDirective.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
Removed:
trunk/main/depot/tools/builder/etc/prefs/xmls/processors.xml

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultProcessor.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Workbench.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractBuildListener.java
Modified:
trunk/main/central/src/docs/about/download/archive.xml
trunk/main/central/src/docs/depot/library/index.xml
trunk/main/central/src/docs/depot/navigation.xml
trunk/main/central/src/docs/depot/tools/index.xml
trunk/main/central/src/docs/metro/navigation.xml
trunk/main/central/src/docs/transit/navigation.xml
trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml
trunk/main/depot/tools/builder/etc/prefs/xmls/configuration.xml

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultWorkbench.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Context.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/GenericTask.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/InitializationTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java

trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
trunk/main/library.xml
trunk/main/station/exec/build.xml
Log:
depot enhancements supporting configurable listeners and processors

Modified: trunk/main/central/src/docs/about/download/archive.xml
===================================================================
--- trunk/main/central/src/docs/about/download/archive.xml 2006-04-17
01:12:05 UTC (rev 1378)
+++ trunk/main/central/src/docs/about/download/archive.xml 2006-04-18
18:09:02 UTC (rev 1379)
@@ -25,7 +25,10 @@

<ul>
<li>Module name processing enhanced to support composite
names.</li>
- <li>Resolution of redundant property assertions in exported
modules.</li>
+ <li>Removal of redundant property assertions in exported
modules.</li>
+ <li>Depot builder structural enhancements.</li>
+ <li>Addition of configurable project listeners.</li>
+ <li>Addition of configurable processors.</li>
</ul>

<table>

Modified: trunk/main/central/src/docs/depot/library/index.xml
===================================================================
--- trunk/main/central/src/docs/depot/library/index.xml 2006-04-17 01:12:05
UTC (rev 1378)
+++ trunk/main/central/src/docs/depot/library/index.xml 2006-04-18 18:09:02
UTC (rev 1379)
@@ -109,7 +109,25 @@
<import file="station/module.xml"/>
<import file="planet/module.xml"/>

- <project name="central" basedir="central"/>
+ <project name="central" basedir="central">
+ <filters>
+ <feature token="VERSION" id="version"/>
+ <feature token="ANT-JAR-VERSION" ref="ant/ant" id="version"/>
+ <feature token="ANT-JAR-URI" ref="ant/ant" id="uri" type="jar" />
+ <feature token="TRANSIT-TOOLS-URI"
ref="dpml/transit/dpml-transit-tools" id="uri" type="jar" />
+ <feature token="TRANSIT-MODULE-VERSION" ref="dpml/transit"
id="version"/>
+ <feature token="TRANSIT-HANDLER-URI"
ref="dpml/transit/dpml-transit-main" id="uri" type="jar" />
+ <feature token="DEPOT-MODULE-VERSION" ref="dpml/depot"
id="version" />
+ <feature token="DEPOT-CONSOLE-URI"
ref="dpml/depot/dpml-depot-console" id="uri" type="jar" />
+ <feature token="DEPOT-TOOLS-ANT-URI"
ref="dpml/depot/dpml-tools-builder" id="uri" type="part" />
+ <feature token="DEPOT-TOOLS-LIBRARY-URI"
ref="dpml/depot/dpml-library" id="uri" type="jar"/>
+ <feature token="METRO-RUNTIME-URI"
ref="dpml/metro/dpml-metro-runtime" id="uri" type="part"/>
+ <feature token="METRO-TOOLS-URI"
ref="dpml/metro/dpml-metro-tools" id="uri" type="part"/>
+ <feature token="UTIL-CLI-URI" ref="dpml/util/dpml-util-cli"
id="uri" type="jar" />
+ <feature token="UTIL-I18N-URI" ref="dpml/util/dpml-util-i18n"
id="uri" type="jar"/>
+ <feature token="UTIL-LOGGING-API-URI"
ref="dpml/util/dpml-logging-api" id="uri" type="jar"/>
+ </filters>
+ </project>

</module>


Modified: trunk/main/central/src/docs/depot/navigation.xml
===================================================================
--- trunk/main/central/src/docs/depot/navigation.xml 2006-04-17 01:12:05
UTC (rev 1378)
+++ trunk/main/central/src/docs/depot/navigation.xml 2006-04-18 18:09:02
UTC (rev 1379)
@@ -26,7 +26,7 @@

<menu>
<item name="Overview" href="concepts/index.html"/>
- <item name="XML Directive" href="library/index.html"/>
+ <item name="Library Directive" href="library/index.html"/>
<item name="Builder" href="tools/index.html"/>
<item name="Ant" href="tasks/index.html"/>
<item name="CLI" href="cli/index.html"/>

Modified: trunk/main/central/src/docs/depot/tools/index.xml
===================================================================
--- trunk/main/central/src/docs/depot/tools/index.xml 2006-04-17 01:12:05
UTC (rev 1378)
+++ trunk/main/central/src/docs/depot/tools/index.xml 2006-04-18 18:09:02
UTC (rev 1379)
@@ -14,7 +14,7 @@
<p>
The Depot Library <a href="../cli/index.html">CLI handler</a> will
resolve a builder plugin using the property
<tt>project.builder.uri</tt>.
- The Depot Builder Plugin is an example of a build system based on the
+ The Depot-on-Ant-Builder Plugin is an example of a build system based
on the
Apache Ant product. The plugin class
<tt>net.dpml.tools.impl.StandardBuilder</tt>
handles the establishment and configuration of a Ant Project using
information
from a <a href="../library/projects.html">project</a> definition. The
plugin
@@ -31,19 +31,19 @@
template</a> build file. Templates are resolved using the
<tt>project.template</tt>
property which defaults to the value of the
<tt>project.standard.template</tt>
property. If neither property is defined, the default template
- <tt>local:template:dpml/tools/standard</tt> will be assigned.
+ <tt>local:template:dpml/tools/standard</tt> is assigned.
</p>

<p>
During project initialization the the current resource is consulted
with
respect to the types it declares it produced. Each type is identified
by a
unique type id. The collection of type ids are used to resolve an
ordered array
- of build listeners. The build listener list is established based on
the initial
- type ids combined with any dependencies declared by respective
listeneners.
+ of build processors. The build processor list is established based on
the initial
+ type ids combined with any dependencies declared by respective
processors.
Finally, the sorted listeners are attached to the current ant project.

Targets in the project template trigger init, prepare, build, package,
test and
- install build events which in-turn trigger sequentially executed
phased
- build-functionality.
+ install build events which in-turn trigger the execution of sequential
build phase
+ functionality (such as jar creation, etc.).
</p>

<subsection name="Builder Configuration">
@@ -54,30 +54,70 @@

<pre>local:xml:dpml/tools/config</pre>

- <p>
- <i>
- Please note that the configuration scheme is not final.
- </i>
- </p>
+<source><![CDATA[
+<builder default="install">
+
+ <listeners>
+ <listener name="standard"
class="net.dpml.tools.impl.StandardBuildListener"/>
+ </listeners>

+ <processors>
+ <processor name="jar" class="net.dpml.tools.process.JarProcess"/>
+ <processor name="part" class="net.dpml.tools.process.PluginProcess"
depends="jar"/>
+ <processor name="module" class="net.dpml.tools.process.ModuleProcess"/>
+ </processors>
+
+</builder>
+]]></source>
+
<p>
- The builder configuration currently contains a set of
<tt>&lt;listener&gt;</tt>
- declarations. A <tt>&lt;listener&gt;</tt> definition allows the
association of a
- collection of properties, a codebase uri, and listener dependencies,
- with a named type. The <tt>type</tt> represents an artifact produced
- as a result of applying a specialized build listener to a project with
- the objective of building the declared type.
+ The builder configuration contains a set of <tt>&lt;listener&gt;</tt>
and
+ <tt>&lt;processor&gt;</tt> declarations. A <tt>&lt;listener&gt;</tt>
definition
+ allows the association of a plugin-based build listener to an Ant
project.
+ Processor declarations allow associating of plugins to handle specific
datatypes.
+ Using information for the Depot library, listeners and processors
provide the
+ bulk of the common build functionality. Further customization may be
added under
+ a build.xml file or via supplimentary processors.
</p>
+
+ </subsection>
+
+ <subsection name="Builder Attributes">
+
+ <table>
+ <tr>
+ <td>default</td>
+ <td>The default build target.</td>
+ </tr>
+ </table>

</subsection>
-
- <subsection name="XML Attributes">

+ <subsection name="Nested elements">
+
<table>
<tr>
+ <td>listeners</td>
+ <td>0..n</td>
+ <td>
+ A sequence of build listeners.</td>
+ </tr>
+ <tr>
+ <td>processors</td>
+ <td>0..n</td>
+ <td>
+ A sequence of build processors.</td>
+ </tr>
+ </table>
+
+ </subsection>
+
+ <subsection name="Listener Attributes">
+
+ <table>
+ <tr>
<td>name</td>
- <td>The name of the type produced by the processor (e.g. 'jar'
or 'part').
- The value is required.</td>
+ <td>The listener name.</td>
</tr>
<tr>
<td>uri</td>
@@ -90,40 +130,39 @@
<tr>
<td>depends</td>
<td>A optional series of listener names (comma separated) that
this listener
- is dependent upon. The implementation ensurea that listeners
- are synchronized with respect to dependency ordering.</td>
+ is dependent upon. The implementation ensures that listeners
+ are synchronized with respect to dependency ordering whan
attached to
+ an Ant project.</td>
</tr>
</table>

</subsection>
+
+ <subsection name="Processor Attributes">

- <subsection name="XML Nested elements">
-
<table>
<tr>
- <td>property</td>
- <td>0..n</td>
- <td>
- A <a href="../properties/index.html">property</a> associating
a
- property <tt>name</tt> and <tt>value</tt> with
- the listener definition.</td>
+ <td>name</td>
+ <td>The name of the type produced by the processor (e.g. 'jar'
or 'part').</td>
</tr>
+ <tr>
+ <td>uri</td>
+ <td>A plugin codebase uri.</td>
+ </tr>
+ <tr>
+ <td>class</td>
+ <td>Processor classname.</td>
+ </tr>
+ <tr>
+ <td>depends</td>
+ <td>A optional series of processor names (comma separated) that
this processor
+ is dependent upon. The implementation ensures that processors
+ are synchronized with respect to dependency ordering.</td>
+ </tr>
</table>

</subsection>
-
- <subsection name="Default Configuration">
-<source><![CDATA[
-<builder>
- <listeners>
- <listener name="jar" class="net.dpml.tools.process.JarProcess"/>
- <listener name="plugin" class="net.dpml.tools.process.PluginProcess"
depends="jar"/>
- <listener name="module" class="net.dpml.tools.process.ModuleProcess"/>
- </listeners>
-</builder>
-]]></source>
- </subsection>
-
+
</section>

</body>

Modified: trunk/main/central/src/docs/metro/navigation.xml
===================================================================
--- trunk/main/central/src/docs/metro/navigation.xml 2006-04-17 01:12:05
UTC (rev 1378)
+++ trunk/main/central/src/docs/metro/navigation.xml 2006-04-18 18:09:02
UTC (rev 1379)
@@ -26,7 +26,7 @@

<menu>
<item name="Overview" href="concepts/index.html"/>
- <item name="XML Directive" href="directives/index.html"/>
+ <item name="Directives" href="directives/index.html"/>
<item name="Runtime" href="runtime/index.html"/>
<item name="Ant" href="tasks/index.html"/>
<item name="CLI" href="cli/index.html"/>

Modified: trunk/main/central/src/docs/transit/navigation.xml
===================================================================
--- trunk/main/central/src/docs/transit/navigation.xml 2006-04-17 01:12:05
UTC (rev 1378)
+++ trunk/main/central/src/docs/transit/navigation.xml 2006-04-18 18:09:02
UTC (rev 1379)
@@ -26,7 +26,7 @@

<menu>
<item name="Overview" href="concepts/index.html"/>
- <item name="XML Directive" href="parts/index.html"/>
+ <item name="Part Directive" href="parts/index.html"/>
<item name="Protocols" href="technical/index.html"/>
<item name="Setup" href="setup/index.html"/>
<item name="Ant" href="tasks/index.html"/>

Modified: trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-04-18 18:09:02 UTC (rev 1379)
@@ -23,29 +23,25 @@
<transit:plugin uri="@PROJECT-URI@">
<antlib urn="dpml:depot" resource="net/dpml/tools/tasks/antlib.xml"/>
</transit:plugin>
-
+
<target name="init">
<x:init/>
</target>

- <target name="prepare" depends="init">
- <x:prepare/>
+ <target name="clean" depends="init">
+ <delete dir="${project.target.dir}"/>
</target>

+ <target name="prepare" depends="init"/>
+
<target name="build" depends="prepare"/>

<target name="package" depends="build"/>

<target name="test" depends="package"/>

- <target name="install" depends="test">
- <x:install/>
- </target>
+ <target name="install" depends="test"/>

- <target name="clean" depends="init">
- <delete dir="${project.target.dir}"/>
- </target>
-
<target name="checkstyle" depends="prepare">
<property name="checkstyle.dir"
location="${project.target.reports.dir}/checkstyle"/>
<property name="checkstyle.data"
location="${checkstyle.dir}/checkstyle.xml"/>

Modified: trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml 2006-04-17
01:12:05 UTC (rev 1378)
+++ trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml 2006-04-18
18:09:02 UTC (rev 1379)
@@ -4,13 +4,17 @@
Default configuration for Depot-on-Ant.
-->

-<builder>
-
+<builder default="install">
+
<listeners>
- <listener name="jar" class="net.dpml.tools.process.JarProcess"/>
- <listener name="part" class="net.dpml.tools.process.PluginProcess"
depends="jar"/>
- <listener name="module" class="net.dpml.tools.process.ModuleProcess"/>
+ <listener name="standard"
class="net.dpml.tools.impl.StandardBuildListener"/>
</listeners>

+ <processors>
+ <processor name="jar" class="net.dpml.tools.process.JarProcess"/>
+ <processor name="part" class="net.dpml.tools.process.PluginProcess"
depends="jar"/>
+ <processor name="module" class="net.dpml.tools.process.ModuleProcess"/>
+ </processors>
+
</builder>


Modified: trunk/main/depot/tools/builder/etc/prefs/xmls/configuration.xml
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/xmls/configuration.xml
2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/depot/tools/builder/etc/prefs/xmls/configuration.xml
2006-04-18 18:09:02 UTC (rev 1379)
@@ -7,57 +7,6 @@

<configuration>

- <phases>
-
- <phase name="preparation">
- <!--
- Convert the client's codebase into a normalized form
- suitable for automated construction.
- -->
-
- <invoke id="prepare-etc"/>
- <invoke id="prepare-main"/>
- <invoke id="prepare-test"/>
- <invoke id="prepare-docs"/>
-
- </phase>
-
- <phase name="construction" depends="preparation">
- <!--
- For all published types - construct the data suitable for
- subsequent packaging.
- -->
-
- <select>
- <invoke key="build"/> <!-- aka build-jar, build-part, etc -->
- </select>
-
- </phase>
-
- <phase name="packaging" depends="construction">
- <!--
- For all published types - package the constructed data
- into a single deliverable file.
- -->
- </phase>
-
- <phase name="validation" depends="packaging">
- <!--
- For all published types - validate the packaged deliverable
- if the deliverable exists and a validation procedure is know.
- -->
- </phase>
-
- <phase name="installation" depends="validation">
- <!--
- For all published types - generate a validated deliverable.
- -->
- </phase>
-
- </phases>
-
-
-
<processes>

<process name="setup">
@@ -183,16 +132,13 @@
</process>

<process name="install">
-
<description>
-
For all of the resources declared by the project defintion - copy
the resource under the target deliverables directory to the working
cache. The process validates that all resource declared as produced
by
the project are present within the deliverables directory prior to
initating a cache update.
</description>
-
<consumes>
<ref id="target.deliverables"/>
<select type="*"/>

Deleted: trunk/main/depot/tools/builder/etc/prefs/xmls/processors.xml
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/xmls/processors.xml
2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/depot/tools/builder/etc/prefs/xmls/processors.xml
2006-04-18 18:09:02 UTC (rev 1379)
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!--
-Default configuration for Depot-on-Ant.
-Status: work-in-progress
--->
-
-<configuration>
-
- <phases>
-
- <phase name="init">
-
- <process name="setup">
- <produces>
- <dir path="${basedir}/etc" name="etc"/>
- <dir path="${basedir}/src" name="src"/>
- <dir path="${basedir}/target" name="target"/>
- <dir path="${etc}/main" name="etc.main"/>
- <dir path="${etc}/test" name="etc.test"/>
- <dir path="${etc}/prefs" name="etc.prefs"/>
- <dir path="${etc}/bin" name="etc.bin"/>
- <dir path="${etc}/deliverables" name="etc.deliverables"/>
- <dir path="${etc}/docs" name="etc.docs"/>
- <dir path="${src}/main" name="src.main"/>
- <dir path="${src}/docs" name="src.docs"/>
- <dir path="${src}/test" name="src.test"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="prepare" depends="init">
-
- <process name="prepare-prefs">
- <consumes>
- <ref id="etc.prefs"/>
- </consumes>
- <produces>
- <dir path="${target}/prefs" name="target.prefs"/>
- </produces>
- </process>
-
- <process name="prepare-deliverables">
- <consumes>
- <ref id="etc.deliverables"/>
- </consumes>
- <produces>
- <dir path="${target}/deliverables" name="target.deliverables"/>
- </produces>
- </process>
-
- <process name="prepare-main">
- <consumes>
- <ref id="target"/>
- <ref id="etc.main" optional="true"/>
- <ref id="src.main" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/build/main" name="target.build.main"/>
- </produces>
- </process>
-
- <process name="prepare-test">
- <consumes>
- <ref id="etc.test" optional="true"/>
- <ref id="src.test" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/build/test" name="target.build.test"/>
- </produces>
- </process>
-
- <process name="prepare-docs">
- <consumes>
- <ref id="etc.docs" optional="true"/>
- <ref id="src.docs" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/build/docs" name="target.build.docs"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="build" depends="prepare">
-
- <process name="build-main">
- <consumes>
- <ref id="target.build.main" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/classes/main" name="target.classes.main"/>
- </produces>
- </process>
-
- <process name="build-test">
- <consumes>
- <ref id="target.build.test" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/classes/test" name="target.classes.test"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="package" depends="build">
-
- <process name="jar">
- <consumes>
- <ref id="target.deliverables"/>
- <ref id="target.classes.main" optional="true"/>
- </consumes>
- <produces>
- <resource base="{target.deliverables}"
name="target.deliverables.jar"/>
- </produces>
- </process>
-
- <process name="part" id="part">
- <consumes>
- <ref id="target.deliverables.jar" optional="true"/>
- </consumes>
- <produces>
- <resource base="{target.deliverables}"
name="target.deliverables.part"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="test" depends="package">
-
- <process name="unit-test">
- <consumes>
- <ref id="target.classes.test" optional="true"/>
- <ref id="target.deliverables.jar" optional="true"/>
- </consumes>
- <produces>
- <dir path="${target}/reports/test" name="target.reports.test"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="install" depends="test">
-
- <select>
- <all/>
- </select>
-
- <process name="prefs">
- <consumes>
- <ref id="target.prefs"/>
- </consumes>
- <produces>
- <collection layout="classic" base="${dpml.prefs}" name="prefs"/>
- </produces>
- </process>
-
- <process name="deliverables">
-
- <description>
- For all of the resources declared by the project defintion - copy
- the resource under the target deliverables directory to the working
- cache. The process validates that all resource declared as produced
by
- the project are present within the deliverables directory prior to
- initating a cache update.
- </description>
-
- <consumes>
- <select type="*"/>
- <ref id="target.deliverables"/>
- </consumes>
- <produces>
- <collection layout="classic" base="${dpml.cache}" name="cache"/>
- </produces>
- </process>
-
- </phase>
-
- <phase name="clean" depends="init">
-
- <process name="purge">
- <consumes>
- <ref id="target"/>
- </consumes>
- </process>
-
- </phase>
-
- </phases>
-
-</configuration>
-

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/BuilderError.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/BuilderError.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/BuilderError.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tools.impl;
+
+/**
+ * A BuilderError is thrown when a fatal error occurs during builder
configuration.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class BuilderError extends Error
+{
+ /**
+ * Creation of a new BuilderError.
+ * @param message the exception message
+ */
+ public BuilderError( String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Creation of a new BuilderError.
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public BuilderError( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -21,20 +21,39 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.net.URI;
+import java.util.Date;

+import net.dpml.lang.Plugin;
+import net.dpml.lang.Part;
+import net.dpml.lang.UnknownKeyException;
+
import net.dpml.library.info.Scope;
import net.dpml.library.Library;
import net.dpml.library.Resource;
import net.dpml.library.Type;
+import net.dpml.library.Filter;
+import net.dpml.library.impl.DefaultLibrary;

+import net.dpml.tools.info.PhaseDirective;
+import net.dpml.tools.info.ListenerDirective;
+import net.dpml.tools.info.ProcessorDirective;
+
import net.dpml.tools.model.Context;
+import net.dpml.tools.model.Processor;

import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;

+import net.dpml.util.Logger;
+import net.dpml.util.DefaultLogger;
+
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Target;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.taskdefs.Delete;

/**
* Default implmentation of a project context.
@@ -42,29 +61,73 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-final class DefaultContext implements Context
+public final class DefaultContext implements Context
{
private final Project m_project;
private final Resource m_resource;
- private final Library m_library;
+ private final DefaultWorkbench m_workbench;
+ private final Processor[] m_processors;

private Path m_runtime;
private Path m_test;

/**
* Creation of a new project build context.
+ * @param project the unconfigured Ant project
+ */
+ public DefaultContext( Project project ) throws Exception
+ {
+ this(
+ newResource( project.getBaseDir() ),
+ project );
+ }
+
+ /**
+ * Creation of a new project build context.
* @param resource the resource definition
- * @param library the resource library
* @param project the Ant project
*/
- public DefaultContext( Resource resource, Library library, Project
project )
+ public DefaultContext( Resource resource, Project project ) throws
Exception
{
m_project = project;
m_resource = resource;
- m_library = library;

- StandardBuilder.configureProject( project, resource );
+ Library library = resource.getLibrary();
+ m_workbench = new DefaultWorkbench( library );

+ project.addReference( "project.timestamp", new Date() );
+ project.setBaseDir( resource.getBaseDir() );
+
+ String[] names = resource.getPropertyNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ String value = resource.getProperty( name );
+ project.setProperty( name, value );
+ }
+ project.setProperty( "project.name", resource.getName() );
+ project.setProperty( "project.version", resource.getVersion() );
+ project.setProperty( "project.resource.path",
resource.getResourcePath() );
+ project.setProperty( "project.basedir",
resource.getBaseDir().toString() );
+
+ Filter[] filters = resource.getFilters();
+ for( int i=0; i<filters.length; i++ )
+ {
+ Filter filter = filters[i];
+ String token = filter.getToken();
+ try
+ {
+ String value = filter.getValue( resource );
+ project.getGlobalFilterSet().addFilter( token, value );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Error while attempting to setup the filter [" + token +
"].";
+ throw new BuildException( error, e );
+ }
+ }
+
project.setNewProperty( "project.nl", "\n" );
project.setNewProperty(
"project.line",
@@ -90,9 +153,67 @@
project.setNewProperty( "project.target.deliverables.dir",
getTargetDeliverablesDirectory().toString() );
project.setNewProperty( "project.target.test.dir",
getTargetTestDirectory().toString() );
project.setNewProperty( "project.target.reports.dir",
getTargetReportsDirectory().toString() );
+
+ // add listeners declared in the builder configuration
+
+ ListenerDirective[] listeners =
StandardBuilder.CONFIGURATION.getListenerDirectives();
+ for( int i=0; i<listeners.length; i++ )
+ {
+ ListenerDirective directive = listeners[i];
+ project.log( "adding listener: " + directive.getName(),
Project.MSG_VERBOSE );
+ BuildListener buildListener = loadBuildListener( directive );
+ project.addBuildListener( buildListener );
+ }
+
+ // load processors declared under the builder configuration matching
the
+ // types produced by the project (including dependent processors)
+
+ ProcessorDirective[] processors = getProcessorSequence();
+ m_processors = new Processor[ processors.length ];
+ for( int i=0; i<processors.length; i++ )
+ {
+ ProcessorDirective processor = processors[i];
+ project.log( "loading processor: " + processor.getName(),
Project.MSG_VERBOSE );
+ m_processors[i] = loadProcessor( processor );
+ }
}

/**
+ * Return an array of processors.
+ * @return the processor array
+ */
+ public Processor[] getProcessors()
+ {
+ return m_processors;
+ }
+
+ /**
+ * Return the sequence of processor definitions supporting production of
a
+ * the current resource. The implementation constructs a sequence of
process
+ * instances based on the types declared by the resource combined with
+ * dependencies declared by respective process definitions.
+ *
+ * @return a sorted array of processor definitions supporting type
production
+ * @exception ProcessorNotFoundException if a processor referenced by
another
+ * processor as a dependent cannot be resolved
+ */
+ private ProcessorDirective[] getProcessorSequence()
+ {
+ try
+ {
+ return m_workbench.getProcessorSequence( m_resource );
+ }
+ catch( UnknownKeyException e )
+ {
+ final String error =
+ "Internal error while constructing processor sequence.";
+ IllegalStateException ise = new IllegalStateException( error );
+ ise.initCause( e );
+ throw ise;
+ }
+ }
+
+ /**
* Initialize the contex during which runtime and test path objects are
* established as project references.
*/
@@ -201,7 +322,7 @@
*/
public Library getLibrary()
{
- return m_library;
+ return m_resource.getLibrary();
}

/**
@@ -554,5 +675,146 @@
throw new BuildException( error, e );
}
}
+
+ private static Resource newResource( File basedir )
+ {
+ try
+ {
+ Logger logger = new DefaultLogger();
+ DefaultLibrary library = new DefaultLibrary( logger );
+ return library.locate( basedir.getCanonicalFile() );
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Exception ioe )
+ {
+ final String error =
+ "Unexpected error while attempting to construct project
context.";
+ throw new RuntimeException( error, ioe );
+ }
+ }
+
+ private static String flatternDependencies( String[] deps )
+ {
+ if( deps.length == 0 )
+ {
+ return null;
+ }
+ StringBuffer buffer = new StringBuffer();
+ for( int i=0; i<deps.length; i++ )
+ {
+ if( i>0 )
+ {
+ buffer.append( "," );
+ }
+ String dep = deps[i];
+ buffer.append( dep );
+ }
+ return buffer.toString();
+ }
+
+ public BuildListener loadBuildListener( ListenerDirective listener )
+ {
+ String name = listener.getName();
+ URI uri = listener.getURI();
+ try
+ {
+ String classname = listener.getClassname();
+ Object object = loadInstance( name, uri, classname );
+ return (BuildListener) object;
+ }
+ catch( ClassCastException e )
+ {
+ final String error =
+ "Build listener ["
+ + name
+ + "] from uri ["
+ + uri
+ + "] does not implement "
+ + BuildListener.class.getName();
+ throw new BuilderError( error );
+ }
+ }
+
+ public Processor loadProcessor( ProcessorDirective directive )
+ {
+ String name = directive.getName();
+ URI uri = directive.getURI();
+ try
+ {
+ String classname = directive.getClassname();
+ Object object = loadInstance( name, uri, classname );
+ return (Processor) object;
+ }
+ catch( ClassCastException e )
+ {
+ final String error =
+ "Build processor ["
+ + name
+ + "] from uri ["
+ + uri
+ + "] does not implement "
+ + Processor.class.getName();
+ throw new BuilderError( error );
+ }
+ }
+
+ public Object loadInstance( String name, URI uri, String classname )
+ {
+ if( null == uri )
+ {
+ try
+ {
+ ClassLoader classloader = getClass().getClassLoader();
+ Class clazz = classloader.loadClass( classname );
+ Object[] args = new Object[]{this};
+ return Plugin.instantiate( clazz, args );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to load a local plugin."
+ + "\nClass: " + classname
+ + "\nName: " + name;
+ throw new BuilderError( error, e );
+ }
+ }
+ else
+ {
+ ClassLoader context =
Thread.currentThread().getContextClassLoader();
+ try
+ {
+ ClassLoader classloader = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader( classloader );
+ Object[] params = new Object[]{this};
+ Part part = Part.load( uri );
+ if( null == classname )
+ {
+ return part.instantiate( params );
+ }
+ else
+ {
+ ClassLoader loader = part.getClassLoader();
+ Class c = loader.loadClass( classname );
+ return Plugin.instantiate( c, params );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to load plugin."
+ + "\nURI: " + uri
+ + "\nName: " + name;
+ throw new BuilderError( error, e );
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( context );
+ }
+ }
+ }
+
}


Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultProcessor.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultProcessor.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultProcessor.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -1,84 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.tools.impl;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import net.dpml.library.impl.DefaultDictionary;
-
-import net.dpml.tools.info.ListenerDirective;
-import net.dpml.tools.model.Processor;
-
-/**
- * Utility class used for construction of a module model from an XML source.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-final class DefaultProcessor extends DefaultDictionary implements Processor
-{
- private final ListenerDirective m_directive;
-
- public DefaultProcessor( ListenerDirective directive ) throws
URISyntaxException
- {
- super( null, directive );
-
- m_directive = directive;
- }
-
-
//----------------------------------------------------------------------------
- // Process
-
//----------------------------------------------------------------------------
-
- /**
- * Return the name of the process.
- */
- public String getName()
- {
- return m_directive.getName();
- }
-
- /**
- * Return the processor codebase uri.
- */
- public URI getCodeBaseURI()
- {
- return m_directive.getURI();
- }
-
- /**
- * Return the processor classname.
- * @return a possibly null classname
- */
- public String getClassname()
- {
- return m_directive.getClassname();
- }
-
- /**
- * Return an array of dependent process names declared by the process
type.
- * @return the process names that this process is depends on
- */
- public String[] getDepends()
- {
- return m_directive.getDependencies();
- }
-
-}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultWorkbench.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultWorkbench.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultWorkbench.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -30,10 +30,11 @@
import net.dpml.tools.info.BuilderDirective;
import net.dpml.tools.info.BuilderDirectiveHelper;
import net.dpml.tools.info.ListenerDirective;
-import net.dpml.tools.model.Workbench;
+import net.dpml.tools.info.ProcessorDirective;
+
import net.dpml.tools.model.Context;
-import net.dpml.tools.model.Processor;
-import net.dpml.tools.model.ProcessorNotFoundException;
+//import net.dpml.tools.model.Processor;
+//import net.dpml.tools.model.ProcessorNotFoundException;

import org.apache.tools.ant.Project;

@@ -43,11 +44,10 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class DefaultWorkbench implements Workbench
+class DefaultWorkbench
{
private final Library m_library;
- private final BuilderDirective m_directive;
- private final DefaultProcessor[] m_processors;
+ private final ProcessorDirective[] m_processors;

/**
* Creation of a new workbench instance. The workbench loads the
@@ -57,7 +57,7 @@
* @param library the common project library
* @exception Exception if an error occurs
*/
- public DefaultWorkbench( Library library ) throws Exception
+ DefaultWorkbench( Library library ) throws Exception
{
if( null == library )
{
@@ -66,28 +66,10 @@

m_library = library;

- m_directive = BuilderDirectiveHelper.build();
- ListenerDirective[] directives = m_directive.getListenerDirectives();
- m_processors = new DefaultProcessor[ directives.length ];
- for( int i=0; i<directives.length; i++ )
- {
- ListenerDirective directive = directives[i];
- m_processors[i] = new DefaultProcessor( directive );
- }
+ m_processors =
StandardBuilder.CONFIGURATION.getProcessorDirectives();
}

/**
- * Create a project context.
- * @param resource the resource
- * @param project the current project
- * @return the project context
- */
- public Context createContext( Resource resource, Project project )
- {
- return new DefaultContext( resource, m_library, project );
- }
-
- /**
* Return the common resource library.
* @return the library
*/
@@ -100,7 +82,7 @@
* Return an array of all registered processor definitions.
* @return the processor definition array
*/
- public Processor[] getProcessors()
+ public ProcessorDirective[] getProcessorDirectives()
{
return m_processors;
}
@@ -117,39 +99,39 @@
* @return a sorted array of processor definitions supporting resource
production
* @exception ProcessorNotFoundException if a processor referenced by
another
* processor as a dependent cannot be resolved
- */
- public Processor[] getProcessorSequence( Resource resource )
- throws ProcessorNotFoundException
+ */
+ public ProcessorDirective[] getProcessorSequence( Resource resource )
+ throws UnknownKeyException
{
Type[] types = resource.getTypes();
return getDefaultProcessorSequence( types );
}

- DefaultProcessor[] getDefaultProcessorSequence( Type[] types )
- throws ProcessorNotFoundException
+ ProcessorDirective[] getDefaultProcessorSequence( Type[] types )
+ throws UnknownKeyException
{
- String[] names = getListenerNames( types );
- DefaultProcessor[] processors = new DefaultProcessor[ names.length ];
+ String[] names = getNames( types );
+ ProcessorDirective[] processors = new ProcessorDirective[
names.length ];
for( int i=0; i<names.length; i++ )
{
String name = names[i];
- processors[i] = getDefaultProcessor( name );
+ processors[i] = getProcessorDirective( name );
}
return processors;
}

- String[] getListenerNames( Type[] types )
+ String[] getNames( Type[] types )
{
String[] names = getTypeNames( types );
- ListenerDirective[] descriptors = getListenerDirectives( names );
- ListenerDirective[] sorted = sortListenerDirectives( descriptors );
- String[] listeners = new String[ sorted.length ];
+ ProcessorDirective[] descriptors = getProcessorDirectives( names );
+ ProcessorDirective[] sorted = sortProcessorDirectives( descriptors );
+ String[] list = new String[ sorted.length ];
for( int i=0; i<sorted.length; i++ )
{
- ListenerDirective directive = sorted[i];
- listeners[i] = directive.getName();
+ ProcessorDirective directive = sorted[i];
+ list[i] = directive.getName();
}
- return listeners;
+ return list;
}

String[] getTypeNames( Type[] types )
@@ -163,7 +145,7 @@
return names;
}

- private ListenerDirective[] getListenerDirectives( String[] names )
+ private ProcessorDirective[] getProcessorDirectives( String[] names )
{
ArrayList list = new ArrayList();
for( int i=0; i<names.length; i++ )
@@ -171,7 +153,7 @@
String name = names[i];
try
{
- ListenerDirective directive = getListenerDirective( name );
+ ProcessorDirective directive = getProcessorDirective( name );
list.add( directive );
}
catch( UnknownKeyException e )
@@ -179,15 +161,14 @@
// ok
}
}
- return (ListenerDirective[]) list.toArray( new ListenerDirective[0]
);
+ return (ProcessorDirective[]) list.toArray( new
ProcessorDirective[0] );
}

- private ListenerDirective getListenerDirective( String name ) throws
UnknownKeyException
+ private ProcessorDirective getProcessorDirective( String name ) throws
UnknownKeyException
{
- ListenerDirective[] directives = m_directive.getListenerDirectives();
- for( int i=0; i<directives.length; i++ )
+ for( int i=0; i<m_processors.length; i++ )
{
- ListenerDirective directive = directives[i];
+ ProcessorDirective directive = m_processors[i];
if( directive.getName().equals( name ) )
{
return directive;
@@ -196,20 +177,20 @@
throw new UnknownKeyException( name );
}

- private ListenerDirective[] sortListenerDirectives( ListenerDirective[]
directives )
+ private ProcessorDirective[] sortProcessorDirectives(
ProcessorDirective[] directives )
{
ArrayList visited = new ArrayList();
ArrayList stack = new ArrayList();
for( int i=0; i<directives.length; i++ )
{
- ListenerDirective directive = directives[i];
- processListenerDirective( visited, stack, directive );
+ ProcessorDirective directive = directives[i];
+ processProcessorDirective( visited, stack, directive );
}
- return (ListenerDirective[]) stack.toArray( new ListenerDirective[0]
);
+ return (ProcessorDirective[]) stack.toArray( new
ProcessorDirective[0] );
}

- private void processListenerDirective(
- List visited, List stack, ListenerDirective directive )
+ private void processProcessorDirective(
+ List visited, List stack, ProcessorDirective directive )
{
if( visited.contains( directive ) )
{
@@ -219,26 +200,12 @@
{
visited.add( directive );
String[] deps = directive.getDependencies();
- ListenerDirective[] providers = getListenerDirectives( deps );
+ ProcessorDirective[] providers = getProcessorDirectives( deps );
for( int i=0; i<providers.length; i++ )
{
- processListenerDirective( visited, stack, providers[i] );
+ processProcessorDirective( visited, stack, providers[i] );
}
stack.add( directive );
}
}
-
- private DefaultProcessor getDefaultProcessor( String name )
- throws ProcessorNotFoundException
- {
- for( int i=0; i<m_processors.length; i++ )
- {
- DefaultProcessor processor = m_processors[i];
- if( name.equals( processor.getName() ) )
- {
- return processor;
- }
- }
- throw new ProcessorNotFoundException( name );
- }
}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tools.impl;
+
+import net.dpml.tools.model.Context;
+import net.dpml.tools.model.Processor;
+
+import net.dpml.tools.info.ProcessorDirective;
+import net.dpml.tools.process.StandardProcess;
+
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+
+/**
+ * Standard build listener.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class StandardBuildListener implements BuildListener
+{
+ private final Context m_context;
+ private final StandardProcess m_standard;
+
+ public StandardBuildListener( Context context )
+ {
+ if( null == context )
+ {
+ throw new NullPointerException( "context" );
+ }
+
+ m_context = context;
+ m_standard = new StandardProcess();
+ }
+
+ /**
+ * Signals that a build has started. This event
+ * is fired before any targets have started.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ */
+ public void buildStarted( BuildEvent event )
+ {
+ }
+
+ /**
+ * Signals that the last target has finished. This event
+ * will still be fired if an error occurred during the build.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void buildFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Signals that a target is starting.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getTarget()
+ */
+ public void targetStarted( BuildEvent event )
+ {
+ Target target = event.getTarget();
+ String targetName = target.getName();
+ Processor[] processors = m_context.getProcessors();
+ if( "init".equals( targetName ) )
+ {
+ event.getProject().log( "executing initialization phase",
Project.MSG_VERBOSE );
+ m_standard.initialize( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.initialize( m_context );
+ }
+ }
+ else if( "prepare".equals( targetName ) )
+ {
+ event.getProject().log( "executing preparation phase",
Project.MSG_VERBOSE );
+ m_standard.prepare( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.prepare( m_context );
+ }
+ }
+ else if( "build".equals( targetName ) )
+ {
+ event.getProject().log( "executing build phase",
Project.MSG_VERBOSE );
+ m_standard.build( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.build( m_context );
+ }
+ }
+ else if( "package".equals( targetName ) )
+ {
+ event.getProject().log( "executing packaging phase",
Project.MSG_VERBOSE );
+ m_standard.pack( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.pack( m_context );
+ }
+ }
+ else if( "test".equals( targetName ) )
+ {
+ event.getProject().log( "executing validation phase",
Project.MSG_VERBOSE );
+ m_standard.validate( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.validate( m_context );
+ }
+ }
+ else if( "install".equals( targetName ) )
+ {
+ event.getProject().log( "executing installation phase",
Project.MSG_VERBOSE );
+ m_standard.install( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.install( m_context );
+ }
+ }
+ }
+
+ /**
+ * Signals that a target has finished. This event will
+ * still be fired if an error occurred during the build.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void targetFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Signals that a task is starting.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getTask()
+ */
+ public void taskStarted( BuildEvent event )
+ {
+ }
+
+ /**
+ * Signals that a task has finished. This event will still
+ * be fired if an error occurred during the build.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void taskFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Signals a message logging event.
+ *
+ * @param event An event with any relevant extra information.
+ * Must not be <code>null</code>.
+ *
+ * @see BuildEvent#getMessage()
+ * @see BuildEvent#getPriority()
+ */
+ public void messageLogged( BuildEvent event )
+ {
+ }
+}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -29,8 +29,9 @@
import net.dpml.library.Resource;
import net.dpml.library.Filter;

-import net.dpml.tools.model.Workbench;
import net.dpml.tools.model.Context;
+import net.dpml.tools.info.BuilderDirective;
+import net.dpml.tools.info.BuilderDirectiveHelper;

import net.dpml.transit.Artifact;
import net.dpml.transit.model.TransitModel;
@@ -64,14 +65,32 @@
* The default template uri path.
*/
public static final String DEFAULT_TEMPLATE_URN =
"local:template:dpml/tools/standard";
-
+
+ public static final BuilderDirective CONFIGURATION = loadConfiguration();
+
+ private static BuilderDirective loadConfiguration()
+ {
+ try
+ {
+ return BuilderDirectiveHelper.build();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to establish the builder
configuration.";
+ BuilderError be = new BuilderError( error, e );
+ be.printStackTrace();
+ return null;
+ }
+ }
+
//
------------------------------------------------------------------------
// state
//
------------------------------------------------------------------------

private Logger m_logger;
private TransitModel m_model;
- private Workbench m_workbench;
+ private Library m_library;
private boolean m_verbose;
private Throwable m_result;

@@ -84,23 +103,25 @@
*
* @param logger assigned logging channel
* @param library the library
+ */
+ public StandardBuilder( Logger logger, Library library )
+ {
+ this( logger, library, false );
+ }
+
+ /**
+ * Creation of a new standard builder.
+ *
+ * @param logger assigned logging channel
+ * @param library the library
* @param verbose verbose execution flag
*/
public StandardBuilder( Logger logger, Library library, boolean verbose )
{
m_logger = logger;
m_verbose = verbose;
+ m_library = library;

- try
- {
- m_workbench = new DefaultWorkbench( library );
- }
- catch( Throwable e )
- {
- final String error =
- "An internal error occured while attempting to construct the
workbench.";
- throw new BuildException( error, e );
- }
Thread.currentThread().setContextClassLoader(
Builder.class.getClassLoader() );
}

@@ -175,7 +196,9 @@
return file;
}
}
-
+
+ //return null;
+
// otherwise we build using either an explicit or default
template
// resolved via a uri (typically a template stored in prefs)

@@ -219,7 +242,12 @@
try
{
ProjectHelper helper = (ProjectHelper) project.getReference(
"ant.projectHelper" );
- helper.parse( project, template );
+
+ if( null != template )
+ {
+ helper.parse( project, template );
+ }
+
Vector vector = new Vector();

if( targets.length == 0 )
@@ -228,6 +256,10 @@
{
vector.addElement( project.getDefaultTarget() );
}
+ else
+ {
+ vector.addElement( CONFIGURATION.getDefaultPhase() );
+ }
}
else
{
@@ -289,55 +321,23 @@

Project createProject( Resource resource )
{
- Project project = createProject();
- project.addReference( "project.workbench", m_workbench );
- Context context = m_workbench.createContext( resource, project );
- project.addReference( "project.context", context );
- return configureProject( project, resource );
- }
-
- static Project configureProject( Project project, Resource resource )
- {
- if( null != project.getReference( "project.timestamp" ) )
+ try
{
+ Project project = newProject();
+ Context context = new DefaultContext( resource, project );
+ project.addReference( "project.context", context );
return project;
}
-
- project.addReference( "project.timestamp", new Date() );
- project.setBaseDir( resource.getBaseDir() );
-
- String[] names = resource.getPropertyNames();
- for( int i=0; i<names.length; i++ )
+ catch( Exception e )
{
- String name = names[i];
- String value = resource.getProperty( name );
- project.setProperty( name, value );
+ final String error =
+ "Unable to establish build context."
+ + "\nProject: " + resource;
+ throw new BuildException( error, e );
}
- project.setProperty( "project.name", resource.getName() );
- project.setProperty( "project.version", resource.getVersion() );
- project.setProperty( "project.resource.path",
resource.getResourcePath() );
- project.setProperty( "project.basedir",
resource.getBaseDir().toString() );
- Filter[] filters = resource.getFilters();
- for( int i=0; i<filters.length; i++ )
- {
- Filter filter = filters[i];
- String token = filter.getToken();
- try
- {
- String value = filter.getValue( resource );
- project.getGlobalFilterSet().addFilter( token, value );
- }
- catch( Exception e )
- {
- final String error =
- "Error while attempting to setup the filter [" + token +
"].";
- throw new BuildException( error, e );
- }
- }
- return project;
}

- Project createProject()
+ private Project newProject()
{
Project project = new Project();
project.setSystemProperties();

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -19,13 +19,16 @@
package net.dpml.tools.info;

import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;

import net.dpml.library.info.AbstractDirective;

+import net.dpml.lang.UnknownKeyException;
+
/**
- * The BuilderDirective class describes a collection of modules together
- * with information about type defintions.
+ * The BuilderDirective class describes the configuration of the build
system.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -33,13 +36,19 @@
public final class BuilderDirective extends AbstractDirective
{
private final ListenerDirective[] m_listeners;
+ private final ProcessorDirective[] m_processors;
+ private final String m_phase;

/**
* Creation of a new library directive.
* @param listeners an array of listener directives
- * @param properties library properties
+ * @param phase the default target phase
+ * @param processors an array of processor directives
+ * @param properties supplimentary properties
*/
- public BuilderDirective( ListenerDirective[] listeners, Properties
properties )
+ public BuilderDirective(
+ ListenerDirective[] listeners, String phase,
+ ProcessorDirective[] processors, Properties properties ) throws
UnknownKeyException
{
super( properties );

@@ -47,6 +56,14 @@
{
throw new NullPointerException( "listeners" );
}
+ if( null == phase )
+ {
+ throw new NullPointerException( "phase" );
+ }
+ if( null == processors )
+ {
+ throw new NullPointerException( "processors" );
+ }
for( int i=0; i<listeners.length; i++ )
{
if( null == listeners[i] )
@@ -55,7 +72,9 @@
}
}

- m_listeners = listeners;
+ m_phase = phase;
+ m_processors = processors;
+ m_listeners = sortListenerDirectives( listeners );
}

/**
@@ -68,6 +87,24 @@
}

/**
+ * Return the default phase.
+ * @return the default phase name.
+ */
+ public String getDefaultPhase()
+ {
+ return m_phase;
+ }
+
+ /**
+ * Return the set of processor directives.
+ * @return the processor directive array
+ */
+ public ProcessorDirective[] getProcessorDirectives()
+ {
+ return m_processors;
+ }
+
+ /**
* Compare this object with another for equality.
* @param other the other object
* @return true if equal
@@ -77,7 +114,18 @@
if( super.equals( other ) && ( other instanceof BuilderDirective ) )
{
BuilderDirective object = (BuilderDirective) other;
- return Arrays.equals( m_listeners, object.m_listeners );
+ if( !equals( m_phase, object.m_phase ) )
+ {
+ return false;
+ }
+ if( !Arrays.equals( m_listeners, object.m_listeners ) )
+ {
+ return false;
+ }
+ else
+ {
+ return Arrays.equals( m_processors, object.m_processors );
+ }
}
else
{
@@ -86,13 +134,76 @@
}

/**
- * Compute the hash value.
- * @return the hascode value
+ * Compute the hash code value.
+ * @return the hash value
*/
public int hashCode()
{
int hash = super.hashCode();
+ hash ^= super.hashValue( m_phase );
hash ^= super.hashArray( m_listeners );
+ hash ^= super.hashArray( m_processors );
return hash;
}
+
+ private static ListenerDirective[] sortListenerDirectives(
ListenerDirective[] directives )
+ throws UnknownKeyException
+ {
+ ArrayList visited = new ArrayList();
+ ArrayList stack = new ArrayList();
+ for( int i=0; i<directives.length; i++ )
+ {
+ ListenerDirective directive = directives[i];
+ processListenerDirective( directives, visited, stack, directive
);
+ }
+ return (ListenerDirective[]) stack.toArray( new ListenerDirective[0]
);
+ }
+
+ private static void processListenerDirective(
+ ListenerDirective[] directives, List visited, List stack,
ListenerDirective directive )
+ throws UnknownKeyException
+ {
+ if( visited.contains( directive ) )
+ {
+ return;
+ }
+ else
+ {
+ visited.add( directive );
+ String[] deps = directive.getDependencies();
+ ListenerDirective[] providers = getListenerDirectives(
directives, deps );
+ for( int i=0; i<providers.length; i++ )
+ {
+ processListenerDirective( directives, visited, stack,
providers[i] );
+ }
+ stack.add( directive );
+ }
+ }
+
+ private static ListenerDirective[] getListenerDirectives(
+ ListenerDirective[] directives, String[] names ) throws
UnknownKeyException
+ {
+ ArrayList list = new ArrayList();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ ListenerDirective directive = getListenerDirective( directives,
name );
+ list.add( directive );
+ }
+ return (ListenerDirective[]) list.toArray( new ListenerDirective[0]
);
+ }
+
+ private static ListenerDirective getListenerDirective(
+ ListenerDirective[] directives, String name ) throws
UnknownKeyException
+ {
+ for( int i=0; i<directives.length; i++ )
+ {
+ ListenerDirective directive = directives[i];
+ if( directive.getName().equals( name ) )
+ {
+ return directive;
+ }
+ }
+ throw new UnknownKeyException( name );
+ }
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -27,7 +27,6 @@
import java.net.URI;
import java.net.URL;
import java.util.Properties;
-import java.beans.XMLDecoder;

import net.dpml.tools.process.JarProcess;
import net.dpml.tools.process.PluginProcess;
@@ -38,6 +37,8 @@

import net.dpml.util.ElementHelper;

+import net.dpml.lang.UnknownKeyException;
+
import org.w3c.dom.Element;

/**
@@ -53,6 +54,10 @@
private static final String LISTENER_ELEMENT_NAME = "listener";
private static final String PROPERTIES_ELEMENT_NAME = "properties";
private static final String PROPERTY_ELEMENT_NAME = "property";
+ private static final String PROCESSORS_ELEMENT_NAME = "processors";
+ private static final String PROCESSOR_ELEMENT_NAME = "processor";
+ private static final String PHASES_ELEMENT_NAME = "phases";
+ private static final String PHASE_ELEMENT_NAME = "phase";

private BuilderDirectiveHelper()
{
@@ -121,54 +126,13 @@
}
else
{
- return createDefaultBuilderDirective();
+ final String error =
+ "Missing builder configuration: "
+ + config;
+ throw new FileNotFoundException( error );
}
}

- private static BuilderDirective createDefaultBuilderDirective()
- {
- ListenerDirective[] listeners = new ListenerDirective[3];
- listeners[0] =
- new ListenerDirective(
- "jar",
- (URI) null,
- JarProcess.class.getName(),
- true,
- new String[0],
- null );
- listeners[1] =
- new ListenerDirective(
- "part",
- (URI) null,
- PluginProcess.class.getName(),
- true,
- new String[0],
- null );
- listeners[2] =
- new ListenerDirective(
- "module",
- (URI) null,
- ModuleProcess.class.getName(),
- true,
- new String[0],
- null );
- return new BuilderDirective( listeners, null );
- }
-
- /**
- * Creates a builder configuration using a supplied uri as the source
configuration.
- * @param uri builder configuration uri
- * @return the builder directive
- * @exception Exception if an error occurs
- */
- public static BuilderDirective build( URI uri ) throws Exception
- {
- URL url = convertToURL( uri );
- InputStream input = url.openStream();
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
- return (BuilderDirective) decoder.readObject();
- }
-
private static URL convertToURL( URI uri ) throws Exception
{
if( Artifact.isRecognized( uri ) )
@@ -194,14 +158,17 @@
if( !BUILDER_ELEMENT_NAME.equals( elementName ) )
{
final String error =
- "Element is not a builder confiuration.";
+ "Element is not a builder configuration.";
throw new IllegalArgumentException( error );
}

// get type descriptors, modules and properties

+ String phase = ElementHelper.getAttribute( element, "default",
"installation" );
+
Properties properties = null;
ListenerDirective[] listeners = new ListenerDirective[0];
+ ProcessorDirective[] processors = new ProcessorDirective[0];
Element[] children = ElementHelper.getChildren( element );
for( int i=0; i<children.length; i++ )
{
@@ -215,6 +182,10 @@
{
listeners = buildListenerDirectives( child );
}
+ else if( PROCESSORS_ELEMENT_NAME.equals( tag ) )
+ {
+ processors = buildProcessorDirectives( child );
+ }
else
{
final String error =
@@ -222,7 +193,7 @@
throw new IllegalArgumentException( error );
}
}
- return new BuilderDirective( listeners, properties );
+ return new BuilderDirective( listeners, phase, processors,
properties );
}

private static ListenerDirective[] buildListenerDirectives( Element
element ) throws Exception
@@ -246,11 +217,10 @@
final String spec = ElementHelper.getAttribute( element, "uri",
null );
final URI uri = createURI( spec );
final String classname = ElementHelper.getAttribute( element,
"class", null );
- final boolean artifact = ElementHelper.getBooleanAttribute(
element, "artifact", true );
final String deps = ElementHelper.getAttribute( element,
"depends", null );
final String[] depends = buildDependenciesArray( deps );
final Properties properties = buildProperties( element );
- return new ListenerDirective( name, uri, classname, artifact,
depends, properties );
+ return new ListenerDirective( name, uri, classname, depends,
properties );
}
else
{
@@ -262,6 +232,75 @@
}
}

+ private static ProcessorDirective[] buildProcessorDirectives( Element
element ) throws Exception
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ ProcessorDirective[] processors = new ProcessorDirective[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ processors[i] = buildProcessorDirective( child );
+ }
+ return processors;
+ }
+
+ private static ProcessorDirective buildProcessorDirective( Element
element ) throws Exception
+ {
+ final String tag = element.getTagName();
+ if( PROCESSOR_ELEMENT_NAME.equals( tag ) )
+ {
+ final String name = ElementHelper.getAttribute( element, "name",
null );
+ final String spec = ElementHelper.getAttribute( element, "uri",
null );
+ final URI uri = createURI( spec );
+ final String classname = ElementHelper.getAttribute( element,
"class", null );
+ final String deps = ElementHelper.getAttribute( element,
"depends", null );
+ final String[] depends = buildDependenciesArray( deps );
+ final Properties properties = buildProperties( element );
+ return new ProcessorDirective( name, uri, classname, depends,
properties );
+ }
+ else
+ {
+ final String error =
+ "Invalid resource element name ["
+ + tag
+ + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ private static PhaseDirective[] buildPhaseDirectives( Element element )
throws Exception
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ PhaseDirective[] phases = new PhaseDirective[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ phases[i] = buildPhaseDirective( child );
+ }
+ return phases;
+ }
+
+ private static PhaseDirective buildPhaseDirective( Element element )
throws Exception
+ {
+ final String tag = element.getTagName();
+ if( PHASE_ELEMENT_NAME.equals( tag ) )
+ {
+ final String name = ElementHelper.getAttribute( element, "name"
);
+ final String deps = ElementHelper.getAttribute( element,
"depends" );
+ final String[] depends = buildDependenciesArray( deps );
+ final String description = ElementHelper.getAttribute( element,
"description" );
+ return new PhaseDirective( name, description, depends );
+ }
+ else
+ {
+ final String error =
+ "Invalid resource element name ["
+ + tag
+ + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
private static String[] buildDependenciesArray( String value )
{
if( null == value )
@@ -312,4 +351,5 @@
return new URI( spec );
}
}
+
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -36,7 +36,6 @@
private final String m_name;
private final URI m_uri;
private final String m_classname;
- private final boolean m_artifact;
private final String[] m_dependencies;

/**
@@ -44,13 +43,13 @@
* @param name the listener name
* @param uri the listener codebase
* @param classname optional classname of the plugin instantiation target
- * @param artifact true if the produced type is a build artifact
* @param dependencies array of listener names that the listener depends
upon
* @param properties supplimentary properties
* @exception NullPointerException if name or dependencies are null
* @exception IllegalStateException if both classname and urn values are
null
*/
- public ListenerDirective( String name, URI uri, String classname,
boolean artifact,
+ public ListenerDirective(
+ String name, URI uri, String classname,
String[] dependencies, Properties properties )
throws NullPointerException, IllegalStateException
{
@@ -74,7 +73,6 @@
throw new IllegalStateException( error );
}
}
- m_artifact = artifact;
m_dependencies = dependencies;
m_name = name;
m_uri = uri;
@@ -116,15 +114,6 @@
}

/**
- * Return the listener classname to load.
- * @return the classname
- */
- public boolean isaArtifactProducer()
- {
- return m_artifact;
- }
-
- /**
* Return true if the listener produces a build artifact. If false
* the listener may contribute to a build process but does not generate a
* specific artifact type.
@@ -168,10 +157,6 @@
{
return false;
}
- else if( m_artifact != object.m_artifact )
- {
- return false;
- }
else
{
return Arrays.equals( m_dependencies, object.m_dependencies
);
@@ -193,7 +178,6 @@
hash ^= super.hashValue( m_name );
hash ^= super.hashArray( m_dependencies );
hash ^= super.hashValue( m_uri );
- hash ^= super.hashValue( new Boolean( m_artifact ) );
return hash;
}
}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ProcessorDirective.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ProcessorDirective.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ProcessorDirective.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tools.info;
+
+import java.net.URI;
+import java.util.Properties;
+import java.util.Arrays;
+
+import net.dpml.library.info.AbstractDirective;
+
+/**
+ * The ProcessorDirective is an immutable descriptor used to define
+ * a build processor.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class ProcessorDirective extends AbstractDirective
+{
+ private final String m_name;
+ private final URI m_uri;
+ private final String m_classname;
+ private final String[] m_dependencies;
+
+ /**
+ * Creation of a new processor directive.
+ * @param name the processor name
+ * @param uri the processor codebase
+ * @param classname optional classname of the plugin instantiation target
+ * @param dependencies array of listener names that the listener depends
upon
+ * @param properties supplimentary properties
+ * @exception NullPointerException if name or dependencies are null
+ * @exception IllegalStateException if both classname and urn values are
null
+ */
+ public ProcessorDirective( String name, URI uri, String classname,
+ String[] dependencies, Properties properties )
+ throws NullPointerException, IllegalStateException
+ {
+ super( properties );
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ if( null == dependencies )
+ {
+ throw new NullPointerException( "dependencies" );
+ }
+ if( null == uri )
+ {
+ if( null == classname )
+ {
+ final String error =
+ "Listener definition ["
+ + name
+ + "] does not declare a classname or uri value.";
+ throw new IllegalStateException( error );
+ }
+ }
+ m_dependencies = dependencies;
+ m_name = name;
+ m_uri = uri;
+ m_classname = classname;
+ }
+
+ /**
+ * Return the listener resource type name.
+ * @return the name of the resource type produced by the listener
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the listener codebase urn.
+ * @return the urn
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ /**
+ * Return the listener codebase urn.
+ * @return the urn
+ */
+ public String getURISpec()
+ {
+ if( null == m_uri )
+ {
+ return null;
+ }
+ else
+ {
+ return m_uri.toASCIIString();
+ }
+ }
+
+ /**
+ * Return true if the listener produces a build artifact. If false
+ * the listener may contribute to a build process but does not generate a
+ * specific artifact type.
+ *
+ * @return true if the listener produces an artifact
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Return the listener dependencies. If a listener declares a dependency
+ * on another listener, it is in effect saying that the names listeners
+ * must be executed before this listener. At an operational level
listener
+ * dependencies effect the order in which listeners are attached to a
+ * an Ant project.
+ *
+ * @return the array of listener names
+ */
+ public String[] getDependencies()
+ {
+ return m_dependencies;
+ }
+
+ /**
+ * Return a string representation of this instance.
+ * @return the string value
+ */
+ public String toString()
+ {
+ return "processor:" + m_name;
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the other object
+ * @return true if equal
+ */
+ public boolean equals( Object other )
+ {
+ if( super.equals( other ) && ( other instanceof ProcessorDirective )
)
+ {
+ ProcessorDirective object = (ProcessorDirective) other;
+ if( !equals( m_name, object.m_name ) )
+ {
+ return false;
+ }
+ else if( !equals( m_uri, object.m_uri ) )
+ {
+ return false;
+ }
+ else
+ {
+ return Arrays.equals( m_dependencies, object.m_dependencies
);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Compute the hash value.
+ * @return the hashcode value
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= super.hashValue( m_name );
+ hash ^= super.hashArray( m_dependencies );
+ hash ^= super.hashValue( m_uri );
+ return hash;
+ }
+}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Context.java
===================================================================
--- trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Context.java
2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Context.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -24,6 +24,8 @@
import net.dpml.library.Library;
import net.dpml.library.Resource;

+import net.dpml.tools.info.ProcessorDirective;
+
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;

@@ -60,6 +62,37 @@
String getProperty( String key, String value );

/**
+ * Return an array of processors.
+ * @return the processor array
+ */
+ Processor[] getProcessors();
+
+ /**
+ * Return the sequence of processor definitions supporting production of
a
+ * the current resource. The implementation constructs a sequence of
process
+ * instances based on the types declared by the resource combined with
+ * dependencies declared by respective process definitions.
+ *
+ * @return a sorted array of processor definitions supporting type
production
+ */
+ //ProcessorDirective[] getProcessorSequence();
+
+ /**
+ * Return the sequence of processor definitions supporting production of
a
+ * supplied resource. The implementation constructs a sequence of process
+ * instances based on the types declared by the resource combined with
+ * dependencies declared by respective process defintions. Clients may
+ * safely invoke processes sequentially relative to the returned process
+ * sequence.
+ *
+ * @param resource the resource to be produced
+ * @return a sorted array of processor definitions supporting resource
production
+ * @exception ProcessorNotFoundException if a processor referenced by
another
+ * processor as a dependent cannot be resolved
+ */
+ //Processor[] getProcessorSequence( Resource resource ) throws
ProcessorNotFoundException;
+
+ /**
*Initialize the context.
*/
void init();

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -23,35 +23,22 @@
import net.dpml.library.Dictionary;

/**
- * The Processor interface defines a process model.
+ * The Processor interface is implemented by phase-aware build processors.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public interface Processor extends Dictionary
+public interface Processor
{
- /**
- * Return the name of the process.
- * @return the processor name
- */
- String getName();
+ void initialize( Context context );

- /**
- * Return the processor codebase uri.
- * @return the processor codebase uri
- */
- URI getCodeBaseURI();
-
- /**
- * Return the processor classname.
- * @return a possibly null classname
- */
- String getClassname();
+ void prepare( Context context );

- /**
- * Return an array of dependent process names declared by the process
type.
- * @return the process names that this process is depends on
- */
- String[] getDepends();
-
+ void build( Context context );
+
+ void pack( Context context );
+
+ void validate( Context context );
+
+ void install( Context context );
}

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Workbench.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Workbench.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Workbench.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -1,69 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.tools.model;
-
-import net.dpml.library.Library;
-import net.dpml.library.Resource;
-
-import org.apache.tools.ant.Project;
-
-/**
- * The Workbench interface exposes the working configuration of the build
system.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Workbench
-{
- /**
- * Return the common resource library.
- * @return the library
- */
- Library getLibrary();
-
- /**
- * Return an array of all registered processors models.
- * @return the processor array
- */
- Processor[] getProcessors();
-
- /**
- * Return the sequence of processor definitions supporting production of
a
- * supplied resource. The implementation constructs a sequence of process
- * instances based on the types declared by the resource combined with
- * dependencies declared by respective process defintions. Clients may
- * safely invoke processes sequentially relative to the returned process
- * sequence.
- *
- * @param resource the resource to be produced
- * @return a sorted array of processor definitions supporting resource
production
- * @exception ProcessorNotFoundException if a processor referenced by
another
- * processor as a dependent cannot be resolved
- */
- Processor[] getProcessorSequence( Resource resource ) throws
ProcessorNotFoundException;
-
- /**
- * Create a project context.
- * @param resource the resource
- * @param project the current project
- * @return the project context
- */
- Context createContext( Resource resource, Project project );
-
-}

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractBuildListener.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractBuildListener.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractBuildListener.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -1,118 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.tools.process;
-
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.BuildEvent;
-
-/**
- * Abstract build listener.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class AbstractBuildListener implements BuildListener
-{
- /**
- * Signals that a build has started. This event
- * is fired before any targets have started.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- */
- public void buildStarted( BuildEvent event )
- {
- }
-
- /**
- * Signals that the last target has finished. This event
- * will still be fired if an error occurred during the build.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getException()
- */
- public void buildFinished( BuildEvent event )
- {
- }
-
- /**
- * Signals that a target is starting.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getTarget()
- */
- public void targetStarted( BuildEvent event )
- {
- }
-
- /**
- * Signals that a target has finished. This event will
- * still be fired if an error occurred during the build.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getException()
- */
- public void targetFinished( BuildEvent event )
- {
- }
-
- /**
- * Signals that a task is starting.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getTask()
- */
- public void taskStarted( BuildEvent event )
- {
- }
-
- /**
- * Signals that a task has finished. This event will still
- * be fired if an error occurred during the build.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getException()
- */
- public void taskFinished( BuildEvent event )
- {
- }
-
- /**
- * Signals a message logging event.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getMessage()
- * @see BuildEvent#getPriority()
- */
- public void messageLogged( BuildEvent event )
- {
- }
-}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tools.process;
+
+import net.dpml.tools.model.Context;
+import net.dpml.tools.model.Processor;
+
+/**
+ * Abstract build processor.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class AbstractProcessor implements Processor
+{
+ public void initialize( Context context )
+ {
+ }
+
+ public void prepare( Context context )
+ {
+ }
+
+ public void build( Context context )
+ {
+ }
+
+ public void pack( Context context )
+ {
+ }
+
+ public void validate( Context context )
+ {
+ }
+
+ public void install( Context context )
+ {
+ }
+}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -23,7 +23,7 @@
import net.dpml.library.info.Scope;

import net.dpml.tools.model.Context;
-import net.dpml.tools.model.Processor;
+//import net.dpml.tools.model.Processor;

import net.dpml.tools.tasks.JavacTask;
import net.dpml.tools.tasks.JarTask;
@@ -41,127 +41,90 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class JarProcess extends AbstractBuildListener
+public class JarProcess extends AbstractProcessor
{
- private Processor m_processor;
-
- /**
- * Creation of a new jar process using the supplied
- * processor as the source for property overrived.
- * @param processor the processor definition
- */
- public JarProcess( Processor processor )
+ public void build( Context context )
{
- m_processor = processor;
+ Project project = context.getProject();
+ final JavacTask task = new JavacTask( context );
+ task.setProject( project );
+ task.init();
+ task.execute();
}

- /**
- * Signals that a target is starting.
- *
- * @param event the build event.
- *
- * @see BuildEvent#getTarget()
- */
- public void targetStarted( BuildEvent event )
+ public void pack( Context context )
{
- Target target = event.getTarget();
- String name = target.getName();
- if( "build".equals( name ) )
+ Project project = context.getProject();
+ String jarSrcPath = context.getProperty(
"project.target.classes.main.dir" );
+ File jarSrcDir = new File( jarSrcPath );
+ if( jarSrcDir.exists() )
{
- Project project = event.getProject();
- Context context = getContext( project );
- final JavacTask task = new JavacTask( context, m_processor );
+ final JarTask task = new JarTask();
+ task.setProject( project );
+ task.setTaskName( "jar" );
+ task.setSrc( jarSrcDir );
+ final File jar = getJarFile( context );
+ task.setDest( jar );
task.init();
task.execute();
}
- else if( "package".equals( name ) )
+ }
+
+ public void validate( Context context )
+ {
+ Project project = context.getProject();
+ String srcPath = context.getProperty(
"project.target.build.test.dir" );
+ File src = new File( srcPath );
+ if( src.exists() )
{
- Project project = event.getProject();
- File jarSrcDir = new File( project.getProperty(
"project.target.classes.main.dir" ) );
- if( jarSrcDir.exists() )
+ final File jar = getJarFile( context );
+ Path testCompilePath = context.getPath( Scope.TEST );
+ if( jar.exists() )
{
- final JarTask task = new JarTask();
+ testCompilePath.createPathElement().setLocation( jar );
+ }
+ final File dest = new File( project.getProperty(
"project.target.classes.test.dir" ) );
+ try
+ {
+ final JavacTask task = new JavacTask( context );
task.setProject( project );
- task.setTaskName( "jar" );
- task.setSrc( jarSrcDir );
- final File jar = getJarFile( project );
- task.setDest( jar );
+ task.setTaskName( "javac" );
+ task.setSrc( src );
+ task.setDest( dest );
+ task.setClasspath( testCompilePath );
task.init();
task.execute();
}
- }
- else if( "test".equals( name ) )
- {
- Project project = event.getProject();
- Context context = getContext( project );
- File src = new File( project.getProperty(
"project.target.build.test.dir" ) );
- if( src.exists() )
+ catch( BuildException e )
{
- final File jar = getJarFile( project );
- Path testCompilePath = context.getPath( Scope.TEST );
- if( jar.exists() )
- {
- testCompilePath.createPathElement().setLocation( jar );
- }
- final File dest = new File( project.getProperty(
"project.target.classes.test.dir" ) );
- try
- {
- final JavacTask task = new JavacTask( context,
m_processor );
- task.setProject( project );
- task.setTaskName( "javac" );
- task.setSrc( src );
- task.setDest( dest );
- task.setClasspath( testCompilePath );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
- try
- {
- testCompilePath.createPathElement().setLocation( dest );
- final JUnitTestTask task = new JUnitTestTask();
- task.setProject( project );
- task.setTaskName( "junit" );
- task.setSrc( src );
- task.setClasspath( testCompilePath );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
+ throw e;
}
+ try
+ {
+ testCompilePath.createPathElement().setLocation( dest );
+ final JUnitTestTask task = new JUnitTestTask();
+ task.setProject( project );
+ task.setTaskName( "junit" );
+ task.setSrc( src );
+ task.setClasspath( testCompilePath );
+ task.init();
+ task.execute();
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
}
}

- private File getJarFile( Project project )
+ private File getJarFile( Context context )
{
- Context context = getContext( project );
- File deliverables = new File( project.getProperty(
"project.target.deliverables.dir" ) );
+ Project project = context.getProject();
+ String deliverablesPath = context.getProperty(
"project.target.deliverables.dir" );
+ File deliverables = new File( deliverablesPath );
File jars = new File( deliverables, "jars" );
String filename = context.getLayoutPath( "jar" );
return new File( jars, filename );
}

- /**
- * Get the project definition.
- * @param project the project
- * @return the build context
- */
- protected Context getContext( Project project )
- {
- Context context = (Context) project.getReference( "project.context"
);
- context.init();
- if( null == context )
- {
- final String error =
- "Missing project context reference.";
- throw new BuildException( error );
- }
- return context;
- }
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -18,6 +18,8 @@

package net.dpml.tools.process;

+import net.dpml.tools.model.Context;
+
import net.dpml.tools.tasks.ModuleTask;

import org.apache.tools.ant.Project;
@@ -30,28 +32,15 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class ModuleProcess extends AbstractBuildListener
+public class ModuleProcess extends AbstractProcessor
{
- /**
- * Signals that a target is starting.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getTarget()
- */
- public void targetFinished( BuildEvent event )
+ public void pack( Context context )
{
- Target target = event.getTarget();
- String name = target.getName();
- if( "build".equals( name ) )
- {
- Project project = event.getProject();
- final ModuleTask task = new ModuleTask();
- task.setProject( project );
- task.setTaskName( "module" );
- task.init();
- task.execute();
- }
+ Project project = context.getProject();
+ final ModuleTask task = new ModuleTask();
+ task.setProject( project );
+ task.setTaskName( "module" );
+ task.init();
+ task.execute();
}
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -18,6 +18,8 @@

package net.dpml.tools.process;

+import net.dpml.tools.model.Context;
+
import net.dpml.tools.tasks.PartTask;

import net.dpml.util.ExceptionHelper;
@@ -33,42 +35,30 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class PluginProcess extends AbstractBuildListener
+public class PluginProcess extends AbstractProcessor
{
- /**
- * Signals that a target is finished.
- *
- * @param event An event with any relevant extra information.
- * Must not be <code>null</code>.
- *
- * @see BuildEvent#getTarget()
- */
- public void targetStarted( BuildEvent event )
+ public void pack( Context context )
{
- Target target = event.getTarget();
- String name = target.getName();
- if( "package".equals( name ) )
+ try
{
- try
- {
- PartTask task = new PartTask();
- Project project = event.getProject();
- task.setProject( project );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String message =
- "Unexpected failure during plugin generation.";
- final String error =
- ExceptionHelper.packException( message, e, true );
- throw new BuildException( error, e );
- }
+ PartTask task = new PartTask();
+ Project project = context.getProject();
+ task.setProject( project );
+ task.setTaskName( "part" );
+ task.init();
+ task.execute();
}
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String message =
+ "Unexpected failure during plugin generation.";
+ final String error =
+ ExceptionHelper.packException( message, e, true );
+ throw new BuildException( error, e );
+ }
}
}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.tools.process;
+
+import net.dpml.library.Resource;
+
+import net.dpml.tools.model.Context;
+
+import net.dpml.tools.tasks.PrepareTask;
+import net.dpml.tools.tasks.InstallTask;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.BuildEvent;
+
+/**
+ * Execute all plugins relative to the current build phase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class StandardProcess extends AbstractProcessor
+{
+ public void initialize( Context context )
+ {
+ context.init();
+ }
+
+ public void prepare( Context context )
+ {
+ context.getProject().log( "commencing preparation",
Project.MSG_VERBOSE );
+ Project project = context.getProject();
+ final PrepareTask task = new PrepareTask();
+ task.setProject( project );
+ task.setTaskName( "prepare" );
+ task.init();
+ task.execute();
+ context.getProject().log( "preparation complete",
Project.MSG_VERBOSE );
+ }
+
+ public void install( Context context )
+ {
+ Project project = context.getProject();
+ final InstallTask task = new InstallTask();
+ task.setProject( project );
+ task.setTaskName( "install" );
+ task.init();
+ task.execute();
+ }
+}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/GenericTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/GenericTask.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/GenericTask.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -21,8 +21,7 @@
import java.io.File;

import net.dpml.tools.model.Context;
-import net.dpml.tools.model.Workbench;
-import net.dpml.tools.impl.DefaultWorkbench;
+import net.dpml.tools.impl.DefaultContext;

import net.dpml.library.Library;
import net.dpml.library.Resource;
@@ -109,57 +108,13 @@
}

/**
- * Return the build workbench.
- * @return the workbench
- */
- protected Workbench getWorkbench()
- {
- Workbench workbench = (Workbench) getProject().getReference(
"project.workbench" );
- if( null != workbench )
- {
- return workbench;
- }
- else
- {
- //
- // We are running under Ant based invocation.
- // Create the library, locate this project, create and set the
context.
- //
-
- String signature = getProject().getProperty( "build.signature" );
- if( null != signature )
- {
- System.setProperty( "build.signature", signature );
- }
-
- try
- {
- Logger logger = new LoggingAdapter();
- DefaultLibrary library = new DefaultLibrary( logger );
- workbench = new DefaultWorkbench( library );
- getProject().addReference( "project.workbench", workbench );
- return workbench;
- }
- catch( BuildException e )
- {
- throw e;
- }
- catch( Exception ioe )
- {
- final String error =
- "Unexpected error while attempting to bootstrap project.";
- throw new RuntimeException( error, ioe );
- }
- }
- }
-
- /**
* Get the project context.
* @return the project context
*/
public Context getContext()
{
- Context context = (Context) getProject().getReference(
"project.context" );
+ Project project = getProject();
+ Context context = (Context) project.getReference( "project.context"
);
if( null != context )
{
return context;
@@ -168,12 +123,8 @@
{
try
{
- Workbench workbench = getWorkbench();
- Library library = workbench.getLibrary();
- File basedir = getProject().getBaseDir();
- Resource resource = library.locate(
basedir.getCanonicalFile() );
- context = workbench.createContext( resource, getProject() );
- getProject().addReference( "project.context", context );
+ context = new DefaultContext( project );
+ project.addReference( "project.context", context );
return context;
}
catch( BuildException e )

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/InitializationTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/InitializationTask.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/InitializationTask.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -27,8 +27,7 @@

import net.dpml.library.Resource;

-import net.dpml.tools.model.Processor;
-import net.dpml.tools.model.ProcessorNotFoundException;
+import net.dpml.tools.model.Context;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildListener;
@@ -48,144 +47,16 @@
* Initialize type to processor mapping. During execution the current
* resource is consulted with respect to the types it declares it
produced.
* Each type is identified by a unique type id. The collection of type
ids
- * are used to resolve an ordered array of build listeners. The build
listener
- * list is established based on the initial type ids combined with any
dependencies
- * declared by respective listeneners. Finally, the sorted listeners are
attached
- * to the current ant project. Targets in the project template trigger
init,
- * prepare, build, package, test and install build events which in-turn
trigger
- * sequentially executed phased functionality within the repective
listeners.
+ * are used to resolve an ordered array of build processors. The build
processor
+ * list is established based on the initial type ids combined with any
processor
+ * dependencies declared by respective processors. Finally, the sorted
processors
+ * are invoked by the standard build listener to handle type production
concerns.
+ * Targets in the project template trigger init, prepare, build, package,
test and
+ * install build events which are monitored by the standard listener
enabling
+ * sequentially executed phased functionality within the repective
processors.
*/
public void execute()
{
- if( null != getProject().getReference(
"project.initialization.timestamp" ) )
- {
- return;
- }
- else
- {
- getProject().addReference( "project.initialization.timestamp",
new Date() );
- }
-
- Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
- Resource resource = getResource();
- log( resource.toString(), Project.MSG_VERBOSE );
- try
- {
- Processor[] processors = getProcessorSequence( resource );
- BuildListener[] listeners = getBuildListeners( processors );
- for( int i=0; i<listeners.length; i++ )
- {
- BuildListener listener = listeners[i];
- getProject().addBuildListener( listener );
- }
- }
- catch( ProcessorInstantiationException e )
- {
- final String error =
- "Processor instantiation error.";
- throw new BuildException( error, e );
- }
+ Context context = getContext(); // triggers context establishment
}
-
- private BuildListener[] getBuildListeners( Processor[] processors )
- throws ProcessorInstantiationException
- {
- BuildListener[] listeners = new BuildListener[ processors.length ];
- for( int i=0; i<processors.length; i++ )
- {
- Processor processor = processors[i];
- String name = processor.getName();
- URI uri = processor.getCodeBaseURI();
- if( null == uri )
- {
- String classname = processor.getClassname();
- if( null == classname )
- {
- final String error =
- "Missing processor uri or classname in processor ["
- + name
- + "].";
- throw new IllegalStateException( error );
- }
-
- try
- {
- ClassLoader classloader = getClass().getClassLoader();
- Class clazz = classloader.loadClass( classname );
- Object[] args = new Object[]{processor};
- listeners[i] = (BuildListener) Plugin.instantiate(
clazz, args );
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to load a local
processor."
- + "\nClass: " + classname
- + "\nName: " + name;
- throw new ProcessorInstantiationException( error, e );
- }
- }
- else
- {
- ClassLoader context =
Thread.currentThread().getContextClassLoader();
- try
- {
- ClassLoader classloader = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(
classloader );
- String classname = processor.getClassname();
- Object[] params = new Object[]{processor};
-
- Part part = Part.load( uri );
- if( null == classname )
- {
- listeners[i] = (BuildListener) part.instantiate(
params );
- }
- else
- {
- ClassLoader loader = part.getClassLoader();
- Class c = loader.loadClass( classname );
- listeners[i] = (BuildListener) Plugin.instantiate(
c, params );
- }
- }
- catch( ClassCastException e )
- {
- final String error =
- "Build processor ["
- + name
- + "] from uri ["
- + uri
- + "] is not a build listener.";
- throw new BuildException( error, getLocation() );
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to load an external
processor."
- + "\nURI: " + uri
- + "\nName: " + name;
- throw new ProcessorInstantiationException( error, e );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( context );
- }
- }
- }
- return listeners;
- }
-
- private Processor[] getProcessorSequence( Resource resource )
- {
- try
- {
- return getWorkbench().getProcessorSequence( resource );
- }
- catch( ProcessorNotFoundException e )
- {
- final String error =
- "Internal referential error while resolving processors for ["
- + resource
- + "]";
- throw new BuildException( error, e );
- }
- }
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -24,7 +24,6 @@
import net.dpml.library.info.Scope;

import net.dpml.tools.model.Context;
-import net.dpml.tools.model.Processor;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -81,7 +80,6 @@
private static final String TARGET_VALUE = "1.4";

private final Context m_context;
- private final Processor m_processor;

private String m_classPathRef;
private Path m_classPath;
@@ -91,9 +89,8 @@
/**
* Creation of a new JavacTask.
* @param context the project context
- * @param processor the associated processor
*/
- public JavacTask( Context context, Processor processor )
+ public JavacTask( Context context )
{
super();
m_context = context;
@@ -101,7 +98,6 @@
{
Resource resource = context.getResource();
setProject( context.getProject() );
- m_processor = processor;
setTaskName( "javac" );
setSrc( context.getTargetBuildMainDirectory() );
setDest( context.getTargetClassesMainDirectory() );
@@ -256,10 +252,6 @@
String value = getContext().getProperty( key );
if( null == value )
{
- value = m_processor.getProperty( key );
- }
- if( null == value )
- {
return fallback;
}
else
@@ -273,10 +265,6 @@
String value = getContext().getProperty( key );
if( null == value )
{
- value = m_processor.getProperty( key );
- }
- if( null == value )
- {
return fallback;
}
else

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PartTask.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -117,6 +117,23 @@
public void writePart( Part part )
{
File file = getOutputFile();
+ if( file.exists() )
+ {
+ try
+ {
+ Part existing = Part.load( new URI( file.toURL().toString()
) );
+ if( part.equals( existing ) )
+ {
+ return;
+ }
+ }
+ catch( Exception e )
+ {
+ // continue
+ }
+ }
+
+ log( "Building part: " + file );
try
{
file.createNewFile();

Modified:
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
===================================================================
---
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
2006-04-17 01:12:05 UTC (rev 1378)
+++
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
2006-04-18 18:09:02 UTC (rev 1379)
@@ -31,7 +31,6 @@
static final String SPEC = "local:plugin:acme/widget";
static final String CLASSNAME = "net.dpml.tools.process.JarProcess";
static final String[] DEPS = new String[0];
- static final boolean ARTIFACT = true;
static final ListenerDirective[] LISTENERS = new ListenerDirective[3];

static
@@ -40,13 +39,13 @@
{
LISTENERS[0] =
new ListenerDirective(
- "jar", (URI) null, CLASSNAME, ARTIFACT, DEPS, PROPERTIES );
+ "jar", (URI) null, CLASSNAME, DEPS, PROPERTIES );
LISTENERS[1] =
new ListenerDirective(
- "acme", new URI( SPEC ), null, ARTIFACT, DEPS, PROPERTIES );
+ "acme", new URI( SPEC ), null, DEPS, PROPERTIES );
LISTENERS[2] =
new ListenerDirective(
- "widget", (URI) null, CLASSNAME, ARTIFACT, new
String[]{"acme"}, PROPERTIES );
+ "widget", (URI) null, CLASSNAME, new String[]{"acme"},
PROPERTIES );
}
catch( Exception e )
{
@@ -64,7 +63,7 @@
try
{
new ListenerDirective(
- null, new URI( SPEC ), CLASSNAME, ARTIFACT, DEPS, PROPERTIES
);
+ null, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -83,7 +82,7 @@
try
{
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, ARTIFACT, null, PROPERTIES
);
+ NAME, new URI( SPEC ), CLASSNAME, null, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -100,7 +99,7 @@
{
ListenerDirective process =
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, ARTIFACT, DEPS, PROPERTIES );
+ NAME, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
assertEquals( "name", NAME, process.getName() );
}

@@ -112,7 +111,7 @@
{
ListenerDirective process =
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, ARTIFACT, DEPS, PROPERTIES );
+ NAME, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
assertEquals( "uri", SPEC, process.getURISpec() );
}

@@ -126,7 +125,7 @@
String dep2 = "def";
String[] deps = new String[]{dep1, dep2};
ListenerDirective process =
- new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, ARTIFACT,
deps, PROPERTIES );
+ new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
assertEquals( "deps", deps, process.getDependencies() );
}

@@ -140,7 +139,7 @@
String dep2 = "def";
String[] deps = new String[]{dep1, dep2};
ListenerDirective process =
- new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, ARTIFACT,
deps, PROPERTIES );
+ new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
doSerializationTest( process );
}


Modified: trunk/main/library.xml
===================================================================
--- trunk/main/library.xml 2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/library.xml 2006-04-18 18:09:02 UTC (rev 1379)
@@ -50,14 +50,14 @@
<feature token="TRANSIT-MODULE-VERSION" ref="dpml/transit"
id="version"/>
<feature token="TRANSIT-HANDLER-URI"
ref="dpml/transit/dpml-transit-main" id="uri" type="jar" />
<feature token="DEPOT-MODULE-VERSION" ref="dpml/depot"
id="version" />
- <feature token="DEPOT-CONSOLE-URI" id="uri" type="jar"
ref="dpml/depot/dpml-depot-console" />
- <feature token="DEPOT-TOOLS-ANT-URI" id="uri" type="part"
ref="dpml/depot/dpml-tools-builder" />
- <feature token="DEPOT-TOOLS-LIBRARY-URI" id="uri" type="jar"
ref="dpml/depot/dpml-library" />
- <feature token="METRO-RUNTIME-URI" id="uri" type="part"
ref="dpml/metro/dpml-metro-runtime" />
- <feature token="METRO-TOOLS-URI" id="uri" type="part"
ref="dpml/metro/dpml-metro-tools" />
- <feature token="UTIL-CLI-URI" id="uri" type="jar"
ref="dpml/util/dpml-util-cli" />
- <feature token="UTIL-I18N-URI" id="uri" type="jar"
ref="dpml/util/dpml-util-i18n" />
- <feature token="UTIL-LOGGING-API-URI" id="uri" type="jar"
ref="dpml/util/dpml-logging-api" />
+ <feature token="DEPOT-CONSOLE-URI"
ref="dpml/depot/dpml-depot-console" id="uri" type="jar" />
+ <feature token="DEPOT-TOOLS-ANT-URI"
ref="dpml/depot/dpml-tools-builder" id="uri" type="part" />
+ <feature token="DEPOT-TOOLS-LIBRARY-URI"
ref="dpml/depot/dpml-library" id="uri" type="jar"/>
+ <feature token="METRO-RUNTIME-URI"
ref="dpml/metro/dpml-metro-runtime" id="uri" type="part"/>
+ <feature token="METRO-TOOLS-URI"
ref="dpml/metro/dpml-metro-tools" id="uri" type="part"/>
+ <feature token="UTIL-CLI-URI" ref="dpml/util/dpml-util-cli"
id="uri" type="jar" />
+ <feature token="UTIL-I18N-URI" ref="dpml/util/dpml-util-i18n"
id="uri" type="jar"/>
+ <feature token="UTIL-LOGGING-API-URI"
ref="dpml/util/dpml-logging-api" id="uri" type="jar"/>
</filters>
</project>


Modified: trunk/main/station/exec/build.xml
===================================================================
--- trunk/main/station/exec/build.xml 2006-04-17 01:12:05 UTC (rev 1378)
+++ trunk/main/station/exec/build.xml 2006-04-18 18:09:02 UTC (rev 1379)
@@ -8,12 +8,6 @@

<available property="metro.exe.available"
file="${dpml.system}/bin/metro.exe"/>

- <target name="build" depends="standard.build">
- <rmic base="${project.target.classes.main.dir}"
classpathref="project.compile.path">
- <include name="**/AbstractAdapter.class"/>
- </rmic>
- </target>
-
<target name="install" depends="bin,standard.install">
<copy todir="${dpml.system}" preservelastmodified="true"
overwrite="true">
<fileset dir="target">




  • r1379 - in trunk/main: . central/src/docs/about/download central/src/docs/depot central/src/docs/depot/library central/src/docs/depot/tools central/src/docs/metro central/src/docs/transit depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info station/exec, mcconnell at BerliOS, 04/18/2006

Archive powered by MHonArc 2.6.24.

Top of Page