notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1818 - in trunk/main/depot: . build build/etc build/etc/bin build/etc/bootstrap build/src/main build/src/main/dpml build/src/main/dpml/build library library/etc/data library/etc/data/ant library/etc/data/commons-cli library/etc/data/dpml library/etc/data/jgoodies library/etc/data/junit library/etc/data/samples library/etc/data/xstream library/src/main library/src/main/dpml/library library/src/main/dpml/library/impl library/src/main/dpml/library/info library/src/test library/src/test/dpml/library library/src/test/dpml/library/impl library/src/test/dpml/library/info library/src/test/net plugins plugins/checkstyle plugins/checkstyle/etc plugins/checkstyle/src/main plugins/checkstyle/src/main/dpml/tools/checkstyle plugins/checkstyle/src/main/net plugins/convert plugins/convert/etc plugins/convert/src/main plugins/convert/src/main/net tools tools/etc tools/etc/bootstrap tools/etc/prefs/templates tools/etc/prefs/xmls tools/src/main tools/src/main/dpml/tools tools/src/mai! n/dpml/tools/impl tools/src/main/dpml/tools/info tools/src/main/dpml/tools/tasks tools/src/main/dpml/tools/transit tools/src/test tools/src/test/dpml/tools/info
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1818 - in trunk/main/depot: . build build/etc build/etc/bin build/etc/bootstrap build/src/main build/src/main/dpml build/src/main/dpml/build library library/etc/data library/etc/data/ant library/etc/data/commons-cli library/etc/data/dpml library/etc/data/jgoodies library/etc/data/junit library/etc/data/samples library/etc/data/xstream library/src/main library/src/main/dpml/library library/src/main/dpml/library/impl library/src/main/dpml/library/info library/src/test library/src/test/dpml/library library/src/test/dpml/library/impl library/src/test/dpml/library/info library/src/test/net plugins plugins/checkstyle plugins/checkstyle/etc plugins/checkstyle/src/main plugins/checkstyle/src/main/dpml/tools/checkstyle plugins/checkstyle/src/main/net plugins/convert plugins/convert/etc plugins/convert/src/main plugins/convert/src/main/net tools tools/etc tools/etc/bootstrap tools/etc/prefs/templates tools/etc/prefs/xmls tools/src/main tools/src/main/dpml/tools tools/src/mai! n/dpml/tools/impl tools/src/main/dpml/tools/info tools/src/main/dpml/tools/tasks tools/src/main/dpml/tools/transit tools/src/test tools/src/test/dpml/tools/info
- Date: Fri, 9 Feb 2007 00:31:42 +0100
Author: mcconnell
Date: 2007-02-09 00:31:25 +0100 (Fri, 09 Feb 2007)
New Revision: 1818
Added:
trunk/main/depot/build/etc/bin/build.policy
trunk/main/depot/build/etc/bootstrap/
trunk/main/depot/build/etc/bootstrap/part.link
trunk/main/depot/build/etc/bootstrap/part.xml
trunk/main/depot/build/etc/component.xml
trunk/main/depot/build/project.xml
trunk/main/depot/build/src/main/dpml/
trunk/main/depot/build/src/main/dpml/build/
trunk/main/depot/build/src/main/dpml/build/BuildError.java
trunk/main/depot/build/src/main/dpml/build/Builder.java
trunk/main/depot/build/src/main/dpml/build/Main.java
trunk/main/depot/library/etc/data/logging.properties
trunk/main/depot/library/project.xml
trunk/main/depot/library/src/main/dpml/
trunk/main/depot/library/src/main/dpml/library/Classifier.java
trunk/main/depot/library/src/main/dpml/library/Local.java
trunk/main/depot/library/src/main/dpml/library/ProjectLocation.java
trunk/main/depot/library/src/main/dpml/library/Scope.java
trunk/main/depot/library/src/main/dpml/library/impl/DefaultType.java
trunk/main/depot/library/src/main/dpml/library/info/ProductionPolicy.java
trunk/main/depot/library/src/main/dpml/library/package-info.java
trunk/main/depot/library/src/test/dpml/
trunk/main/depot/plugins/checkstyle/etc/resource.xml
trunk/main/depot/plugins/checkstyle/project.xml
trunk/main/depot/plugins/checkstyle/src/main/dpml/
trunk/main/depot/plugins/convert/build.xml
trunk/main/depot/plugins/convert/etc/
trunk/main/depot/plugins/convert/etc/resource.xml
trunk/main/depot/plugins/convert/project.xml
trunk/main/depot/plugins/convert/src/main/dpml/
trunk/main/depot/tools/CHANGES.TXT
trunk/main/depot/tools/etc/component.xml
trunk/main/depot/tools/project.xml
trunk/main/depot/tools/src/main/dpml/
trunk/main/depot/tools/src/main/dpml/tools/BuilderError.java
trunk/main/depot/tools/src/main/dpml/tools/antlib.xml
trunk/main/depot/tools/src/main/dpml/tools/transit/
trunk/main/depot/tools/src/main/dpml/tools/transit/AntAdapter.java
trunk/main/depot/tools/src/main/dpml/tools/transit/GetTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/ImportArtifactTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/MainTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/MapDataType.java
trunk/main/depot/tools/src/main/dpml/tools/transit/NodeTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/PluginTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/TransitComponentHelper.java
trunk/main/depot/tools/src/main/dpml/tools/transit/TransitTask.java
trunk/main/depot/tools/src/main/dpml/tools/transit/antlib.xml
trunk/main/depot/tools/src/main/dpml/tools/transit/package.html
trunk/main/depot/tools/src/test/dpml/
Removed:
trunk/main/depot/build/build.xml
trunk/main/depot/build/src/main/dpml/library/
trunk/main/depot/build/src/main/net/
trunk/main/depot/core/
trunk/main/depot/library/build.xml
trunk/main/depot/library/src/main/dpml/library/Builder.java
trunk/main/depot/library/src/main/dpml/library/Data.java
trunk/main/depot/library/src/main/dpml/library/TypeBuilder.java
trunk/main/depot/library/src/main/dpml/library/info/DataDirective.java
trunk/main/depot/library/src/main/dpml/library/package.html
trunk/main/depot/library/src/main/net/
trunk/main/depot/library/src/test/dpml/library/impl/ExportTestCase.java
trunk/main/depot/library/src/test/net/dpml/
trunk/main/depot/plugins/checkstyle/src/main/net/dpml/
trunk/main/depot/plugins/convert/src/main/net/dpml/
trunk/main/depot/test/
trunk/main/depot/tools/src/main/dpml/tools/BuildError.java
trunk/main/depot/tools/src/main/dpml/tools/impl/BuilderError.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/PartTask.java
trunk/main/depot/tools/src/main/net/
trunk/main/depot/tools/src/test/net/
Modified:
trunk/main/depot/build.xml
trunk/main/depot/build/bootstrap.xml
trunk/main/depot/build/etc/bin/build
trunk/main/depot/build/etc/bin/build.lap
trunk/main/depot/library/bootstrap.properties
trunk/main/depot/library/bootstrap.xml
trunk/main/depot/library/etc/data/ant/module.xml
trunk/main/depot/library/etc/data/commons-cli/module.xml
trunk/main/depot/library/etc/data/dpml/module.xml
trunk/main/depot/library/etc/data/jgoodies/module.xml
trunk/main/depot/library/etc/data/junit/module.xml
trunk/main/depot/library/etc/data/library.xml
trunk/main/depot/library/etc/data/samples/absolute.xml
trunk/main/depot/library/etc/data/samples/anonymous.xml
trunk/main/depot/library/etc/data/samples/duplicates.xml
trunk/main/depot/library/etc/data/samples/example-1.xml
trunk/main/depot/library/etc/data/samples/example-2.xml
trunk/main/depot/library/etc/data/samples/example-3.xml
trunk/main/depot/library/etc/data/samples/example-4.xml
trunk/main/depot/library/etc/data/samples/example-5.xml
trunk/main/depot/library/etc/data/samples/example-6.xml
trunk/main/depot/library/etc/data/samples/example-7.xml
trunk/main/depot/library/etc/data/samples/example-8.xml
trunk/main/depot/library/etc/data/samples/filters.xml
trunk/main/depot/library/etc/data/samples/info.xml
trunk/main/depot/library/etc/data/samples/jar-type.xml
trunk/main/depot/library/etc/data/samples/properties.xml
trunk/main/depot/library/etc/data/samples/widget.xml
trunk/main/depot/library/etc/data/xstream/module.xml
trunk/main/depot/library/src/main/dpml/library/Dictionary.java
trunk/main/depot/library/src/main/dpml/library/DuplicateNameException.java
trunk/main/depot/library/src/main/dpml/library/Feature.java
trunk/main/depot/library/src/main/dpml/library/FeatureRuntimeException.java
trunk/main/depot/library/src/main/dpml/library/Filter.java
trunk/main/depot/library/src/main/dpml/library/Info.java
trunk/main/depot/library/src/main/dpml/library/Library.java
trunk/main/depot/library/src/main/dpml/library/Module.java
trunk/main/depot/library/src/main/dpml/library/ModuleNotFoundException.java
trunk/main/depot/library/src/main/dpml/library/ReferentialException.java
trunk/main/depot/library/src/main/dpml/library/Resource.java
trunk/main/depot/library/src/main/dpml/library/ResourceNotFoundException.java
trunk/main/depot/library/src/main/dpml/library/Type.java
trunk/main/depot/library/src/main/dpml/library/TypeNotFoundException.java
trunk/main/depot/library/src/main/dpml/library/impl/DefaultDictionary.java
trunk/main/depot/library/src/main/dpml/library/impl/DefaultLibrary.java
trunk/main/depot/library/src/main/dpml/library/impl/DefaultModule.java
trunk/main/depot/library/src/main/dpml/library/impl/DefaultResource.java
trunk/main/depot/library/src/main/dpml/library/impl/InvalidNameException.java
trunk/main/depot/library/src/main/dpml/library/impl/InvalidProcessorNameException.java
trunk/main/depot/library/src/main/dpml/library/impl/InvalidTypeNameException.java
trunk/main/depot/library/src/main/dpml/library/info/AbstractDirective.java
trunk/main/depot/library/src/main/dpml/library/info/DependencyDirective.java
trunk/main/depot/library/src/main/dpml/library/info/FeatureFilterDirective.java
trunk/main/depot/library/src/main/dpml/library/info/FilterDirective.java
trunk/main/depot/library/src/main/dpml/library/info/ImportDirective.java
trunk/main/depot/library/src/main/dpml/library/info/IncludeDirective.java
trunk/main/depot/library/src/main/dpml/library/info/InfoDirective.java
trunk/main/depot/library/src/main/dpml/library/info/LibraryConstants.java
trunk/main/depot/library/src/main/dpml/library/info/LibraryDecoder.java
trunk/main/depot/library/src/main/dpml/library/info/LibraryDirective.java
trunk/main/depot/library/src/main/dpml/library/info/LibraryEncoder.java
trunk/main/depot/library/src/main/dpml/library/info/ModuleDirective.java
trunk/main/depot/library/src/main/dpml/library/info/ResourceDirective.java
trunk/main/depot/library/src/main/dpml/library/info/Scope.java
trunk/main/depot/library/src/main/dpml/library/info/SimpleFilterDirective.java
trunk/main/depot/library/src/main/dpml/library/info/TypeDirective.java
trunk/main/depot/library/src/main/dpml/library/info/TypeUnknownException.java
trunk/main/depot/library/src/main/dpml/library/info/ValidationException.java
trunk/main/depot/library/src/test/dpml/library/XMLTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/AbsoluteTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/AbstractTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/AnonymousTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/DefaultDictionaryTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/DefaultLibraryTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/DefaultModuleTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/DefaultResourceTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/DuplicatesTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/FiltersTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/InfoTestCase.java
trunk/main/depot/library/src/test/dpml/library/impl/PropertiesTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/AbstractTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/DependencyDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/ImportDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/IncludeDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/InfoDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/LibraryDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/ModuleDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/ResourceDirectiveTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/ScopeTestCase.java
trunk/main/depot/library/src/test/dpml/library/info/TypeDirectiveTestCase.java
trunk/main/depot/module.xml
trunk/main/depot/plugins/
trunk/main/depot/plugins/checkstyle/build.xml
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/CheckstyleTask.java
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/antlib.xml
trunk/main/depot/tools/bootstrap.properties
trunk/main/depot/tools/bootstrap.xml
trunk/main/depot/tools/build.xml
trunk/main/depot/tools/etc/bootstrap/builder.xml
trunk/main/depot/tools/etc/prefs/templates/standard.template
trunk/main/depot/tools/etc/prefs/xmls/builder.xml
trunk/main/depot/tools/src/main/dpml/tools/Context.java
trunk/main/depot/tools/src/main/dpml/tools/impl/DefaultContext.java
trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuildListener.java
trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuilder.java
trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirective.java
trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirectiveHelper.java
trunk/main/depot/tools/src/main/dpml/tools/info/ListenerDirective.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/BuildTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/CleanTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/DocTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/FeatureTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/FilterTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/GenericTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/InitializationTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/InstallTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/JUnitTestTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/JarTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/JavacTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/JavadocTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/ModuleTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/PackageTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/PluginTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/PrepareTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/ProcessorInstantiationException.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/PropertyTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/RMICTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/ReactorTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/ReplicateTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/ResourceTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/TestTask.java
trunk/main/depot/tools/src/main/dpml/tools/tasks/antlib.xml
trunk/main/depot/tools/src/test/dpml/tools/info/AbstractTestCase.java
trunk/main/depot/tools/src/test/dpml/tools/info/ListenerDirectiveTestCase.java
Log:
SDK 2.X initial commit.
Modified: trunk/main/depot/build/bootstrap.xml
===================================================================
--- trunk/main/depot/build/bootstrap.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/build/bootstrap.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -1,20 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="dpml-library-console" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
+<project name="dpml-depot-build" default="install" basedir=".">
- <transit:import uri="local:template:dpml/tools/standard"/>
+ <property name="project.group" value="dpml/depot"/>
+ <property name="project.name" value="dpml-depot-build"/>
- <available property="builder.exe.available"
file="${dpml.system}/bin/build.exe"/>
+ <property name="home" value="../.."/>
+ <import file="${home}/bootstrap.xml"/>
+
+ <target name="init" depends="bootstrap.init">
+ <filter token="PROJECT-NAME" value="${project.name}" />
+ <filter token="PROJECT-GROUP" value="${project.group}"/>
+ <filter token="PROJECT-VERSION" value="${project.version}"/>
+ <filter token="DEPOT-BUILDER-URI"
value="link:part:dpml/depot/dpml-depot-builder"/>
+ </target>
+
+ <target name="setup-path" depends="bootstrap.setup-path">
+ <path id="project.main.path">
+ <pathelement
location="${dpml.local.cache}/dpml/transit/jars/dpml-transit-main-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/lang/jars/dpml-lang-part-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/depot/jars/dpml-depot-library-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/util/jars/dpml-util-cli-BOOTSTRAP.jar"/>
+ <pathelement location="${target.classes.dir}"/>
+ </path>
+ <path id="project.test.path">
+ <path refid="project.main.path"/>
+ <pathelement
location="${dpml.local.cache}/junit/jars/${junit.filename}"/>
+ <pathelement
location="${target.deliverables.jars.dir}/${project.filename}"/>
+ </path>
+ </target>
- <target name="install" depends="bin,standard.install">
- <copy todir="${dpml.system}" preservelastmodified="true"
overwrite="true">
- <fileset dir="target">
- <include name="bin/build.lap"/>
- <include name="bin/build"/>
+ <target name="package" depends="bootstrap.package">
+ <mkdir dir="${target.deliverables.dir}/parts"/>
+ <move file="${target.dir}/bootstrap/part.xml"
+
toFile="${target.deliverables.dir}/parts/${project.name}-${project.version}.part"/>
+ <move file="${target.dir}/bootstrap/part.link"
+ toFile="${target.deliverables.dir}/parts/${project.name}.part.link"/>
+ </target>
+
+ <target name="install" depends="bootstrap.install">
+ <mkdir dir="${dpml.system}/bin"/>
+ <copy todir="${dpml.system}/bin" preservelastmodified="true"
overwrite="true">
+ <fileset dir="target/bin">
+ <include name="build"/>
+ <include name="build.lap"/>
+ <include name="build.policy"/>
</fileset>
</copy>
+ <copy todir="${dpml.system}/bin" preservelastmodified="true"
overwrite="true" filtering="false">
+ <fileset dir="etc/bin">
+ <include name="build.exe"/>
+ </fileset>
+ </copy>
<chmod perm="755">
<fileset dir="${dpml.system}/bin">
<include name="build"/>
@@ -22,12 +59,14 @@
</chmod>
</target>
- <target name="bin" depends="standard.install"
unless="builder.exe.available">
+ <!--
+ <target name="bin" depends="bootstrap.install"
unless="builder.exe.available">
<copy todir="${dpml.system}" preservelastmodified="true">
- <fileset dir="target">
- <include name="bin/build.exe"/>
+ <fileset dir="${basedir}/etc/bin">
+ <include name="build.exe"/>
</fileset>
</copy>
</target>
-
+ -->
+
</project>
Deleted: trunk/main/depot/build/build.xml
===================================================================
--- trunk/main/depot/build/build.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/build/build.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-library-console" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
-
- <transit:import uri="local:template:dpml/tools/standard"/>
-
-</project>
Modified: trunk/main/depot/build/etc/bin/build
===================================================================
--- trunk/main/depot/build/etc/bin/build 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/build/etc/bin/build 2007-02-08 23:31:25 UTC (rev
1818)
@@ -2,7 +2,7 @@
# Copyright 2005-2006 Stephen J. McConnell
#
-BUILD_JVM_OPTS="-Ddpml.transit.include.tools=true
-Ddpml.depot.application=dpml.builder"
+BUILD_JVM_OPTS="-Ddpml.transit.include.tools=true
-Ddpml.depot.application=link:part:dpml/depot/dpml-depot-build"
if [ "$DEPOT_JVM_OPTS" = "" ] ; then
DEPOT_JVM_OPTS=$BUILD_JVM_OPTS
Modified: trunk/main/depot/build/etc/bin/build.lap
===================================================================
--- trunk/main/depot/build/etc/bin/build.lap 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/build/etc/bin/build.lap 2007-02-08 23:31:25 UTC (rev
1818)
@@ -1,17 +1,19 @@
#
# This file contains the runtime configuration of the Janel java launcher
application.
-# Copyright 2005-2006 Stephen J. McConnell
+# Copyright 2005-2007 Stephen J. McConnell
#
--Ddpml.transit.include.tools=true
--Djava.system.class.loader=net.dpml.lang.SystemClassLoader
--Djava.security.policy=${env.DPML_HOME}\share\bin\security.policy
+janel.java.bundle=require_sdk
+janel.main.class=dpml.util.Main
+janel.min.java.version=1.6.0
+janel.sysprop.process.id=true
+-Djava.ext.dirs=${env.DPML_HOME}\share\lib\ext
-Djava.endorsed.dirs=${env.DPML_HOME}\share\lib\endorsed
--Ddpml.depot.application=dpml.builder
--Djava.protocol.handler.pkgs=net.dpml.transit
+-Djava.system.class.loader=dpml.util.SystemClassLoader
+-Djava.security.policy=${env.DPML_HOME}\share\bin\build.policy
+-Djava.protocol.handler.pkgs=dpml.transit
+-Djava.rmi.server.RMIClassLoaderSpi=dpml.util.FederatingClassLoader
-Dcom.sun.management.jmxremote
-janel.main.class=net.dpml.depot.Main
-janel.min.java.version=1.4.0
-janel.classpath.jars.dir=${env.DPML_HOME}\share\lib
-janel.sysprop.process.id=true
-janel.java.bundle=require_sdk
+-Ddpml.class.path=link:jar:dpml/lang/dpml-lang-part
+-Ddpml.transit.include.tools=true
+-Ddpml.depot.application=link:part:dpml/depot/dpml-depot-build
Added: trunk/main/depot/build/etc/bin/build.policy
===================================================================
--- trunk/main/depot/build/etc/bin/build.policy 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/build/etc/bin/build.policy 2007-02-08 23:31:25 UTC (rev
1818)
@@ -0,0 +1,4 @@
+grant {
+ permission java.security.AllPermission;
+};
+
Added: trunk/main/depot/build/etc/bootstrap/part.link
===================================================================
--- trunk/main/depot/build/etc/bootstrap/part.link 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/build/etc/bootstrap/part.link 2007-02-08 23:31:25
UTC (rev 1818)
@@ -0,0 +1 @@
+artifact:part:@PROJECT-GROUP@/@PROJECT-NAME@#@PROJECT-VERSION@
\ No newline at end of file
Added: trunk/main/depot/build/etc/bootstrap/part.xml
===================================================================
--- trunk/main/depot/build/etc/bootstrap/part.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/build/etc/bootstrap/part.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<part xmlns="dpml:part">
+
+ <info title="Depot Build Tool">
+ <description>
+ Depot Build CLI Handler.
+ </description>
+ </info>
+
+ <component xmlns="dpml:metro" type="dpml.build.Main"
+ handler="net.dpml.runtime.ComponentStrategyHandler"/>
+
+ <classpath>
+ <private>
+ <uri>artifact:jar:dpml/transit/dpml-transit-main#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/lang/dpml-lang-part#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/depot/dpml-depot-library#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/util/dpml-util-cli#BOOTSTRAP</uri>
+ <uri>artifact:jar:@PROJECT-GROUP@/@PROJECT-NAME@#BOOTSTRAP</uri>
+ </private>
+ </classpath>
+
+</part>
Added: trunk/main/depot/build/etc/component.xml
===================================================================
--- trunk/main/depot/build/etc/component.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/build/etc/component.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<component xmlns="dpml:metro" name="build" type="dpml.build.Main"/>
Added: trunk/main/depot/build/project.xml
===================================================================
--- trunk/main/depot/build/project.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/build/project.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project xmlns="dpml:library" name="dpml-depot-build">
+
+ <info title="DPML Depot Build Tool">
+ <description>Multi-project build automation tool.</description>
+ </info>
+
+ <types>
+ <type id="jar"/>
+ <type id="part" alias="true" source="target/component.xml"/>
+ </types>
+
+ <dependencies>
+ <runtime>
+ <include ref="dpml/lang/dpml-lang-part"/>
+ <include ref="dpml/depot/dpml-depot-library"/>
+ <include ref="dpml/util/dpml-util-cli"/>
+ </runtime>
+ <test>
+ <include ref="org/apache/ant/ant-junit"/>
+ </test>
+ </dependencies>
+
+ <filters>
+ <feature token="DEPOT-BUILDER-URI" ref="dpml/depot/dpml-depot-builder"
id="uri" type="part" alias="true"/>
+ </filters>
+
+</project>
Copied: trunk/main/depot/build/src/main/dpml (from rev 1789,
trunk/main/depot/build/src/main/net/dpml)
Added: trunk/main/depot/build/src/main/dpml/build/BuildError.java
===================================================================
--- trunk/main/depot/build/src/main/net/dpml/build/BuildError.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/build/src/main/dpml/build/BuildError.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,38 @@
+/*
+ * 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 dpml.build;
+
+/**
+ * A BuilderError is thrown if an error occurs while attempting to establish
a plugin builder..
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class BuildError extends Error
+{
+ /**
+ * Creation of a new BuilderError.
+ * @param message the exception message
+ * @param cause the causal excetion
+ */
+ public BuildError( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
Added: trunk/main/depot/build/src/main/dpml/build/Builder.java
===================================================================
--- trunk/main/depot/build/src/main/net/dpml/build/Builder.java 2006-11-30
21:08:46 UTC (rev 1789)
+++ trunk/main/depot/build/src/main/dpml/build/Builder.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005-2007 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 dpml.build;
+
+import dpml.library.Resource;
+
+/**
+ * A Builder is an interface implementated by a plugin that handles the
building of
+ * a project.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Builder
+{
+ /**
+ * Build a resource.
+ *
+ * @param resource the resource to build
+ * @param targets build target names
+ * @return the success status of the build
+ * @exception Exception if a builder implementation error occurs
+ */
+ boolean build( Resource resource, String[] targets ) throws Exception;
+
+}
Added: trunk/main/depot/build/src/main/dpml/build/Main.java
===================================================================
--- trunk/main/depot/build/src/main/net/dpml/build/Main.java 2006-11-30
21:08:46 UTC (rev 1789)
+++ trunk/main/depot/build/src/main/dpml/build/Main.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,736 @@
+/*
+ * Copyright 2005-2007 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 dpml.build;
+
+import dpml.cli.Option;
+import dpml.cli.Group;
+import dpml.cli.CommandLine;
+import dpml.cli.commandline.Parser;
+import dpml.cli.util.HelpFormatter;
+import dpml.cli.OptionException;
+import dpml.cli.DisplaySetting;
+import dpml.cli.builder.ArgumentBuilder;
+import dpml.cli.builder.GroupBuilder;
+import dpml.cli.builder.DefaultOptionBuilder;
+import dpml.cli.builder.CommandBuilder;
+import dpml.cli.option.PropertyOption;
+import dpml.cli.validation.URIValidator;
+
+import dpml.build.Builder;
+
+import dpml.library.impl.DefaultLibrary;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.EnumSet;
+import java.util.Collections;
+
+import javax.tools.Tool;
+import javax.lang.model.SourceVersion;
+
+import static net.dpml.annotation.LifestylePolicy.SINGLETON;
+
+import net.dpml.lang.Strategy;
+import net.dpml.lang.ServiceRegistry;
+import net.dpml.lang.SimpleServiceRegistry;
+
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Type;
+import dpml.library.Classifier;
+import dpml.library.Scope;
+import dpml.library.Library;
+
+import net.dpml.util.Logger;
+
+/**
+ * Tool providing project info listing and supports delegation of project
+ * building to a builder plugin.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class Main implements Tool
+{
+ //
------------------------------------------------------------------------
+ // static
+ //
------------------------------------------------------------------------
+
+ private static final URI BUILD_IMPLEMENTATION_URI;
+
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ private final Logger m_logger;
+ private final DefaultLibrary m_library;
+ private final Map m_map = new Hashtable();
+
+ private boolean m_verbose;
+ private boolean m_expand = false;
+
+ //
------------------------------------------------------------------------
+ // constructors
+ //
------------------------------------------------------------------------
+
+ /**
+ * Builder establishment. System property have already been assigned
+ * to the current jvm by depot.
+ *
+ * @param logger the assigned logging channel
+ * @exception Exception if the build fails
+ */
+ public Main( Logger logger ) throws Exception
+ {
+ m_logger = logger;
+ m_library = new DefaultLibrary( logger );
+ }
+
+ //
------------------------------------------------------------------------
+ // implementation
+ //
------------------------------------------------------------------------
+
+ /**
+ * Return the source versions supported by this tool.
+ * @return the set of source java versions
+ */
+ public Set<SourceVersion> getSourceVersions()
+ {
+ return Collections.unmodifiableSet(
+ EnumSet.range(
+ SourceVersion.RELEASE_0,
+ SourceVersion.latest() ) );
+ }
+
+ /**
+ * Run the build tool.
+ * @param in the input stream
+ * @param out the output stream
+ * @param err the error stream
+ * @param arguments the tool arguments
+ */
+ public int run( InputStream in, OutputStream out, OutputStream err,
String... arguments )
+ {
+ try
+ {
+ return execute( arguments );
+ }
+ catch( Throwable e )
+ {
+ m_logger.error( "Build error.", e );
+ return -1;
+ }
+ }
+
+ private int execute( String... args ) throws Exception
+ {
+ if( m_logger.isTraceEnabled() )
+ {
+ m_logger.trace( "Initializing builder with " + args.length + "
args." );
+ for( String arg : args )
+ {
+ m_logger.trace( "\t" + arg );
+ }
+ }
+
+ Thread.currentThread().setContextClassLoader(
Builder.class.getClassLoader() );
+
+ CommandLine line = getCommandLine( args );
+ m_verbose = line.hasOption( VERBOSE_OPTION );
+
+ // setup the build version
+
+ if( line.hasOption( VERSION_OPTION ) )
+ {
+ String version = (String) line.getValue( VERSION_OPTION,
"SNAPSHOT" );
+ System.setProperty( "build.signature", version );
+ if( m_verbose )
+ {
+ m_logger.info( "Setting version to: " + version );
+ }
+ }
+
+ if( line.hasOption( DECIMAL_OPTION ) )
+ {
+ System.setProperty( Resource.DECIMAL_VERSIONING_KEY, "true" );
+ if( m_verbose )
+ {
+ m_logger.info( "Enabling decimal versioning." );
+ }
+ }
+
+ try
+ {
+ if( line.hasOption( HELP_OPTION ) )
+ {
+ processHelp();
+ return 0;
+ }
+ else
+ {
+ if( line.hasOption( LIST_OPTION ) )
+ {
+ m_expand = line.hasOption( EXPAND_OPTION );
+ Resource[] resources = getTargetSelection( line );
+ if( resources.length == 0 )
+ {
+ m_logger.info( "Empty selection." );
+ return 0;
+ }
+ else
+ {
+ list( resources );
+ return 0;
+ }
+ }
+ else
+ {
+ Resource[] resources = getSelection( line );
+ if( resources.length == 0 )
+ {
+ m_logger.error( "Empty selection." );
+ return -1;
+ }
+ return process( line, resources );
+ }
+ }
+ }
+ catch( OptionException e )
+ {
+ m_logger.error( e.getMessage() );
+ return -1;
+ }
+ }
+
+ private CommandLine getCommandLine( String[] args ) throws Exception
+ {
+ Parser parser = new Parser();
+ parser.setGroup( COMMAND_GROUP );
+ return parser.parse( args );
+ }
+
+ /**
+ * Resolve the project selection taking into account any overriding -s
+ * selection option, the -c switch, or in the absence of a selction, the
+ * implicit slection relative to the current working directory.
+ *
+ * @param line the commandline
+ * @return the resolved array of resources sorted relative to build
sequence
+ */
+ private Resource[] getSelection( CommandLine line ) throws Exception
+ {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ Resource[] targets = getTargetSelection( line );
+ for( int i=0; i<targets.length; i++ )
+ {
+ Resource project = targets[i];
+ if( Classifier.LOCAL.equals( project.getClassifier() ) )
+ {
+ list.add( project );
+ }
+ }
+ return list.toArray( new Resource[ list.size() ] );
+ }
+
+ /**
+ * Get the base selection and check if the consumer switch is present and
+ * if so build the consumers list from the selection list.
+ *
+ * @param line the commandline
+ * @return the array of projects in build order
+ */
+ private Resource[] getTargetSelection( CommandLine line ) throws
Exception
+ {
+ Resource[] resources = getBaseSelection( line );
+ if( resources.length == 0 )
+ {
+ return resources;
+ }
+ boolean flag = line.hasOption( CONSUMERS_OPTION );
+ if( flag )
+ {
+ if( resources.length != 1 )
+ {
+ final String error =
+ "Consumer resolution against a multi-element selection is
not supported.";
+ getLogger().error( error );
+ return new Resource[0];
+ }
+ else
+ {
+ Resource resource = resources[0];
+ return resource.getConsumers( true, true );
+ }
+ }
+ else
+ {
+ return resources;
+ }
+ }
+
+ /**
+ * Get the set of projects taking into consideration either the
+ * overriding selection option or the base directory if no selection
specificed.
+ *
+ * @param line the commandline
+ * @return the array of projects in build order
+ */
+ private Resource[] getBaseSelection( CommandLine line ) throws Exception
+ {
+ String selection = (String) line.getValue( SELECT_OPTION, null );
+ if( null != selection )
+ {
+ getLogger().debug( "parsing selection: " + selection );
+ Resource[] resources = m_library.select( selection, false, true
);
+ getLogger().debug( "selection: " + resources.length );
+ return resources;
+ }
+ else
+ {
+ String work = System.getProperty( "user.dir" );
+ getLogger().debug( "resolving selection in: " + work );
+ File file = new File( work ).getCanonicalFile();
+ Resource[] resources = m_library.select( file );
+ return resources;
+ }
+ }
+
+ /**
+ * Build the supplied set of projects. If a build filure occurs then
+ * abort the build sequence and exit.
+ *
+ * @param line the commandline
+ * @param resources the sorted sequence of projects to build
+ * @return the exit value
+ */
+ private int process( CommandLine line, Resource[] resources )
+ {
+ boolean validation = line.hasOption( VALIDATE_OPTION );
+ if( validation )
+ {
+ System.setProperty( "project.validation.enabled", "true" );
+ }
+
+ URI uri = (URI) line.getValue( BUILDER_URI_OPTION,
BUILD_IMPLEMENTATION_URI );
+
+
+ ServiceRegistry registry =
+ new SimpleServiceRegistry(
+ m_logger,
+ m_library,
+ new Boolean( m_verbose ) );
+
+ Strategy strategy = loadBuilderStrategy( registry, uri );
+ Builder builder = strategy.getInstance( Builder.class );
+
+ if( resources.length > 1 )
+ {
+ StringBuffer buffer =
+ new StringBuffer( "Initiating build sequence: (" +
resources.length + ")\n" );
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource resource = resources[i];
+ buffer.append( "\n (" + ( i+1 ) + ")\t" +
resource.getResourcePath() );
+ }
+ buffer.append( "\n" );
+ getLogger().info( buffer.toString() );
+ }
+
+ List<?> list = line.getValues( TARGETS );
+ String[] targets = (String[]) list.toArray( new String[ list.size()
] );
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource resource = resources[i];
+ try
+ {
+ boolean success = builder.build( resource, targets );
+ if( !success )
+ {
+ return -1;
+ }
+ }
+ catch( Throwable e )
+ {
+ System.out.println( "# BUILD: " + e.toString() );
+ final String error =
+ "Unexpected error while building project ["
+ + resource.getResourcePath()
+ + "] under the basedir ["
+ + resource.getBaseDir()
+ + "].";
+ getLogger().error( error, e );
+ return -1;
+ }
+ }
+ return 0;
+ }
+
+ private Strategy loadBuilderStrategy( final ServiceRegistry registry,
final URI uri )
+ {
+ try
+ {
+ ClassLoader classloader = Builder.class.getClassLoader();
+ return Strategy.load( classloader, registry, uri, null );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to load the builder plugin
from the uri ["
+ + uri
+ + "].";
+ throw new BuildError( error, e );
+ }
+ }
+
+ /**
+ * Build the supplied set of projects. If a build filure occurs then
+ * abort the build sequence and exit.
+ *
+ * @param resources the sorted sequence of prouject to build
+ * @exception Exception if an error occurs
+ */
+ private void list( Resource[] resources ) throws Exception
+ {
+ if( resources.length == 1 )
+ {
+ Resource resource = resources[0];
+ if( resource instanceof Module )
+ {
+ listModule( (Module) resource );
+ }
+ else
+ {
+ listResource( resource );
+ }
+ }
+ else
+ {
+ listResources( resources );
+ }
+ }
+
+ private void listModule( Module module ) throws Exception
+ {
+ print( "Listing module [" + module.getResourcePath() + "]\n" );
+ listResource( " ", module, 0 );
+ print( "" );
+ }
+
+ private void listResource( Resource project ) throws Exception
+ {
+ print( "Listing project: " + project.getResourcePath() + "\n" );
+ listResource( " ", project, 0 );
+ print( "" );
+ }
+
+ private void listResources( Resource[] resources ) throws Exception
+ {
+ print( "Selection: [" + resources.length + "]\n" );
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource resource = resources[i];
+ String label = getLabel( i+1 );
+ print( label + resource );
+ }
+ print( "" );
+ }
+
+
+ private void listResource( String pad, Resource resource, int n ) throws
Exception
+ {
+ if( n > 0 )
+ {
+ print( "\n[" + n + "] " + resource );
+ }
+ else
+ {
+ print( "\n" + resource );
+ }
+ print( "" );
+ if( null != resource.getVersion() )
+ {
+ print( pad + "version: " + resource.getVersion() );
+ }
+ print( pad + "basedir: " + resource.getBaseDir() );
+ String p = pad + " ";
+ Type[] types = resource.getTypes();
+ if( types.length > 0 )
+ {
+ print( pad + "types: (" + types.length + ")" );
+ for( int i=0; i<types.length; i++ )
+ {
+ Type type = types[i];
+ print( p + type.getID() );
+ }
+ }
+
+ Resource[] resources = resource.getProviders( Scope.BUILD, m_expand,
true );
+ if( resources.length > 0 )
+ {
+ print( pad + "build phase providers: (" + resources.length + ")"
);
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource res = resources[i];
+ print( p + res );
+ }
+ }
+ resources = resource.getProviders( Scope.RUNTIME, m_expand, true );
+ if( resources.length > 0 )
+ {
+ print( pad + "runtime providers: (" + resources.length + ")" );
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource res = resources[i];
+ print( p + res );
+ }
+ }
+ resources = resource.getProviders( Scope.TEST, m_expand, true );
+ if( resources.length > 0 )
+ {
+ print( pad + "test providers: (" + resources.length + ")" );
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource res = resources[i];
+ print( p + res );
+ }
+ }
+ }
+
+ static void print( String message )
+ {
+ System.out.println( message );
+ }
+
+ private static String getLabel( int n )
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( " [" + n );
+ buffer.append( "]" );
+ buffer.append( " " );
+ String tag = buffer.toString();
+ return tag.substring( 0, 7 ) + " ";
+ }
+
+ /**
+ * List general command help to the console.
+ * @exception IOException if an I/O error occurs
+ */
+ @SuppressWarnings( "unchecked" )
+ private void processHelp() throws IOException
+ {
+ HelpFormatter formatter = new HelpFormatter(
+ HelpFormatter.DEFAULT_GUTTER_LEFT,
+ HelpFormatter.DEFAULT_GUTTER_CENTER,
+ HelpFormatter.DEFAULT_GUTTER_RIGHT,
+ 100 );
+
+ formatter.getDisplaySettings().add(
DisplaySetting.DISPLAY_GROUP_OUTER );
+ formatter.getDisplaySettings().add(
DisplaySetting.DISPLAY_PROPERTY_OPTION );
+ formatter.getDisplaySettings().add(
DisplaySetting.DISPLAY_ARGUMENT_BRACKETED );
+
+ formatter.getFullUsageSettings().add(
DisplaySetting.DISPLAY_OPTIONAL );
+ formatter.getFullUsageSettings().add(
DisplaySetting.DISPLAY_GROUP_OUTER );
+ formatter.getFullUsageSettings().add(
DisplaySetting.DISPLAY_PROPERTY_OPTION );
+ formatter.getFullUsageSettings().add(
DisplaySetting.DISPLAY_OPTIONAL );
+ formatter.getFullUsageSettings().add(
DisplaySetting.DISPLAY_ARGUMENT_BRACKETED );
+ formatter.getFullUsageSettings().remove(
DisplaySetting.DISPLAY_PARENT_CHILDREN );
+
+ formatter.getLineUsageSettings().add(
DisplaySetting.DISPLAY_PROPERTY_OPTION );
+ formatter.getLineUsageSettings().add(
DisplaySetting.DISPLAY_ARGUMENT_BRACKETED );
+ formatter.getLineUsageSettings().remove(
DisplaySetting.DISPLAY_PARENT_CHILDREN );
+ formatter.getLineUsageSettings().remove(
DisplaySetting.DISPLAY_GROUP_EXPANDED );
+
+ formatter.setGroup( COMMAND_GROUP );
+ formatter.setShellCommand( "build" );
+ formatter.print();
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private static final DefaultOptionBuilder OPTION_BUILDER = new
DefaultOptionBuilder();
+ private static final ArgumentBuilder ARGUMENT_BUILDER = new
ArgumentBuilder();
+ private static final GroupBuilder GROUP_BUILDER = new GroupBuilder();
+ private static final CommandBuilder COMMAND_BUILDER = new
CommandBuilder();
+ private static final PropertyOption PROPERTY_OPTION = new
PropertyOption();
+
+ private static final Option HELP_OPTION =
+ OPTION_BUILDER
+ .withShortName( "help" )
+ .withShortName( "h" )
+ .withDescription( "List command help." )
+ .withRequired( false )
+ .create();
+
+ private static final Option SELECT_OPTION =
+ OPTION_BUILDER
+ .withShortName( "select" )
+ .withShortName( "s" )
+ .withDescription( "Build selected project(s)." )
+ .withRequired( false )
+ .withArgument(
+ ARGUMENT_BUILDER
+ .withDescription( "Project." )
+ .withName( "pattern" )
+ .withMinimum( 1 )
+ .withMaximum( 1 )
+ .create() )
+ .create();
+
+ private static final Option VERBOSE_OPTION =
+ OPTION_BUILDER
+ .withShortName( "verbose" )
+ .withShortName( "v" )
+ .withDescription( "Enable verbose mode." )
+ .withRequired( false )
+ .create();
+
+ private static final Option LIST_OPTION =
+ OPTION_BUILDER
+ .withShortName( "list" )
+ .withShortName( "l" )
+ .withDescription( "List selected project(s)." )
+ .withRequired( false )
+ .withArgument(
+ ARGUMENT_BUILDER
+ .withDescription( "Project." )
+ .withName( "pattern" )
+ .withMinimum( 0 )
+ .withMaximum( 1 )
+ .create() )
+ .create();
+
+ private static final Option EXPAND_OPTION =
+ OPTION_BUILDER
+ .withShortName( "expand" )
+ .withShortName( "e" )
+ .withDescription( "Expand dependencies." )
+ .withRequired( false )
+ .create();
+
+ private static final Option CONSUMERS_OPTION =
+ OPTION_BUILDER
+ .withShortName( "consumers" )
+ .withShortName( "c" )
+ .withDescription( "Consumer switch." )
+ .withRequired( false )
+ .create();
+
+ private static final Option VALIDATE_OPTION =
+ OPTION_BUILDER
+ .withShortName( "validate" )
+ .withDescription( "Enable deliverable validation." )
+ .withRequired( false )
+ .create();
+
+ private static final Option VERSION_OPTION =
+ OPTION_BUILDER
+ .withShortName( "version" )
+ .withDescription( "Build version." )
+ .withRequired( false )
+ .withArgument(
+ ARGUMENT_BUILDER
+ .withDescription( "Created artifact version." )
+ .withName( "version" )
+ .withMinimum( 1 )
+ .withMaximum( 1 )
+ .create() )
+ .create();
+
+ private static final Option DECIMAL_OPTION =
+ OPTION_BUILDER
+ .withShortName( "decimal" )
+ .withDescription( "Enable decimal versioning." )
+ .withRequired( false )
+ .create();
+
+ private static final Option BUILDER_URI_OPTION =
+ OPTION_BUILDER
+ .withShortName( "plugin" )
+ .withDescription( "Default builder plugin uri." )
+ .withRequired( false )
+ .withArgument(
+ ARGUMENT_BUILDER
+ .withDescription( "Artifact reference." )
+ .withName( "artifact" )
+ .withMinimum( 1 )
+ .withMaximum( 1 )
+ .withValidator( new URIValidator() )
+ .create() )
+ .create();
+
+ private static final Option TARGETS =
+ ARGUMENT_BUILDER
+ .withName( "target" )
+ .create();
+
+ private static final Group LIST_GROUP =
+ GROUP_BUILDER
+ .withMinimum( 0 )
+ .withOption( LIST_OPTION )
+ .withOption( EXPAND_OPTION )
+ .withOption( CONSUMERS_OPTION )
+ .create();
+
+ private static final Group BUILD_GROUP =
+ GROUP_BUILDER
+ .withMinimum( 0 )
+ .withOption( SELECT_OPTION )
+ .withOption( CONSUMERS_OPTION )
+ .withOption( VERBOSE_OPTION )
+ .withOption( BUILDER_URI_OPTION )
+ .withOption( VERSION_OPTION )
+ .withOption( DECIMAL_OPTION )
+ .withOption( VALIDATE_OPTION )
+ .withOption( PROPERTY_OPTION )
+ .create();
+
+ private static final Group COMMAND_GROUP =
+ GROUP_BUILDER
+ .withName( "options" )
+ .withOption( HELP_OPTION )
+ .withOption( LIST_GROUP )
+ .withOption( BUILD_GROUP )
+ .withOption( TARGETS )
+ .create();
+
+ static
+ {
+ try
+ {
+ BUILD_IMPLEMENTATION_URI = new URI( "@DEPOT-BUILDER-URI@" );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "will not happen", e );
+ }
+ }
+
+}
+
Modified: trunk/main/depot/build.xml
===================================================================
--- trunk/main/depot/build.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/build.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -17,9 +17,8 @@
limitations under the License.
-->
-<project name="dpml-depot" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit" >
+<project name="dpml-depot" default="install" basedir="."
xmlns:x="antlib:dpml.tools" >
- <transit:import uri="local:template:dpml/tools/standard"/>
+ <x:import uri="local:template:dpml/tools/standard"/>
</project>
Modified: trunk/main/depot/library/bootstrap.properties
===================================================================
--- trunk/main/depot/library/bootstrap.properties 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/bootstrap.properties 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,7 +1,4 @@
project.group = dpml/depot
-project.name = dpml-library
+project.name = dpml-depot-library
project.test.fork = true
-junit.version = 3.8.1
-junit.filename = junit-${junit.version}.jar
-junit.uri = artifact:jar:junit/junit#${junit.version}
Modified: trunk/main/depot/library/bootstrap.xml
===================================================================
--- trunk/main/depot/library/bootstrap.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/library/bootstrap.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -1,30 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="dpml-library" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit" >
+<project name="dpml-depot-library" default="install" basedir=".">
<property file="${basedir}/bootstrap.properties"/>
- <transit:import
file="${dpml.prefs}/dpml/transit/templates/bootstrap.template"/>
-
- <target name="init" depends="bootstrap.init">
- <property name="project.xsd.version" value="${project.version}"/>
- <filter token="MODULE-XSD-URI"
value="link:xsd:dpml/lang/dpml-module#1.0"/>
- <filter token="PART-XSD-URI" value="link:xsd:dpml/lang/dpml-part#1.0"/>
- <filter value="${junit.version}" token="JUNIT_VERSION"/>
- <filter value="${project.version}" token="PROJECT-VERSION"/>
- <filter value="link:part:dpml/depot/dpml-tools-builder"
token="ANT-BUILDER-URI"/>
- </target>
-
+ <property file="../../bootstrap.properties"/>
+
+ <property name="bootstrap.template"
location="${basedir}/../../bootstrap.xml"/>
+ <import file="${bootstrap.template}"/>
+
<target name="setup-path" depends="bootstrap.setup-path">
- <transit:get property="junit.path" uri="${junit.uri}"/>
- <transit:get property="transit.path"
uri="artifact:jar:dpml/transit/dpml-transit-main#BOOTSTRAP"/>
<path id="project.main.path">
<pathelement
location="${dpml.local.cache}/dpml/transit/jars/dpml-transit-main-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/lang/jars/dpml-lang-part-BOOTSTRAP.jar"/>
<pathelement location="${target.classes.dir}"/>
</path>
<path id="project.test.path">
- <pathelement location="${junit.path}"/>
- <pathelement location="${transit.path}"/>
+ <path refid="project.main.path"/>
+ <pathelement
location="${dpml.local.cache}/junit/jars/${junit.filename}"/>
<pathelement
location="${target.deliverables.jars.dir}/${project.filename}"/>
</path>
</target>
Deleted: trunk/main/depot/library/build.xml
===================================================================
--- trunk/main/depot/library/build.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/build.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-library" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
-
- <transit:import uri="local:template:dpml/tools/standard"/>
-
-</project>
Modified: trunk/main/depot/library/etc/data/ant/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/ant/module.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/ant/module.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module name="ant" version="1.6.5" xmlns="@MODULE-XSD-URI@">
+<module name="ant" version="1.6.5" xmlns="dpml:library">
<resource name="ant">
<types>
Modified: trunk/main/depot/library/etc/data/commons-cli/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/commons-cli/module.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/commons-cli/module.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module name="commons-cli" version="1.0" xmlns="@MODULE-XSD-URI@">
+<module xmlns="dpml:library" name="commons-cli" version="1.0">
<resource name="commons-cli">
<types>
Modified: trunk/main/depot/library/etc/data/dpml/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/dpml/module.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/dpml/module.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module xmlns="@MODULE-XSD-URI@"
- xmlns:part="@PART-XSD-URI@"
+<module xmlns="dpml:library"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="dpml" basedir=".." >
<properties>
- <property name="project.publisher.name" value="Digital Product Meta
Library"/>
+ <property name="project.publisher.name" value="Digital Product
Management Laboratory"/>
<property name="project.specification.vendor"
value="${project.publisher.name}"/>
<property name="project.implementation.vendor"
value="${project.publisher.name}"/>
<property name="project.implementation.vendor-id" value="net.dpml"/>
@@ -158,7 +157,7 @@
<property name="project.template" value="${basedir}/builder.xml"/>
</properties>
<types>
- <part:plugin alias="true" class="net.dpml.lang.PartManager"/>
+ <type id="part" source="target/plugin.xml"/>
<type id="jar"/>
</types>
<dependencies>
@@ -218,7 +217,7 @@
</properties>
<types>
<type id="jar"/>
- <part:plugin
class="net.dpml.metro.runtime.edit.CompositionEditorFactory"/>
+ <type id="part" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
@@ -234,7 +233,7 @@
</properties>
<types>
<type id="jar"/>
- <part:plugin alias="true"
class="net.dpml.metro.runtime.CompositionController"/>
+ <type id="part" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
@@ -254,7 +253,7 @@
</properties>
<types>
<type id="jar"/>
- <part:resource urn="dpml:metro"
path="net/dpml/composition/tools/antlib.xml"/>
+ <type id="part" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
@@ -324,7 +323,7 @@
</properties>
<types>
<type id="jar"/>
- <part:plugin alias="true"
class="net.dpml.library.impl.BuildPlugin"/>
+ <type id="part" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
@@ -343,7 +342,7 @@
</properties>
<types>
<type id="jar"/>
- <part:plugin alias="true"
class="net.dpml.tools.impl.StandardBuilder"/>
+ <type id="part" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
Modified: trunk/main/depot/library/etc/data/jgoodies/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/jgoodies/module.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/jgoodies/module.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module xmlns="@MODULE-XSD-URI@" name="jgoodies">
+<module xmlns="dpml:library" name="jgoodies">
<resource name="looks" version="1.1">
<types>
Modified: trunk/main/depot/library/etc/data/junit/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/junit/module.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/junit/module.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module xmlns="@MODULE-XSD-URI@" name="junit" version="3.8.1">
+<module xmlns="dpml:library" name="junit" version="3.8.1">
<resource name="junit">
<types>
Modified: trunk/main/depot/library/etc/data/library.xml
===================================================================
--- trunk/main/depot/library/etc/data/library.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/library.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<index xmlns="@MODULE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library">
<properties>
- <property name="project.builder.uri"
value="link:part:dpml/tools/dpml-tools-builder"/>
+ <property name="project.builder.uri"
value="link:part:dpml/tools/dpml-depot-builder"/>
<property name="project.standard.template"
value="local:template:dpml/tools/standard"/>
<property name="project.template" value="${project.standard.template}"/>
</properties>
Added: trunk/main/depot/library/etc/data/logging.properties
===================================================================
--- trunk/main/depot/library/etc/data/logging.properties 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/logging.properties 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,3 @@
+.level=INFO
+sun.rmi.level=INFO
+dpml.transit.level=INFO
Modified: trunk/main/depot/library/etc/data/samples/absolute.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/absolute.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/absolute.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@" >
+<index xmlns="dpml:library" >
<module name="gov/nsa/acme">
<info/>
Modified: trunk/main/depot/library/etc/data/samples/anonymous.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/anonymous.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/anonymous.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<index xmlns="@MODULE-XSD-URI@">
+<index xmlns="dpml:library">
<properties>
- <property name="project.builder.uri"
value="link:plugin:dpml/tools/dpml-tools-builder"/>
+ <property name="project.builder.uri"
value="link:plugin:dpml/tools/dpml-depot-builder"/>
<property name="project.standard.template"
value="local:template:dpml/tools/standard"/>
<property name="project.template" value="${project.standard.template}"/>
</properties>
Modified: trunk/main/depot/library/etc/data/samples/duplicates.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/duplicates.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/duplicates.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
- xmlns:part="@PART-XSD-URI@">
+<index xmlns="dpml:library">
<module name="acme">
<resource name="widget">
@@ -9,7 +8,7 @@
<property name="pink" value="floyd"/>
<property name="alice" value="cooper"/>
</type>
- <part:plugin class="Widget"/>
+ <type id="part" source="strategy.xml"/>
</types>
</resource>
</module>
@@ -17,7 +16,7 @@
<module name="acme">
<resource name="gizmo">
<types>
- <part:plugin class="gizmo"/>
+ <type id="part" source="strategy.xml"/>
</types>
</resource>
</module>
Modified: trunk/main/depot/library/etc/data/samples/example-1.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-1.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-1.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@">
+<index xmlns="dpml:library">
</index>
Modified: trunk/main/depot/library/etc/data/samples/example-2.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-2.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-2.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@">
+<index xmlns="dpml:library">
<properties>
<property name="foo" value="bar"/>
Modified: trunk/main/depot/library/etc/data/samples/example-3.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-3.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-3.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@">
+<index xmlns="dpml:library">
<imports>
<import uri="link:xml:abc/def/import-1#1.0"/>
Modified: trunk/main/depot/library/etc/data/samples/example-4.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-4.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-4.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import uri="link:module:junit"/>
Modified: trunk/main/depot/library/etc/data/samples/example-5.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-5.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-5.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import uri="link:module:junit"/>
Modified: trunk/main/depot/library/etc/data/samples/example-6.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-6.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-6.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import uri="link:module:junit"/>
Modified: trunk/main/depot/library/etc/data/samples/example-7.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-7.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-7.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library">
<imports>
<import uri="link:module:junit"/>
Modified: trunk/main/depot/library/etc/data/samples/example-8.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/example-8.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/example-8.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:part="@PART-XSD-URI@">
+<index xmlns="dpml:library">
<imports>
<import uri="link:module:junit"/>
@@ -11,11 +9,11 @@
<module name="acme">
<resource name="widget">
<types>
- <type id="foo" xsi:type="GenericType">
+ <type id="foo">
<property name="pink" value="floyd"/>
<property name="alice" value="cooper"/>
</type>
- <part:plugin class="Widget"/>
+ <type id="part" source="target/plugin.xml" test="true"
alias="false"/>
</types>
</resource>
</module>
Modified: trunk/main/depot/library/etc/data/samples/filters.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/filters.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/filters.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:part="@PART-XSD-URI@">
+<index xmlns="dpml:library">
<module name="acme">
<filters>
Modified: trunk/main/depot/library/etc/data/samples/info.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/info.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/info.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:part="@PART-XSD-URI@">
+<index xmlns="dpml:library">
<module name="acme-1">
<info/>
Modified: trunk/main/depot/library/etc/data/samples/jar-type.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/jar-type.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/jar-type.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<index xmlns="dpml:library">
<module name="acme">
<project name="widget" basedir=".">
Modified: trunk/main/depot/library/etc/data/samples/properties.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/properties.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/properties.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<index xmlns="@MODULE-XSD-URI@">
+<index xmlns="dpml:library">
<module name="org">
<properties>
Modified: trunk/main/depot/library/etc/data/samples/widget.xml
===================================================================
--- trunk/main/depot/library/etc/data/samples/widget.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/samples/widget.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,2 +1,2 @@
<?xml version="1.0"?>
-<module xmlns="@MODULE-XSD-URI@" name="abc"/>
+<module xmlns="dpml:library" name="abc"/>
Modified: trunk/main/depot/library/etc/data/xstream/module.xml
===================================================================
--- trunk/main/depot/library/etc/data/xstream/module.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/library/etc/data/xstream/module.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module xmlns="@MODULE-XSD-URI@" name="xstream" version="1.1">
+<module xmlns="dpml:library" name="xstream" version="1.1">
<resource name="xstream">
<types>
Added: trunk/main/depot/library/project.xml
===================================================================
--- trunk/main/depot/library/project.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/library/project.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project xmlns="dpml:library" name="dpml-depot-library">
+
+ <info title="DPML Project Management Library Implementation">
+ <description>Multi-project build automation tool.</description>
+ </info>
+
+ <types>
+ <type id="jar"/>
+ </types>
+
+ <dependencies>
+ <runtime>
+ <include ref="dpml/lang/dpml-lang-part"/>
+ </runtime>
+ <test>
+ <include ref="org/apache/ant/ant-junit"/>
+ </test>
+ </dependencies>
+
+ <filters>
+ <feature token="JUNIT_VERSION" ref="junit/junit" id="version"/>
+ <feature token="PROJECT_VERSION" id="version"/>
+ </filters>
+
+</project>
Copied: trunk/main/depot/library/src/main/dpml (from rev 1789,
trunk/main/depot/library/src/main/net/dpml)
Deleted: trunk/main/depot/library/src/main/dpml/library/Builder.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Builder.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Builder.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,38 +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.library;
-
-/**
- * A Builder is implementated by a plugin that handles the building of
- * a project.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Builder
-{
- /**
- * Build a resource.
- * @param resource the resource to build
- * @param targets build target names
- * @return the success status of the build
- */
- public boolean build( Resource resource, String[] targets );
-
-}
Added: trunk/main/depot/library/src/main/dpml/library/Classifier.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Classifier.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Classifier.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,43 @@
+/*
+ * 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 dpml.library;
+
+/**
+ * Resource classifier enumeration.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public enum Classifier
+{
+ /**
+ * Anonymous resources.
+ */
+ ANONYMOUS,
+
+ /**
+ * External resource.
+ */
+ EXTERNAL,
+
+ /**
+ * Local resources.
+ */
+ LOCAL;
+}
Deleted: trunk/main/depot/library/src/main/dpml/library/Data.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Data.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Data.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,37 +0,0 @@
-/*
- * Copyright 2006 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.library;
-
-import org.w3c.dom.Element;
-
-/**
- * Declaration of a production criteria datatype.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Data
-{
- /**
- * Return the production datatype.
- * @return the DOM element
- */
- Element getElement();
-
-}
Modified: trunk/main/depot/library/src/main/dpml/library/Dictionary.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Dictionary.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Dictionary.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,8 +16,10 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
+import java.util.Properties;
+
/**
* The Dictonary interface exposes operations dealing with named properties.
*
@@ -70,10 +72,16 @@
int getIntegerProperty( String key, int value );
/**
+ * Evaluate and expand any symbolic references in the supplied property
set.
+ * @param properties the properties to resolve
+ * @return the resolved properties
+ */
+ Properties resolveProperties( Properties properties );
+
+ /**
* Evaluate and expand any symbolic references in the supplied value.
* @param value the value to resolve
* @return the resolved value
*/
String resolve( String value );
-
}
Modified:
trunk/main/depot/library/src/main/dpml/library/DuplicateNameException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/DuplicateNameException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/DuplicateNameException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A DuplicateNameException is thrown when an attempt is made to duplicate
Modified: trunk/main/depot/library/src/main/dpml/library/Feature.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Feature.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Feature.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,13 +16,11 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
import java.io.File;
import net.dpml.lang.Version;
-import net.dpml.lang.Enum;
-
import net.dpml.transit.Artifact;
/**
@@ -31,142 +29,55 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public final class Feature extends Enum
+public enum Feature
{
- static final long serialVersionUID = 1L;
-
/**
* Resource name.
*/
- public static final Feature NAME = new Feature( "name" );
+ NAME,
/**
* Resource group.
*/
- public static final Feature GROUP = new Feature( "group" );
+ GROUP,
/**
* Resource version.
*/
- public static final Feature VERSION = new Feature( "version" );
+ VERSION,
/**
* Resource decimal version.
*/
- public static final Feature DECIMAL = new Feature( "decimal" );
+ DECIMAL,
/**
* Resource version.
*/
- public static final Feature URI = new Feature( "uri" );
+ URI,
/**
* Resource spec.
*/
- public static final Feature SPEC = new Feature( "spec" );
+ SPEC,
/**
* Resource path.
*/
- public static final Feature PATH = new Feature( "path" );
+ PATH,
/**
* Resource filename.
*/
- public static final Feature FILENAME = new Feature( "filename" );
+ FILENAME,
/**
* Project basedir.
*/
- public static final Feature BASEDIR = new Feature( "basedir" );
+ BASEDIR;
- /**
- * Array of scope enumeration values.
- */
- private static final Feature[] ENUM_VALUES =
- new Feature[]{NAME, GROUP, VERSION, DECIMAL, URI, SPEC, PATH,
FILENAME, BASEDIR};
-
- /**
- * Returns an array of activation enum values.
- * @return the activation policies array
- */
- public static Feature[] values()
- {
- return ENUM_VALUES;
- }
/**
- * Internal constructor.
- * @param label the enumeration label.
- * @param index the enumeration index.
- */
- private Feature( String label )
- {
- super( label );
- }
-
- /**
- * Return a string representation of the scope.
- * @return the string value
- */
- public String toString()
- {
- return getName().toUpperCase();
- }
-
- /**
- * Return a feature.
- * @param value the feature name
- * @return the feature
- * @exception IllegalArgumentException if the name if not a recognized
feature.
- */
- public static Feature parse( String value ) throws
IllegalArgumentException
- {
- if( value.equalsIgnoreCase( "name" ) )
- {
- return NAME;
- }
- else if( value.equalsIgnoreCase( "group" ) )
- {
- return GROUP;
- }
- else if( value.equalsIgnoreCase( "version" ) )
- {
- return VERSION;
- }
- else if( value.equalsIgnoreCase( "decimal" ) )
- {
- return DECIMAL;
- }
- else if( value.equalsIgnoreCase( "uri" ) )
- {
- return URI;
- }
- else if( value.equalsIgnoreCase( "spec" ) )
- {
- return SPEC;
- }
- else if( value.equalsIgnoreCase( "path" ) )
- {
- return PATH;
- }
- else if( value.equalsIgnoreCase( "filename" ) )
- {
- return FILENAME;
- }
- else if( value.equalsIgnoreCase( "basedir" ) )
- {
- return BASEDIR;
- }
- else
- {
- final String error =
- "Unrecognized feature argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
-
- /**
* Return the value of a feature.
* @param resource the target resource
* @param feature the feature
@@ -211,27 +122,36 @@
throw new FeatureRuntimeException( error );
}
- if( feature.equals( Feature.NAME ) )
+ if( feature.equals( NAME ) )
{
- return resource.getName();
+ if( null != type )
+ {
+ String name = type.getName();
+ return getValue( name );
+ }
+ else
+ {
+ return resource.getName();
+ }
}
- else if( feature.equals( Feature.GROUP ) )
+ else if( feature.equals( GROUP ) )
{
return resource.getParent().getResourcePath();
}
- else if( feature.equals( Feature.VERSION ) )
+ else if( feature.equals( VERSION ) )
{
- String version = resource.getVersion();
- if( null == version )
+ if( null != type )
{
- return "";
+ String version = type.getVersion();
+ return getValue( version );
}
else
{
- return version;
+ String version = resource.getVersion();
+ return getValue( version );
}
}
- else if( feature.equals( Feature.DECIMAL ) )
+ else if( feature.equals( DECIMAL ) ) // <-- TODO, think about
decimal versus explicit version on types
{
Version version = resource.getDecimalVersion();
if( null == version )
@@ -243,11 +163,11 @@
return version.toString();
}
}
- else if( feature.equals( Feature.URI ) )
+ else if( feature.equals( URI ) )
{
return resolveURIFeature( resource, type, alias );
}
- else if( feature.equals( Feature.SPEC ) )
+ else if( feature.equals( SPEC ) ) // <-- TODO: what is this used for?
{
String path = resource.getResourcePath();
String version =resource.getVersion();
@@ -260,33 +180,28 @@
return path + "#" + version;
}
}
- else if( feature.equals( Feature.PATH ) )
+ else if( feature.equals( PATH ) ) // <!-- TODO: update for
Type/name/version/test
{
if( null == type )
{
final String error =
- "Type must be supplied in conjuction with the uri
feature.";
+ "Type must be supplied in conjuction with the a type.";
throw new FeatureRuntimeException( error );
}
- else
+
+ File file = type.getFile();
+ try
{
- String id = type.getID();
- Artifact artifact = resource.getArtifact( id );
- try
- {
- File cached =
- (File) artifact.toURL().getContent( new
Class[]{File.class} );
- return cached.getCanonicalPath();
- }
- catch( Exception e )
- {
- final String error =
- "Unable to resolve resource path.";
- throw new FeatureRuntimeException( error, e );
- }
+ return file.getCanonicalPath();
}
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while resolving resource type path [" +
file + "].";
+ throw new FeatureRuntimeException( error, e );
+ }
}
- else if( feature.equals( Feature.FILENAME ) )
+ else if( feature.equals( FILENAME ) ) // needs to be fixed
{
if( null == type )
{
@@ -294,29 +209,30 @@
"Type must be supplied in conjuction with the filename
feature.";
throw new IllegalArgumentException( error );
}
- String id = type.getID();
- return resource.getLayoutPath( id );
+ if( type.getTest() )
+ {
+ throw new IllegalArgumentException(
+ "Filename cannot be used in conjunction with a test type."
);
+ }
+ return type.getLayoutPath();
}
- else if( feature.equals( Feature.BASEDIR ) )
+ else if( feature.equals( BASEDIR ) )
{
File base = resource.getBaseDir();
if( null == base )
{
throw new IllegalArgumentException( "basedir" );
}
- else
+ try
{
- try
- {
- return base.getCanonicalPath();
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while resolving project basedir [" +
base + "].";
- throw new FeatureRuntimeException( error, e );
- }
+ return base.getCanonicalPath();
}
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while resolving project basedir [" +
base + "].";
+ throw new FeatureRuntimeException( error, e );
+ }
}
else
{
@@ -326,12 +242,25 @@
}
}
+ private static String getValue( String value )
+ {
+ if( null != value )
+ {
+ return value;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
private static String resolveURIFeature( Resource resource, Type type )
{
return resolveURIFeature( resource, type, false );
}
- private static String resolveURIFeature( Resource resource, Type type,
boolean alias )
+ private static String resolveURIFeature(
+ Resource resource, Type type, boolean alias ) // TODO: update to
handle version on types and type names
{
if( null == type )
{
@@ -344,41 +273,15 @@
String id = type.getID();
if( alias )
{
- Version version = type.getVersion();
- if( null != version )
+ if( type.getAliasProduction() )
{
- Artifact artifact = resource.getArtifact( id );
- String group = artifact.getGroup();
- String name = artifact.getName();
- if( Version.NULL_VERSION.equals( version ) )
- {
- return "link:"
- + id
- + ":"
- + group
- + "/"
- + name;
- }
- else
- {
- int major = version.getMajor();
- int minor = version.getMinor();
- return "link:"
- + id
- + ":"
- + group
- + "/"
- + name
- + "#"
- + major
- + "."
- + minor;
- }
+ Artifact artifact = type.getLinkArtifact();
+ return artifact.toURI().toASCIIString();
}
else
{
final String error =
- "Cannot resolve link from resource ["
+ "Cannot resolve link feature from the resource ["
+ resource
+ "] because the resource does not declare production
of an alias for the type ["
+ id
@@ -388,10 +291,11 @@
}
else
{
- Artifact artifact = resource.getArtifact( id );
+
+ Artifact artifact = type.getArtifact();
return artifact.toURI().toASCIIString();
}
}
- }
+ }
}
Modified:
trunk/main/depot/library/src/main/dpml/library/FeatureRuntimeException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/FeatureRuntimeException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/FeatureRuntimeException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A FeatureRuntimeException is thrown when a requested for a feature cannot
Modified: trunk/main/depot/library/src/main/dpml/library/Filter.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Filter.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Filter.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* Interface implemented by content filters.
Modified: trunk/main/depot/library/src/main/dpml/library/Info.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Info.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Info.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* Interface implemented by info handlers.
Modified: trunk/main/depot/library/src/main/dpml/library/Library.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Library.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Library.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
import java.io.File;
Added: trunk/main/depot/library/src/main/dpml/library/Local.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Local.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Local.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 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 dpml.library;
+
+import java.io.File;
+
+/**
+ * Interface implemented by resources that are backed by a local
+ * codebase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Local
+{
+ /**
+ * Return the project basedir.
+ * @param location the project location
+ * @return the base directory of the associated codebase
+ */
+ File getDirectory( ProjectLocation location );
+
+}
Modified: trunk/main/depot/library/src/main/dpml/library/Module.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Module.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Module.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,10 +16,13 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
-import net.dpml.library.info.ModuleDirective;
+import java.io.IOException;
+import java.io.OutputStream;
+//import dpml.library.info.ModuleDirective;
+
/**
* The Modele interface defines a node within a module hierachy.
*
@@ -77,8 +80,8 @@
/**
* Return a directive suitable for publication as an external description.
- * @return the module directive
+ * @param output the output stream
+ * @exception IOException if an IO error occurs
*/
- ModuleDirective export();
-
+ void export( OutputStream output ) throws IOException;
}
Modified:
trunk/main/depot/library/src/main/dpml/library/ModuleNotFoundException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/ModuleNotFoundException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/ModuleNotFoundException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A ModuleNotFoundException is thrown when a requested for a named module
cannot
Added: trunk/main/depot/library/src/main/dpml/library/ProjectLocation.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/ProjectLocation.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/ProjectLocation.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2004-2006 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 dpml.library;
+
+/**
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public enum ProjectLocation
+{
+ /**
+ * Project base directory.
+ */
+ BASEDIR,
+
+ /**
+ * Supplimentary resources directory.
+ */
+ ECT,
+
+ /**
+ * Supplimentary main codebase resources directory.
+ */
+ ECT_MAIN,
+
+ /**
+ * Supplimentary test codebase resources directory.
+ */
+ ECT_TEST,
+
+ /**
+ * Supplimentary test runtime resources directory.
+ */
+ ECT_DATA,
+
+ /**
+ * Supplimentary doc resources directory.
+ */
+ ECT_DOCS,
+
+ /**
+ * Preference resources directory.
+ */
+ ECT_PREFS,
+
+ /**
+ * Main codebase directory.
+ */
+ SRC,
+
+ /**
+ * Main codebase directory.
+ */
+ SRC_MAIN,
+
+ /**
+ * Test codebase directory.
+ */
+ SRC_TEST,
+
+ /**
+ * Documentation codebase directory.
+ */
+ SRC_DOCS,
+
+ /**
+ * Target directory.
+ */
+ TARGET,
+
+ /**
+ * Interim filtered codebase parent directory.
+ */
+ BUILD,
+
+ /**
+ * Interim filtered main codebase parent directory.
+ */
+ BUILD_MAIN,
+
+ /**
+ * Interim filtered test codebase parent directory.
+ */
+ BUILD_TEST,
+
+ /**
+ * Interim filtered documentation codebase parent directory.
+ */
+ BUILD_DOCS,
+
+ /**
+ * Compiled classes directory.
+ */
+ CLASSES,
+
+ /**
+ * Compiled main codebase classes directory.
+ */
+ CLASSES_MAIN,
+
+ /**
+ * Compiled test codebase classes directory.
+ */
+ CLASSES_TEST,
+
+ /**
+ * Target deliverables directory.
+ */
+ DELIVERABLES,
+
+ /**
+ * Target preferences directory.
+ */
+ PREFS,
+
+ /**
+ * Target working test directory.
+ */
+ TEST,
+
+ /**
+ * Target reports directory.
+ */
+ REPORTS;
+
+}
+/*
+ BASEDIR contains ECT, SRC, TARGET
+
+ ECT contains MAIN, TEST, DATA
+ SRC contains MAIN, TEST, DOCS
+ TARGET directories BUILD, CLASSES, DELIVERABLES, TEST, REPORTS
+
+ etc/MAIN --> target/build/MAIN
+ etc/TEST --> target/build/TEST
+ etc/DOCS --> target/build/DOCS
+ etc/${X} --> target/${X}
+
+ src/MAIN --> target/build/MAIN --> target/classes/MAIN
+ src/TEST --> target/build/TEST --> target/classes/TEST
+ src/DOCS --> target/build/DOCS --> target/DOCS
+
+ target/${X}
+ target/deliverables/${type}s/
+ target/reports/MAIN
+ target/reports/TEST
+ target/test
+ target/test/DATA
+
+ getDirectory( SRC.MAIN )
+ getDirectory( BUILD.MAIN )
+ getDirectory( CLASSES.MAIN )
+ getDirectory( REPORTS.TEST )
+
+ // full list
+
+ BASEDIR
+
+ SRC
+ SRC_MAIN
+ SRC_TEST
+ SRC_DOCS
+ ETC
+ ETC_MAIN
+ ETC_TEST
+ ECT_DATA
+ ETC_DOCS
+ ECT_PREFS
+ TARGET
+ CLASSES
+ CLASSES_MAIN
+ CLASSES_TEST
+ DELIVERABLES
+ PREFS
+ REPORTS
+ TEST
+
+*/
+
+
+
Modified:
trunk/main/depot/library/src/main/dpml/library/ReferentialException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/ReferentialException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/ReferentialException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A ReferentialException is thrown when a requested change would result
Modified: trunk/main/depot/library/src/main/dpml/library/Resource.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Resource.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Resource.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,16 +16,14 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
+import dpml.util.Category;
+
import java.io.File;
-import net.dpml.library.info.Scope;
-import net.dpml.library.info.ResourceDirective.Classifier;
-
import net.dpml.transit.Artifact;
-import net.dpml.lang.Category;
import net.dpml.lang.Version;
import net.dpml.util.Resolver;
@@ -56,12 +54,26 @@
String getName();
/**
+ * Return the name of the type.
+ * @param type the type
+ * @return the resource name
+ */
+ //String getName( Type type );
+
+ /**
* Return the resource version.
* @return the version
*/
String getVersion();
/**
+ * Return the type version.
+ * @param type the type
+ * @return the version
+ */
+ //String getVersion( Type type );
+
+ /**
* Return the statutory resource version.
* @return the version
*/
@@ -124,14 +136,23 @@
* @param type the resource type id
* @return the artifact
*/
- Artifact getArtifact( String type );
+ //Artifact getArtifact( Type type, boolean resolve );
/**
+ * Construct a file for a supplied type.
+ * @param type the resource type
+ * @return the artifact
+ */
+ //File getFile( Type type );
+
+ //File getFile( Type type, boolean local );
+
+ /**
* Construct an unversion link artifact for the supplied type.
* @param type the resource type id
* @return the link artifact
*/
- Artifact getLinkArtifact( String type );
+ //Artifact getLinkArtifact( Type type );
/**
* Return the enclosing parent module.
@@ -208,11 +229,11 @@
* @param id the artifact type
* @return the filename
*/
- String getLayoutPath( String id );
+ //String getLayoutPath( String id ); // move to Type
/**
* Return the array of production data.
* @return the associated production data
*/
- Data[] getData();
+ //Data[] getData();
}
Modified:
trunk/main/depot/library/src/main/dpml/library/ResourceNotFoundException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/ResourceNotFoundException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/ResourceNotFoundException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A ResourceNotFoundException is thrown when a requested for a named
resource cannot
Added: trunk/main/depot/library/src/main/dpml/library/Scope.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Scope.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Scope.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,45 @@
+/*
+ * 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 dpml.library;
+
+/**
+ * Enumeration identifying BUILD, RUNTIME and TEST phases.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public enum Scope
+{
+ /**
+ * Build scope.
+ */
+ BUILD,
+
+ /**
+ * Runtime scope.
+ */
+ RUNTIME,
+
+ /**
+ * Test scope.
+ */
+ TEST;
+
+}
+
Modified: trunk/main/depot/library/src/main/dpml/library/Type.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Type.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/Type.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,10 +16,12 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
-import net.dpml.lang.Version;
+import java.io.File;
+import java.io.IOException;
+import net.dpml.transit.Artifact;
/**
* Declaration of a type production.
@@ -27,18 +29,53 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public interface Type extends Data
+public interface Type extends Dictionary
{
/**
+ * Return the resource holding the type.
+ * @return the resource
+ */
+ Resource getResource();
+
+ /**
* Return the type production id.
* @return the type id
*/
String getID();
/**
- * Return the alias version.
- * @return the alias version value (may be null)
+ * Return the version.
+ * @return the type version
*/
- Version getVersion();
+ String getVersion();
+ String getName();
+
+ String getCompoundName();
+
+ String getSource();
+
+ boolean getTest();
+
+ /**
+ * Return the alias production flag.
+ * @return the alias flag
+ */
+ boolean getAliasProduction();
+
+ File getFile();
+
+ File getFile( boolean local );
+
+ Artifact getResolvedArtifact() throws IOException;
+
+ Artifact getArtifact();
+
+ Artifact getLinkArtifact(); // resolve option?
+
+ /**
+ * Return a filename using the layout strategy employed by the cache.
+ * @return the path
+ */
+ String getLayoutPath();
}
Deleted: trunk/main/depot/library/src/main/dpml/library/TypeBuilder.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/TypeBuilder.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/TypeBuilder.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,43 +0,0 @@
-/*
- * Copyright 2006 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.library;
-
-import net.dpml.library.info.TypeDirective;
-
-/**
- * Interface implemented by type datastructure builders.
- */
-public interface TypeBuilder
-{
- /**
- * Return the id of the type produced by the builder.
- * @return the type id
- */
- String getID();
-
- /**
- * Construct a type instance using a supplied classloader and type
- * production directive.
- * @param classloader the base classloader
- * @param type the type production directive
- * @return the type instance
- * @exception Exception if an error occurs
- */
- Type buildType( ClassLoader classloader, TypeDirective type ) throws
Exception;
-}
Modified:
trunk/main/depot/library/src/main/dpml/library/TypeNotFoundException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/TypeNotFoundException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/TypeNotFoundException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
/**
* A TypeNotFoundException is thrown when a requested for a named type cannot
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/DefaultDictionary.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultDictionary.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/impl/DefaultDictionary.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,16 +16,18 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.library.info.AbstractDirective;
+
+import dpml.util.PropertyResolver;
+
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
-import net.dpml.library.Dictionary;
-import net.dpml.library.info.AbstractDirective;
+import dpml.library.Dictionary;
-import net.dpml.util.PropertyResolver;
/**
* Utility class used for construction of a module model from an XML source.
@@ -164,6 +166,16 @@
return PropertyResolver.resolve( m_properties, value );
}
+ /**
+ * Evaluate and expand any symbolic references in the supplied property
set.
+ * @param properties the properties to resolve
+ * @return the resolved properties
+ */
+ public Properties resolveProperties( Properties properties )
+ {
+ return PropertyResolver.resolve( m_properties, properties );
+ }
+
//----------------------------------------------------------------------------
// internal
//----------------------------------------------------------------------------
@@ -197,13 +209,13 @@
private String[] getLocalPropertyNames( Properties properties )
{
- ArrayList list = new ArrayList();
+ ArrayList<String> list = new ArrayList<String>();
Enumeration names = properties.propertyNames();
while( names.hasMoreElements() )
{
list.add( (String) names.nextElement() );
}
- return (String[]) list.toArray( new String[0] );
+ return list.toArray( new String[0] );
}
Properties getExportProperties()
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/DefaultLibrary.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultLibrary.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/impl/DefaultLibrary.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,8 +16,14 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.library.info.LibraryDecoder;
+import dpml.library.info.ImportDirective;
+import dpml.library.info.LibraryDirective;
+import dpml.library.info.ModuleDirective;
+import dpml.library.info.ResourceDirective;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URI;
@@ -26,17 +32,12 @@
import java.util.Properties;
import java.util.Hashtable;
-import net.dpml.library.info.LibraryDecoder;
-import net.dpml.library.info.ImportDirective;
-import net.dpml.library.info.LibraryDirective;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.Scope;
-import net.dpml.library.Library;
-import net.dpml.library.Module;
-import net.dpml.library.ModuleNotFoundException;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
+import dpml.library.Scope;
+import dpml.library.Library;
+import dpml.library.Module;
+import dpml.library.ModuleNotFoundException;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
import net.dpml.transit.Artifact;
@@ -56,7 +57,8 @@
private final DefaultModule m_module;
private final File m_root;
private final Logger m_logger;
- private final Hashtable m_anonymous = new Hashtable();
+ private final Hashtable<String,DefaultResource> m_anonymous =
+ new Hashtable<String,DefaultResource>();
private static LibraryDirective buildLibraryDirective( File source )
throws Exception
{
@@ -139,24 +141,14 @@
// create the top-level modules
- ArrayList primaryDirectives = new ArrayList();
+ ArrayList<ResourceDirective> primaryDirectives = new
ArrayList<ResourceDirective>();
ResourceDirective[] directives = m_directive.getResourceDirectives();
for( int i=0; i<directives.length; i++ )
{
ResourceDirective directive = directives[i];
- //if( directive instanceof ModuleDirective )
- //{
- //ModuleDirective md = (ModuleDirective) directive;
- primaryDirectives.add( directive );
- //}
- //else
- //{
- // final String error =
- // "No support in place for non-module top-level
resources.";
- // throw new IllegalArgumentException( error );
- //}
+ primaryDirectives.add( directive );
}
- ResourceDirective[] values = (ResourceDirective[])
primaryDirectives.toArray( new ResourceDirective[0] );
+ ResourceDirective[] values = primaryDirectives.toArray( new
ResourceDirective[0] );
for( int i=0; i<values.length; i++ )
{
ResourceDirective d = values[i];
@@ -220,7 +212,14 @@
*/
public Resource getResource( String ref ) throws
ResourceNotFoundException
{
- return m_module.getResource( ref );
+ try
+ {
+ return m_module.getResource( ref );
+ }
+ catch( InvalidNameException e )
+ {
+ throw new ResourceNotFoundException( e.getMessage(),
e.getCause() );
+ }
}
/**
@@ -273,7 +272,7 @@
public Resource[] select( final File base, boolean self )
{
String root = base.toString();
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new ArrayList<DefaultResource>();
DefaultResource[] resources = m_module.selectDefaultResources( true,
"**/*" );
for( int i=0; i<resources.length; i++ )
{
@@ -306,7 +305,7 @@
throw new IllegalStateException( error );
}
}
- DefaultResource[] selection = (DefaultResource[]) list.toArray( new
DefaultResource[0] );
+ DefaultResource[] selection = list.toArray( new DefaultResource[0] );
return m_module.sortDefaultResources( selection );
}
@@ -360,9 +359,9 @@
/**
* Construct a new locally referenced anonymouse resource.
- * @param include the dependency include
+ * @param urn the resource urn
+ * @param properties properties assigned to the resource
* @return the resource
- * @exception IllegalArgumentException if the include mode is not URN mode
* @exception URISyntaxException if the include urn is invaid
*/
DefaultResource getAnonymousResource( String urn, Properties properties
)
@@ -370,7 +369,7 @@
{
if( m_anonymous.containsKey( urn ) )
{
- return (DefaultResource) m_anonymous.get( urn );
+ return m_anonymous.get( urn );
}
Artifact artifact = Artifact.createArtifact( urn );
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/DefaultModule.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultModule.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/impl/DefaultModule.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,19 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.library.info.AbstractDirective;
+import dpml.library.info.ModuleDirective;
+import dpml.library.info.ResourceDirective;
+import dpml.library.info.DependencyDirective;
+import dpml.library.info.TypeDirective;
+import dpml.library.info.InfoDirective;
+import dpml.library.info.LibraryEncoder;
+
import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
@@ -28,20 +38,14 @@
import java.util.Hashtable;
import java.util.Map;
-import net.dpml.library.info.Scope;
-import net.dpml.library.info.AbstractDirective;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.DependencyDirective;
-import net.dpml.library.info.ResourceDirective.Classifier;
-import net.dpml.library.info.TypeDirective;
-import net.dpml.library.info.InfoDirective;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
-import net.dpml.library.ModuleNotFoundException;
+import dpml.library.Scope;
+import dpml.library.Classifier;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
+import dpml.library.ModuleNotFoundException;
-import net.dpml.lang.Category;
+import dpml.util.Category;
import net.dpml.lang.DuplicateKeyException;
/**
@@ -57,12 +61,11 @@
{
private final boolean m_root;
private final ModuleDirective m_directive;
- private final Map m_map = new Hashtable();
+ private final Map<String,DefaultResource> m_map = new
Hashtable<String,DefaultResource>();
/**
* Constructor used by the library to create a virtual root module os
shared
* resource references.
- * @param logger the assigned logging channel
* @param library the library
* @param directive the directive from which common properties are
established
*/
@@ -76,7 +79,6 @@
/**
* Creation of a new nested module.
- * @param logger the assigned logging channel
* @param library the library
* @param module the parent module
* @param directive the directive from which common properties are
established
@@ -332,11 +334,18 @@
}
/**
- * Return a directive suitable for publication as an external description.
- * @return the resource directive
+ * Publish the module to the output stream.
+ * @param output the output stream
*/
- public ModuleDirective export()
+ public void export( OutputStream output ) throws IOException
{
+ ModuleDirective directive = exportDirective();
+ final LibraryEncoder encoder = new LibraryEncoder();
+ encoder.export( directive, output );
+ }
+
+ public ModuleDirective exportDirective()
+ {
if( null == m_directive )
{
final String error =
@@ -395,11 +404,10 @@
String basedir = null;
InfoDirective info = m_directive.getInfoDirective();
TypeDirective[] types = m_directive.getTypeDirectives();
- TypeDirective[] exportedTypes = createExportedTypes( types );
Properties properties = getExportProperties();
return new ModuleDirective(
name, version, Classifier.EXTERNAL, basedir,
- info, exportedTypes, new DependencyDirective[0],
+ info, types, new DependencyDirective[0],
directives, properties, null );
}
@@ -425,7 +433,7 @@
DefaultResource[] local = super.getLocalDefaultProviders( scope,
category );
if( Scope.BUILD.equals( scope ) )
{
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> stack = new
ArrayList<DefaultResource>();
for( int i=0; i<local.length; i++ )
{
DefaultResource resource = local[i];
@@ -435,7 +443,7 @@
}
else if( Scope.RUNTIME.equals( scope ) )
{
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> stack = new
ArrayList<DefaultResource>();
for( int i=0; i<local.length; i++ )
{
DefaultResource resource = local[i];
@@ -451,7 +459,7 @@
stack.add( resource );
}
}
- return (DefaultResource[]) stack.toArray( new DefaultResource[0]
);
+ return stack.toArray( new DefaultResource[0] );
}
else
{
@@ -459,7 +467,7 @@
}
}
- DefaultResource[] expandLocalDefaultProviders( final List stack )
+ DefaultResource[] expandLocalDefaultProviders( final
List<DefaultResource> stack )
{
DefaultResource[] resources = getDefaultResources();
for( int i=0; i<resources.length; i++ )
@@ -470,7 +478,6 @@
DefaultModule module = (DefaultModule) resource;
String path = module.getResourcePath();
if( !path.startsWith( getResourcePath() ) )
- //if( !getResourcePath().startsWith( path ) )
{
DefaultResource[] providers =
module.expandLocalDefaultProviders( stack );
for( int j=0; j<providers.length; j++ )
@@ -490,10 +497,10 @@
getParentModules( stack, providers );
}
}
- return (DefaultResource[]) stack.toArray( new DefaultResource[0] );
+ return stack.toArray( new DefaultResource[0] );
}
- private void getParentModules( final List stack, final DefaultResource[]
resources )
+ private void getParentModules( final List<DefaultResource> stack, final
DefaultResource[] resources )
{
for( int i=0; i<resources.length; i++ )
{
@@ -514,7 +521,8 @@
}
void sortDefaultResource(
- final List visited, final List stack, final Scope scope, final
DefaultResource[] resources )
+ final List<DefaultResource> visited, final List<DefaultResource>
stack,
+ final Scope scope, final DefaultResource[] resources )
{
if( visited.contains( this ) )
{
@@ -564,7 +572,7 @@
DefaultResource[] getDefaultResources()
{
- return (DefaultResource[]) m_map.values().toArray( new
DefaultResource[0] );
+ return m_map.values().toArray( new DefaultResource[0] );
}
DefaultResource getDefaultResource( final String ref )
@@ -657,17 +665,17 @@
DefaultModule[] getDefaultModules()
{
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultModule> stack = new ArrayList<DefaultModule>();
DefaultResource[] resources = getDefaultResources();
for( int i=0; i<resources.length; i++ )
{
DefaultResource resource = resources[i];
if( resource instanceof DefaultModule )
{
- stack.add( resource );
+ stack.add( (DefaultModule) resource );
}
}
- return (DefaultModule[]) stack.toArray( new DefaultModule[0] );
+ return stack.toArray( new DefaultModule[0] );
}
DefaultModule[] getAllDefaultModules()
@@ -685,8 +693,8 @@
else
{
DefaultModule[] modules = getDefaultModules();
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultModule> visited = new
ArrayList<DefaultModule>();
+ ArrayList<DefaultModule> stack = new ArrayList<DefaultModule>();
for( int i=0; i<modules.length; i++ )
{
DefaultModule module = modules[i];
@@ -701,7 +709,8 @@
}
private void collectChildModules(
- final List visited, final List stack, final DefaultModule module )
+ final List<DefaultModule> visited, final List<DefaultModule> stack,
+ final DefaultModule module )
{
if( visited.contains( module ) )
{
@@ -781,7 +790,7 @@
boolean wildcard = ( token.indexOf( "**" ) > -1 );
String remainder = getRemainderOfSelection( spec, "/", token );
DefaultModule[] modules = selectDefaultModules( token );
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new
ArrayList<DefaultResource>();
for( int i=0; i<modules.length; i++ )
{
DefaultModule module = modules[i];
@@ -793,7 +802,7 @@
DefaultResource[] selection = doSelectDefaultResources(
wildcard, remainder );
aggregate( list, selection );
}
- return (DefaultResource[]) list.toArray( new DefaultResource[0]
);
+ return list.toArray( new DefaultResource[0] );
}
}
@@ -823,10 +832,10 @@
private DefaultResource[] selectUsingPattern( final DefaultResource[]
resources, final Pattern pattern )
{
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new ArrayList<DefaultResource>();
for( int i=0; i<resources.length; i++ )
{
- Resource resource = resources[i];
+ DefaultResource resource = resources[i];
String name = resource.getName();
Matcher matcher = pattern.matcher( name );
boolean matches = matcher.matches();
@@ -835,7 +844,7 @@
list.add( resource );
}
}
- return (DefaultResource[]) list.toArray( new DefaultResource[0] );
+ return list.toArray( new DefaultResource[0] );
}
private String getRemainderOfSelection( final String spec, final String
delimiter, final String token )
@@ -844,7 +853,7 @@
return spec.substring( n );
}
- private void aggregate( final List list, final DefaultResource[]
resources )
+ private void aggregate( final List<DefaultResource> list, final
DefaultResource[] resources )
{
for( int i=0; i<resources.length; i++ )
{
@@ -893,8 +902,8 @@
private DefaultModule[] sortDefaultModules( final DefaultModule[]
modules )
{
Scope scope = Scope.TEST;
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> visited = new
ArrayList<DefaultResource>();
+ ArrayList<DefaultResource> stack = new ArrayList<DefaultResource>();
for( int i=0; i<modules.length; i++ )
{
DefaultModule module = modules[i];
@@ -912,14 +921,15 @@
*/
private DefaultModule[] getProviderModules( final Scope scope )
{
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> visited = new
ArrayList<DefaultResource>();
+ ArrayList<DefaultModule> stack = new ArrayList<DefaultModule>();
processModuleDependencies( visited, stack, scope, this );
return (DefaultModule[]) stack.toArray( new DefaultModule[0] );
}
private void processModuleDependencies(
- final List visited, final List stack, final Scope scope, final
DefaultResource resource )
+ final List<DefaultResource> visited, final List<DefaultModule> stack,
+ final Scope scope, final DefaultResource resource )
{
if( visited.contains( resource ) )
{
@@ -968,7 +978,7 @@
private DefaultResource[] filterProjects( final DefaultResource[]
resources )
{
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new ArrayList<DefaultResource>();
for( int i=0; i<resources.length; i++ )
{
DefaultResource resource = resources[i];
@@ -977,6 +987,6 @@
list.add( resource );
}
}
- return (DefaultResource[]) list.toArray( new DefaultResource[0] );
+ return list.toArray( new DefaultResource[0] );
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/DefaultResource.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultResource.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/impl/DefaultResource.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,22 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.library.info.InfoDirective;
+import dpml.library.info.TypeDirective;
+import dpml.library.info.ResourceDirective;
+import dpml.library.info.IncludeDirective;
+import dpml.library.info.DependencyDirective;
+import dpml.library.info.AbstractDirective;
+import dpml.library.info.ValidationException;
+import dpml.library.info.FilterDirective;
+
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.ArrayList;
@@ -32,30 +42,22 @@
import java.util.Map;
import java.util.Hashtable;
-import net.dpml.lang.Category;
+import dpml.util.Category;
import net.dpml.lang.Version;
-import net.dpml.library.Info;
-import net.dpml.library.Filter;
-import net.dpml.library.Library;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.Type;
-import net.dpml.library.Data;
-import net.dpml.library.ResourceNotFoundException;
-import net.dpml.library.info.InfoDirective;
-import net.dpml.library.info.TypeDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.ResourceDirective.Classifier;
-import net.dpml.library.info.IncludeDirective;
-import net.dpml.library.info.DependencyDirective;
-import net.dpml.library.info.AbstractDirective;
-import net.dpml.library.info.ValidationException;
-import net.dpml.library.info.FilterDirective;
-import net.dpml.library.info.Scope;
+import dpml.library.Info;
+import dpml.library.Filter;
+import dpml.library.Library;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Type;
+import dpml.library.Classifier;
+import dpml.library.Scope;
+import dpml.library.ResourceNotFoundException;
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
+import net.dpml.transit.Layout;
import net.dpml.util.Resolver;
@@ -103,12 +105,10 @@
private final String[] m_typeNames;
private final String m_path;
private final File m_basedir;
- private final Map m_filters = new Hashtable();
- private final Data[] m_data;
+ private final Map<String,Filter> m_filters = new
Hashtable<String,Filter>();
/**
* Creation of a new default resource.
- * @param logger the assigned logging channel
* @param library the reference library
* @param directive the directive
*/
@@ -123,12 +123,10 @@
m_typeNames = new String[0];
m_path = "";
m_basedir = null;
- m_data = new Data[0];
}
/**
* Creation of a new default resource.
- * @param logger the assigned logging channel
* @param library the reference library
* @param module the parent module
* @param directive the resource directive
@@ -157,18 +155,16 @@
// setup produced types
- m_types = directive.getTypeDirectives();
- m_typeNames = new String[ m_types.length ];
- for( int i=0; i<m_types.length; i++ )
+ TypeDirective[] types = directive.getTypeDirectives();
+ m_types = new Type[types.length];
+ m_typeNames = new String[ types.length ];
+ for( int i=0; i<types.length; i++ )
{
- Type type = m_types[i];
+ TypeDirective type = types[i];
+ m_types[i] = new DefaultType( this, type );
m_typeNames[i] = type.getID();
}
- // setup production data
-
- m_data = new Data[0];
-
// setup the resource basedir
File anchor = getAnchor();
@@ -237,15 +233,6 @@
//----------------------------------------------------------------------------
/**
- * Return a data directives.
- * @return the associated production data
- */
- public Data[] getData()
- {
- return m_data;
- }
-
- /**
* Return the singleton library.
* @return the library
*/
@@ -274,6 +261,25 @@
* Return the resource version.
* @return the version
*/
+ /*
+ public String getVersion( Type type )
+ {
+ Version version = type.getTypeVersion();
+ if( null != version )
+ {
+ return version.toString();
+ }
+ else
+ {
+ return getVersion();
+ }
+ }
+ */
+
+ /**
+ * Return the resource version.
+ * @return the version
+ */
public String getVersion()
{
String version = getStatutoryVersion();
@@ -281,6 +287,10 @@
{
return version;
}
+ else if( m_directive.isAnonymous() )
+ {
+ return version;
+ }
else
{
return getStandardVersion();
@@ -300,7 +310,7 @@
else
{
String version = m_directive.getVersion();
- if( null != version )
+ if( ( null != version ) || m_directive.isAnonymous() )
{
return version;
}
@@ -417,14 +427,29 @@
*/
public Type getType( final String id ) throws IllegalArgumentException
{
- for( int i=0; i<m_types.length; i++ )
+ boolean flag = id.indexOf( '#' ) > -1;
+ if( flag )
{
- Type type = m_types[i];
- if( type.getID().equals( id ) )
+ for( int i=0; i<m_types.length; i++ )
{
- return type;
+ Type type = m_types[i];
+ if( type.getCompoundName().equals( id ) )
+ {
+ return type;
+ }
}
}
+ else
+ {
+ for( int i=0; i<m_types.length; i++ )
+ {
+ Type type = m_types[i];
+ if( type.getID().equals( id ) )
+ {
+ return type;
+ }
+ }
+ }
final String error =
"Type name ["
+ id
@@ -439,7 +464,8 @@
* @param id the resource type id
* @return the link artifact
*/
- public Artifact getLinkArtifact( final String id )
+ /*
+ public Artifact getLinkArtifact( final Type type )
{
if( null == m_directive )
{
@@ -447,22 +473,24 @@
"Method not supported on virtual root.";
throw new UnsupportedOperationException( error );
}
- if( null == id )
+ if( null == type )
{
- throw new NullPointerException( "id" );
+ throw new NullPointerException( "type" );
}
+
+ String id = type.getID();
String group = getGroupName();
- String name = getName();
- Type type = getType( id );
- Version version = type.getVersion();
- if( null == version )
- {
- final String error =
- "Resource does not declare production of an alias for the
requested type."
- + "\nResource: " + this
- + "\nType: " + id;
- throw new IllegalArgumentException( error );
- }
+ String name = getName( type );
+
+ //Version version = type.getVersion();
+ //if( null == version )
+ //{
+ // final String error =
+ // "Resource does not declare production of an alias for the
requested type."
+ // + "\nResource: " + this
+ // + "\nType: " + id;
+ // throw new IllegalArgumentException( error );
+ //}
try
{
String spec = "link:" + id;
@@ -474,15 +502,16 @@
{
spec = spec + ":" + name;
}
- if( !Version.NULL_VERSION.equals( version ) )
- {
- int major = version.getMajor();
- int minor = version.getMinor();
- spec = spec + "#"
- + major
- + "."
- + minor;
- }
+ //if( !Version.NULL_VERSION.equals( version ) )
+ //{
+ // int major = version.getMajor();
+ // int minor = version.getMinor();
+ // spec = spec + "#"
+ // + major
+ // + "."
+ // + minor;
+ //}
+
return Artifact.createArtifact( spec );
}
catch( Throwable e )
@@ -494,13 +523,15 @@
throw new RuntimeException( error, e );
}
}
+ */
/**
* Construct an artifact for the supplied type.
* @param id the resource type identifier
* @return the artifact
*/
- public Artifact getArtifact( final String id )
+ /*
+ public Artifact getArtifact( final Type type, boolean resolve )
{
if( null == m_directive )
{
@@ -508,29 +539,43 @@
"Method not supported on virtual root.";
throw new UnsupportedOperationException( error );
}
- if( null == id )
+ if( null == type )
{
- throw new NullPointerException( "id" );
+ throw new NullPointerException( "type" );
}
+ String id = type.getID();
String group = getGroupName();
- String name = getName();
- String version = getVersion();
+ String name = getName( type );
+ String version = getVersion( type );
String scheme = m_directive.getScheme();
- try
+ if( !resolve )
{
return Artifact.createArtifact( scheme, group, name, version, id
);
}
- catch( Throwable e )
+ else
{
- final String error =
- "Failed to construct artifact for resource ["
- + getResourcePath()
- + "].";
- throw new RuntimeException( error, e );
+ try
+ {
+ Artifact artifact = Artifact.createArtifact( scheme, group,
name, version, id );
+ URL url = artifact.toURL();
+ url.openConnection().connect();
+ return artifact;
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "Unable to resolve the artifact for the type ["
+ + type.getID()
+ + "] on the resource ["
+ + getResourcePath()
+ + "].";
+ throw new IllegalStateException( error, ioe );
+ }
}
}
+ */
/**
* Return the enclosing parent module.
@@ -550,7 +595,7 @@
DefaultModule module = getDefaultParent();
if( null != module )
{
- Map map = new Hashtable();
+ Map<String,Filter> map = new Hashtable<String,Filter>();
Filter[] filters = module.getFilters();
for( int i=0; i<filters.length; i++ )
{
@@ -565,7 +610,7 @@
String token = filter.getToken();
map.put( token, filter );
}
- return (Filter[]) map.values().toArray( new Filter[0] );
+ return map.values().toArray( new Filter[0] );
}
else
{
@@ -608,14 +653,15 @@
try
{
Resource resource = library.getResource( path );
+ Type t = resource.getType( type );
if( ref.startsWith( "resource:" ) )
{
- Artifact artifact = resource.getArtifact( type );
+ Artifact artifact = t.getArtifact();
return artifact.toURI();
}
else
{
- Artifact artifact = resource.getLinkArtifact( type );
+ Artifact artifact = t.getLinkArtifact();
return artifact.toURI();
}
}
@@ -645,7 +691,7 @@
Filter[] getLocalFilters()
{
- return (Filter[]) getFilterMap().values().toArray( new Filter[0] );
+ return (Filter[]) m_filters.values().toArray( new Filter[0] );
}
/**
@@ -689,7 +735,7 @@
public Resource[] getClasspathProviders( final Scope scope )
{
DefaultResource[] result = getAggregatedDefaultProviders( scope,
true, true, true );
- List stack = new ArrayList();
+ List<DefaultResource> stack = new ArrayList<DefaultResource>();
for( int i=0; i<result.length; i++ )
{
DefaultResource resource = result[i];
@@ -698,7 +744,7 @@
stack.add( resource );
}
}
- return (DefaultResource[]) stack.toArray( new DefaultResource[0] );
+ return stack.toArray( new DefaultResource[0] );
}
/**
@@ -746,13 +792,103 @@
* @param id the artifact type
* @return the filename
*/
- public String getLayoutPath( final String id )
+ /*
+ public String getLayoutPath( final String id ) // <-- what about test
types?
{
- Artifact artifact = getArtifact( id );
+ Type type = getType( id );
+ Artifact artifact = getArtifact( type, false );
return Transit.getInstance().getCacheLayout().resolveFilename(
artifact );
}
+ */
/**
+ * Return a filename of a produced type.
+ * @param id the type id
+ * @return the filename
+ */
+
+ /*
+ public File getFile( final Type type )
+ {
+ return getFile( type, false );
+ }
+
+ public File getFile( final Type type, boolean local ) // <!-- TODO:
policy concerning versions on test types
+ {
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+ try
+ {
+ if( type.getTest() )
+ {
+ String id = type.getID();
+ String name = getName( type );
+ String path = "target/test/" + name + "." + id;
+ File basedir = getBaseDir();
+ return new File( basedir, path );
+ }
+ else
+ {
+ if( local )
+ {
+ String id = type.getID();
+ String name = getName( type );
+ String version = getVersion( type );
+ String path = "target/deliverables/" + id + "s/" + name;
+ if( null != version )
+ {
+ path = path + "-" + version;
+ }
+ path = path + "." + id;
+ File basedir = getBaseDir();
+ return new File( basedir, path );
+ }
+ else
+ {
+ Artifact artifact = getArtifact( type, false );
+ Layout layout = Transit.getInstance().getCacheLayout();
+ File cache = Transit.getInstance().getCacheDirectory();
+ String path = layout.resolvePath( artifact );
+ return new File( cache, path );
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to resolve resource path.";
+ throw new RuntimeException( error, e );
+ }
+ }
+ */
+
+ /**
+ * Return a filename of a produced type.
+ * @param id the type id
+ * @return the filename
+ */
+ /*
+ public String getName( final Type type )
+ {
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+ String name = type.getName();
+ if( null == name )
+ {
+ return getName();
+ }
+ else
+ {
+ return name;
+ }
+ }
+ */
+
+ /**
* Return a directive suitable for publication as an external description.
* @param module the enclosing module
* @return the resource directive
@@ -785,7 +921,7 @@
{
TypeDirective type = types[i];
String id = type.getID();
- Version version = type.getVersion();
+ String version = type.getVersion();
export[i] = new TypeDirective( id, version );
}
return export;
@@ -793,7 +929,7 @@
private DependencyDirective[] createDeps( final DefaultModule module )
{
- ArrayList list = new ArrayList();
+ ArrayList<IncludeDirective> list = new ArrayList<IncludeDirective>();
createIncludeDirectives( module, list, Category.SYSTEM );
createIncludeDirectives( module, list, Category.PUBLIC );
createIncludeDirectives( module, list, Category.PROTECTED );
@@ -804,8 +940,7 @@
}
else
{
- IncludeDirective[] includes =
- (IncludeDirective[]) list.toArray( new IncludeDirective[0] );
+ IncludeDirective[] includes = list.toArray( new
IncludeDirective[0] );
DependencyDirective runtime =
new DependencyDirective( Scope.RUNTIME, includes );
return new DependencyDirective[]{runtime};
@@ -836,7 +971,7 @@
}
private void createIncludeDirectives(
- final DefaultModule module, final List list, final Category category )
+ final DefaultModule module, final List<IncludeDirective> list, final
Category category )
{
DefaultResource[] providers =
getDefaultProviders( Scope.RUNTIME, true, category );
@@ -864,7 +999,7 @@
{
Type type = types[j];
String label = type.getID();
- Artifact artifact = provider.getArtifact( label );
+ Artifact artifact = type.getArtifact();
String urn = artifact.toString();
IncludeDirective include =
new IncludeDirective(
@@ -900,7 +1035,14 @@
String toString( final String type )
{
- return type + ":" + getResourcePath() + "#" + getVersion();
+ if( null != getVersion() )
+ {
+ return type + ":" + getResourcePath() + "#" + getVersion();
+ }
+ else
+ {
+ return type + ":" + getResourcePath();
+ }
}
/**
@@ -983,35 +1125,35 @@
DefaultResource[] getAggregatedDefaultProviders(
final Scope scope, final boolean expanded, final boolean flag )
{
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new ArrayList<DefaultResource>();
if( !flag )
{
aggregateProviders( list, Scope.BUILD );
}
- if( scope.isGreaterThan( Scope.BUILD ) )
+ if( scope.compareTo( Scope.BUILD ) > 0 )
{
aggregateProviders( list, Scope.RUNTIME );
}
- if( scope.isGreaterThan( Scope.RUNTIME ) )
+ if( scope.compareTo( Scope.RUNTIME ) > 0 )
{
aggregateProviders( list, Scope.TEST );
}
- DefaultResource[] result = (DefaultResource[]) list.toArray( new
DefaultResource[0] );
+ DefaultResource[] result = list.toArray( new DefaultResource[0] );
if( expanded )
{
- List visited = new ArrayList();
- List stack = new ArrayList();
+ List<DefaultResource> visited = new ArrayList<DefaultResource>();
+ List<DefaultResource> stack = new ArrayList<DefaultResource>();
for( int i=0; i<result.length; i++ )
{
DefaultResource resource = result[i];
expandDefaultResource( visited, stack, scope, resource );
}
- result = (DefaultResource[]) stack.toArray( new
DefaultResource[0] );
+ result = stack.toArray( new DefaultResource[0] );
}
return result;
}
- private void aggregateProviders( final List list, final Scope scope )
+ private void aggregateProviders( final List<DefaultResource> list, final
Scope scope )
{
DefaultResource[] resources = getDefaultProviders( scope, false,
null );
for( int i=0; i<resources.length; i++ )
@@ -1042,8 +1184,8 @@
DefaultResource[] getDefaultProviders(
final Scope scope, final boolean expand, final Category category )
{
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> visited = new
ArrayList<DefaultResource>();
+ ArrayList<DefaultResource> stack = new ArrayList<DefaultResource>();
DefaultResource[] providers = getLocalDefaultProviders( scope,
category );
for( int i=0; i<providers.length; i++ )
{
@@ -1161,7 +1303,8 @@
}
private void expandDefaultResource(
- final List visited, final List stack, final Scope scope, final
DefaultResource resource )
+ final List<DefaultResource> visited, final List<DefaultResource>
stack,
+ final Scope scope, final DefaultResource resource )
{
if( visited.contains( resource ) )
{
@@ -1244,7 +1387,7 @@
{
if( !expand )
{
- ArrayList list = new ArrayList();
+ ArrayList<DefaultResource> list = new
ArrayList<DefaultResource>();
DefaultResource[] resources = m_library.selectDefaultResources(
"**/*" );
for( int i=0; i<resources.length; i++ )
{
@@ -1254,12 +1397,12 @@
list.add( resource );
}
}
- return (DefaultResource[]) list.toArray( new DefaultResource[0]
);
+ return list.toArray( new DefaultResource[0] );
}
else
{
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> visited = new
ArrayList<DefaultResource>();
+ ArrayList<DefaultResource> stack = new
ArrayList<DefaultResource>();
DefaultResource[] consumers = getDefaultConsumers( false );
for( int i=0; i<consumers.length; i++ )
{
@@ -1270,7 +1413,9 @@
}
}
- void processConsumer( final List visited, final List stack, final
DefaultResource consumer )
+ void processConsumer(
+ final List<DefaultResource> visited, final List<DefaultResource>
stack,
+ final DefaultResource consumer )
{
if( visited.contains( consumer ) )
{
@@ -1300,10 +1445,10 @@
*/
private DefaultResource[] getClasspathDefaultProviders( final Category
category )
{
- ArrayList list = new ArrayList();
- for( int i=0; i<category.getValue(); i++ )
+ ArrayList<DefaultResource> list = new ArrayList<DefaultResource>();
+ for( int i=0; i<category.ordinal(); i++ )
{
- Category c = Category.parse( i );
+ Category c = Category.valueOf( i );
DefaultResource[] collection =
getDefaultProviders( Scope.RUNTIME, true, c );
for( int j=0; j<collection.length; j++ )
@@ -1313,7 +1458,7 @@
}
DefaultResource[] resources =
getDefaultProviders( Scope.RUNTIME, true, category );
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> stack = new ArrayList<DefaultResource>();
for( int i=0; i<resources.length; i++ )
{
DefaultResource resource = resources[i];
@@ -1323,7 +1468,7 @@
}
}
- return (DefaultResource[]) stack.toArray( new DefaultResource[0] );
+ return stack.toArray( new DefaultResource[0] );
}
//----------------------------------------------------------------------------
@@ -1337,18 +1482,19 @@
DefaultResource[] sortDefaultResources( final DefaultResource[]
resources, final Scope scope )
{
- ArrayList visited = new ArrayList();
- ArrayList stack = new ArrayList();
+ ArrayList<DefaultResource> visited = new
ArrayList<DefaultResource>();
+ ArrayList<DefaultResource> stack = new ArrayList<DefaultResource>();
for( int i=0; i<resources.length; i++ )
{
DefaultResource resource = resources[i];
resource.sortDefaultResource( visited, stack, scope, resources );
}
- return (DefaultResource[]) stack.toArray( new DefaultResource[0] );
+ return stack.toArray( new DefaultResource[0] );
}
void sortDefaultResource(
- final List visited, final List stack, final Scope scope, final
DefaultResource[] resources )
+ final List<DefaultResource> visited, final List<DefaultResource>
stack,
+ final Scope scope, final DefaultResource[] resources )
{
if( visited.contains( this ) )
{
@@ -1527,7 +1673,7 @@
}
}
- private String getGroupName()
+ String getGroupName()
{
if( m_parent.isRoot() )
{
@@ -1538,4 +1684,9 @@
return m_parent.getResourcePath();
}
}
+
+ String getScheme()
+ {
+ return m_directive.getScheme();
+ }
}
Added: trunk/main/depot/library/src/main/dpml/library/impl/DefaultType.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultType.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/impl/DefaultType.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,291 @@
+/*
+ * Copyright 2007 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 dpml.library.impl;
+
+import dpml.library.info.TypeDirective;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.Hashtable;
+
+import dpml.library.Type;
+import dpml.library.Resource;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Layout;
+import net.dpml.transit.Transit;
+
+import net.dpml.util.Logger;
+
+/**
+ * Utility class used for construction of a module model from an XML source.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class DefaultType extends DefaultDictionary implements Type
+{
+ private final TypeDirective m_directive;
+ private final DefaultResource m_resource;
+
+ /**
+ * Creation of a new type.
+ * @param resource the resource
+ * @param type the type directive
+ */
+ public DefaultType( DefaultResource resource, TypeDirective type )
+ {
+ super( resource, type );
+
+ if( null == resource )
+ {
+ throw new NullPointerException( "resource" );
+ }
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+
+ m_directive = type;
+ m_resource = resource;
+ }
+
+
//----------------------------------------------------------------------------
+ // Type
+
//----------------------------------------------------------------------------
+
+ /**
+ * Return the resource holding the type.
+ * @return the resource
+ */
+ public Resource getResource()
+ {
+ return m_resource;
+ }
+
+ /**
+ * Return the type production id.
+ * @return the type id
+ */
+ public String getID()
+ {
+ return m_directive.getID();
+ }
+
+ /**
+ * Return the alias version.
+ * @return the alias version value (may be null)
+ */
+ public String getVersion()
+ {
+ String version = m_directive.getVersion();
+ if( null == version )
+ {
+ return m_resource.getVersion();
+ }
+ else
+ {
+ return version;
+ }
+ }
+
+ public String getName()
+ {
+ String name = m_directive.getName();
+ if( null == name )
+ {
+ return m_resource.getName();
+ }
+ else
+ {
+ return name;
+ }
+ }
+
+ public String getCompoundName()
+ {
+ String name = m_directive.getName();
+ if( null == name )
+ {
+ return getID();
+ }
+ else
+ {
+ return getID() + "#" + name;
+ }
+ }
+
+ public String getSource()
+ {
+ return m_directive.getSource();
+ }
+
+ public boolean getTest()
+ {
+ return m_directive.getTest();
+ }
+
+ /**
+ * Return the alias production flag.
+ * @return the alias flag
+ */
+ public boolean getAliasProduction()
+ {
+ return m_directive.getAliasProduction();
+ }
+
+ /**
+ * Return the type local filename.
+ * @return the filename
+ */
+ public File getFile()
+ {
+ return getFile( false );
+ }
+
+ /**
+ * Return the type filename.
+ * @param local true if the requested filename is the local filename
otherwise the
+ * cached filename is returned
+ * @return the filename
+ */
+ public File getFile( boolean local ) // <!-- TODO: policy concerning
versions on test types
+ {
+ try
+ {
+ if( getTest() )
+ {
+ String id = getID();
+ String name = getName();
+ String path = "target/test/" + name + "." + id;
+ File basedir = m_resource.getBaseDir();
+ return new File( basedir, path );
+ }
+ else
+ {
+ if( local )
+ {
+ String id = getID();
+ String name = getName();
+ String version = getVersion();
+ String path = "target/deliverables/" + id + "s/" + name;
+ if( null != version )
+ {
+ path = path + "-" + version;
+ }
+ path = path + "." + id;
+ File basedir = m_resource.getBaseDir();
+ return new File( basedir, path );
+ }
+ else
+ {
+ Artifact artifact = getArtifact();
+ Layout layout = Transit.getInstance().getCacheLayout();
+ File cache = Transit.getInstance().getCacheDirectory();
+ String path = layout.resolvePath( artifact );
+ return new File( cache, path );
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to resolve resource path.";
+ throw new RuntimeException( error, e );
+ }
+ }
+
+ public Artifact getArtifact()
+ {
+ String id = getID();
+ String group = m_resource.getGroupName();
+ String name = getName();
+ String version = getVersion();
+ String scheme = m_resource.getScheme();
+ return Artifact.createArtifact( scheme, group, name, version, id );
+ }
+
+ public Artifact getResolvedArtifact() throws IOException
+ {
+ try
+ {
+ Artifact artifact = getArtifact();
+ URL url = artifact.toURL();
+ url.openConnection().connect();
+ return artifact;
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "Unable to resolve the artifact for the type ["
+ + getID()
+ + "] on the resource ["
+ + m_resource.getResourcePath()
+ + "].";
+ IOException e = new IOException( error );
+ e.initCause( ioe );
+ throw e;
+ }
+ }
+
+ public Artifact getLinkArtifact()
+ {
+ String id = getID();
+ String group = m_resource.getGroupName();
+ String name = getName();
+
+ try
+ {
+ String spec = "link:" + id;
+ if( null != group )
+ {
+ spec = spec + ":" + group + "/" + name;
+ }
+ else
+ {
+ spec = spec + ":" + name;
+ }
+ return Artifact.createArtifact( spec );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Failed to construct link artifact for resource ["
+ + m_resource.getResourcePath()
+ + "].";
+ throw new RuntimeException( error, e );
+ }
+ }
+
+ /**
+ * Return a filename using the layout strategy employed by the cache.
+ * @return the path
+ */
+ public String getLayoutPath()
+ {
+ Artifact artifact = getArtifact();
+ return Transit.getInstance().getCacheLayout().resolveFilename(
artifact );
+ }
+}
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/InvalidNameException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/InvalidNameException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/impl/InvalidNameException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
/**
* Internal exception throw to indicate a bad name reference.
@@ -24,7 +24,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-class InvalidNameException extends RuntimeException
+public class InvalidNameException extends RuntimeException
{
/**
* Creation of a new InvalidNameException.
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/InvalidProcessorNameException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/InvalidProcessorNameException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/impl/InvalidProcessorNameException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
/**
* Internal exception throw when an attempt is made to reference a processor
Modified:
trunk/main/depot/library/src/main/dpml/library/impl/InvalidTypeNameException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/impl/InvalidTypeNameException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/impl/InvalidTypeNameException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
/**
* Internal exception throw when an attempt is made to reference a type
Modified:
trunk/main/depot/library/src/main/dpml/library/info/AbstractDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/AbstractDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/AbstractDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.io.Serializable;
import java.util.Properties;
Deleted:
trunk/main/depot/library/src/main/dpml/library/info/DataDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/DataDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/DataDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,95 +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.library.info;
-
-import net.dpml.library.Data;
-
-import java.util.Properties;
-
-import org.w3c.dom.Element;
-
-/**
- * Base class for a data directives.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class DataDirective extends AbstractDirective implements Data
-{
- private final Element m_element;
-
- /**
- * Creation of a new data directive using a DOM element as the
- * datastructure definition.
- * @param element the DOM element
- */
- public DataDirective( Element element )
- {
- super();
- m_element = element;
- }
-
- /**
- * Creation of a new data directive using a supplied properties argument.
- * @param properties associated properties
- */
- public DataDirective( Properties properties )
- {
- super( properties );
- m_element = null;
- }
-
- /**
- * Return the datatype element.
- * @return the DOM element
- */
- public Element getElement()
- {
- return m_element;
- }
-
- /**
- * 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 DataDirective ) )
- {
- DataDirective object = (DataDirective) other;
- return equals( m_element, object.m_element );
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Compute the hash value.
- * @return the hascode value
- */
- public int hashCode()
- {
- int hash = super.hashCode();
- hash ^= hashValue( m_element );
- return hash;
- }
-}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/DependencyDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/DependencyDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/DependencyDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,16 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Arrays;
import java.util.Properties;
import java.util.ArrayList;
-import net.dpml.lang.Category;
+import dpml.library.Scope;
+import dpml.util.Category;
+
/**
* The ModuleDirective class describes a module data-structure.
*
@@ -112,7 +114,7 @@
{
return m_includes;
}
- ArrayList list = new ArrayList();
+ ArrayList<IncludeDirective> list = new ArrayList<IncludeDirective>();
for( int i=0; i<m_includes.length; i++ )
{
IncludeDirective include = m_includes[i];
@@ -121,7 +123,7 @@
list.add( include );
}
}
- return (IncludeDirective[]) list.toArray( new IncludeDirective[0] );
+ return list.toArray( new IncludeDirective[0] );
}
/**
Modified:
trunk/main/depot/library/src/main/dpml/library/info/FeatureFilterDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/FeatureFilterDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/FeatureFilterDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,15 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.library.Feature;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
-import net.dpml.library.Type;
+import dpml.library.Feature;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
+import dpml.library.Type;
+import dpml.util.ObjectUtils;
+
/**
* Simple value filter.
*
@@ -260,7 +262,7 @@
*/
public boolean equals( Object other )
{
- if( super.equals( other ) && ( other instanceof
FeatureFilterDirective ) )
+ if( other instanceof FeatureFilterDirective )
{
FeatureFilterDirective directive = (FeatureFilterDirective)
other;
if( !m_feature.equals( directive.m_feature ) )
@@ -292,10 +294,10 @@
*/
public int hashCode()
{
- int hash = super.hashCode();
- hash ^= super.hashValue( m_feature );
- hash ^= super.hashValue( m_reference );
- hash ^= super.hashValue( m_type );
+ int hash = getClass().hashCode();
+ hash ^= ObjectUtils.hashValue( m_feature );
+ hash ^= ObjectUtils.hashValue( m_reference );
+ hash ^= ObjectUtils.hashValue( m_type );
if( m_alias )
{
hash ^= 1;
Modified:
trunk/main/depot/library/src/main/dpml/library/info/FilterDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/FilterDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/FilterDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,13 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.lang.AbstractDirective;
+import dpml.library.Filter;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
-import net.dpml.library.Filter;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
+import dpml.util.ObjectUtils;
/**
* Base class for filter directives.
@@ -30,7 +30,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public abstract class FilterDirective extends AbstractDirective implements
Filter
+public abstract class FilterDirective implements Filter
{
private final String m_token;
@@ -68,7 +68,7 @@
*/
public boolean equals( Object other )
{
- if( super.equals( other ) && ( other instanceof FilterDirective ) )
+ if( other instanceof FilterDirective )
{
FilterDirective directive = (FilterDirective) other;
return m_token.equals( directive.m_token );
@@ -85,8 +85,8 @@
*/
public int hashCode()
{
- int hash = super.hashCode();
- hash ^= super.hashValue( m_token );
+ int hash = getClass().hashCode();
+ hash ^= ObjectUtils.hashValue( m_token );
return hash;
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/ImportDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ImportDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/ImportDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,10 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Properties;
-import net.dpml.lang.Enum;
-
/**
* The ImportDirective class describes a the import of resource via a file
or uri reference.
*
@@ -134,50 +132,16 @@
/**
* Mode of inclusion.
*/
- public static final class Mode extends Enum
+ public enum Mode
{
- static final long serialVersionUID = 1L;
-
/**
* File include stratgy constant.
*/
- public static final Mode FILE = new Mode( "file" );
+ FILE,
/**
* URI include stratgy constant.
*/
- public static final Mode URI = new Mode( "uri" );
-
- /**
- * Internal constructor.
- * @param label the enumeration label.
- */
- private Mode( String label )
- {
- super( label );
- }
-
- /**
- * Create a now mode using a supplied mode name.
- * @param value the mode name
- * @return the mode
- */
- public static Mode parse( String value )
- {
- if( value.equalsIgnoreCase( "file" ) )
- {
- return FILE;
- }
- else if( value.equalsIgnoreCase( "uri" ) )
- {
- return URI;
- }
- else
- {
- final String error =
- "Unrecognized module mode argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
+ URI;
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/IncludeDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/IncludeDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/IncludeDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,11 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Properties;
-import net.dpml.lang.Category;
-import net.dpml.lang.Enum;
+import dpml.util.Category;
/**
* The IncludeDirective class describes a dependency on a named resource.
@@ -71,7 +70,7 @@
}
if( null == category )
{
- m_category = Category.UNDEFINED; // was PRIVATE
+ m_category = Category.PRIVATE; // was PRIVATE the changed to
UNDEFINED
}
else
{
@@ -162,59 +161,21 @@
/**
* Mode of inclusion.
*/
- public static final class Mode extends Enum
+ public enum Mode
{
- static final long serialVersionUID = 1L;
-
/**
* Include by reference to a local key.
*/
- public static final Mode KEY = new Mode( "key" );
+ KEY,
/**
* Include by reference to an absolute resource address.
*/
- public static final Mode REF = new Mode( "ref" );
+ REF,
/**
* Include by urn definition.
*/
- public static final Mode URI = new Mode( "uri" );
-
- /**
- * Internal constructor.
- * @param label the enumeration label.
- */
- private Mode( String label )
- {
- super( label );
- }
-
- /**
- * Create a now mode using a supplied mode name.
- * @param value the mode name
- * @return the mode
- */
- public static Mode parse( String value )
- {
- if( value.equalsIgnoreCase( "key" ) )
- {
- return KEY;
- }
- else if( value.equalsIgnoreCase( "ref" ) )
- {
- return REF;
- }
- else if( value.equalsIgnoreCase( "uri" ) )
- {
- return URI;
- }
- else
- {
- final String error =
- "Unrecognized resource mode argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
+ URI;
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/InfoDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/InfoDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/InfoDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,19 +16,21 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.lang.AbstractDirective;
+import java.io.Serializable;
-import net.dpml.library.Info;
+import dpml.util.ObjectUtils;
+import dpml.library.Info;
+
/**
* Info block descriptor.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public final class InfoDirective extends AbstractDirective implements Info
+public final class InfoDirective implements Info, Serializable
{
private final String m_title;
private final String m_description;
@@ -79,16 +81,16 @@
*/
public boolean equals( Object other )
{
- if( super.equals( other ) && ( other instanceof InfoDirective ) )
+ if( other instanceof InfoDirective )
{
InfoDirective info = (InfoDirective) other;
- if( !equals( m_title, info.m_title ) )
+ if( !ObjectUtils.equals( m_title, info.m_title ) )
{
return false;
}
else
{
- return equals( m_description, info.m_description );
+ return ObjectUtils.equals( m_description, info.m_description
);
}
}
else
@@ -103,9 +105,9 @@
*/
public int hashCode()
{
- int hash = super.hashCode();
- hash ^= super.hashValue( m_title );
- hash ^= super.hashValue( m_description );
+ int hash = getClass().hashCode();
+ hash ^= ObjectUtils.hashValue( m_title );
+ hash ^= ObjectUtils.hashValue( m_description );
return hash;
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/LibraryConstants.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/LibraryConstants.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/LibraryConstants.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* Abstract base class for encoder and decoder..
@@ -26,8 +26,8 @@
*/
abstract class LibraryConstants
{
- static final String PART_XSD_URI = "@PART-XSD-URI@";
- static final String MODULE_XSD_URI = "@MODULE-XSD-URI@";
+ static final String PART_XSD_URI = "@PART-XSD-SPEC-URI@";
+ static final String MODULE_XSD_URI = "dpml:library";
static final String XML_HEADER =
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
Modified:
trunk/main/depot/library/src/main/dpml/library/info/LibraryDecoder.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/LibraryDecoder.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/LibraryDecoder.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -17,8 +17,11 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
+import dpml.lang.DOM3DocumentBuilder;
+import dpml.util.ElementHelper;
+
import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
@@ -28,18 +31,14 @@
import java.util.ArrayList;
import java.util.Properties;
-import net.dpml.library.Feature;
-import net.dpml.library.TypeBuilder;
-import net.dpml.library.info.ResourceDirective.Classifier;
+import dpml.library.Feature;
+import dpml.library.Classifier;
+import dpml.library.Scope;
-import net.dpml.lang.Category;
-import net.dpml.lang.Part;
+import dpml.util.Category;
import net.dpml.lang.Version;
+import net.dpml.lang.DecodingException;
-import net.dpml.util.DecodingException;
-import net.dpml.util.DOM3DocumentBuilder;
-import net.dpml.util.ElementHelper;
-
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.TypeInfo;
@@ -78,20 +77,22 @@
+ "] references a directory.";
throw new IllegalArgumentException( error );
}
+ final Element root = getRootElement( source );
try
{
- final Element root = getRootElement( source );
File base = source.getParentFile();
return buildLibraryDirective( base, root );
}
+ catch( DecodingException e )
+ {
+ throw e;
+ }
catch( Exception e )
{
final String error =
"Unexpected error while attempting to load library."
- + "File: '" + source + "'";
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
+ + "\nFile: '" + source + "'";
+ throw new DecodingException( error, e, root );
}
}
@@ -154,7 +155,7 @@
Properties properties = null;
ImportDirective[] imports = new ImportDirective[0];
- List list = new ArrayList();
+ List<ResourceDirective> list = new ArrayList<ResourceDirective>();
Element[] children = ElementHelper.getChildren( element );
for( int i=0; i<children.length; i++ )
{
@@ -174,7 +175,7 @@
list.add( resource );
}
}
- ResourceDirective[] resources = (ResourceDirective[]) list.toArray(
new ResourceDirective[0] );
+ ResourceDirective[] resources = list.toArray( new
ResourceDirective[0] );
return new LibraryDirective( imports, resources, properties );
}
@@ -203,7 +204,7 @@
+ "\n base: " + base
+ "\n path: " + path
+ "\n source: " + source;
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
else if( source.isDirectory() )
{
@@ -212,7 +213,7 @@
+ "\n base: " + base
+ "\n path: " + path
+ "\n source: " + source;
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
else
{
@@ -234,7 +235,7 @@
{
final String error =
"Internal error while attempting to resolve a import
directive.";
- throw new DecodingException( element, error, e );
+ throw new DecodingException( error, e, element );
}
}
else
@@ -298,8 +299,8 @@
buildInfoDirective(
ElementHelper.getChild( element, "info" ) );
- final DataDirective[] data =
- buildDataTypes(
+ final TypeDirective[] data =
+ buildTypeDirectives(
ElementHelper.getChild( element, "types" ) );
final DependencyDirective[] dependencies =
@@ -317,7 +318,7 @@
if( MODULE_ELEMENT_NAME.equals( tag ) )
{
File anchor = getAnchorDirectory( base, basedir );
- ArrayList list = new ArrayList();
+ ArrayList<ResourceDirective> list = new
ArrayList<ResourceDirective>();
Element[] children = ElementHelper.getChildren( element );
for( int i=0; i<children.length; i++ )
{
@@ -334,8 +335,7 @@
}
}
- ResourceDirective[] resources =
- (ResourceDirective[]) list.toArray( new
ResourceDirective[0] );
+ ResourceDirective[] resources = list.toArray( new
ResourceDirective[0] );
return ModuleDirective.createModuleDirective(
name, version, classifier, basedir, info, data,
dependencies,
properties, filters, resources );
@@ -353,7 +353,7 @@
"Invalid element name ["
+ tag
+ "].";
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
}
@@ -446,7 +446,7 @@
{
final String error =
"Internal error while attempting to resolve an import
directive.";
- throw new DecodingException( element, error, e );
+ throw new DecodingException( error, e, element );
}
}
else
@@ -492,8 +492,8 @@
private DependencyDirective buildDependencyDirective( Element element )
throws DecodingException
{
- String name = element.getTagName();
- Scope scope = Scope.parse( name );
+ String name = element.getTagName().toUpperCase();
+ Scope scope = Scope.valueOf( name );
if( Scope.BUILD.equals( scope ) )
{
IncludeDirective[] includes = buildIncludeDirectives( element,
false );
@@ -565,7 +565,7 @@
"Invalid include element name ["
+ tag
+ "].";
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
}
@@ -573,12 +573,12 @@
{
if( !flag )
{
- return Category.UNDEFINED;
+ return Category.PRIVATE; // was UNDEFINED
}
else
{
final String value = ElementHelper.getAttribute( element, "tag",
"private" );
- return Category.parse( value );
+ return Category.valueOf( value.toUpperCase() );
}
}
@@ -647,8 +647,8 @@
}
else if( "feature".equals( child.getTagName() ) )
{
- String id = ElementHelper.getAttribute( child, "id" );
- Feature feature = Feature.parse( id );
+ String id = ElementHelper.getAttribute( child, "id"
).toUpperCase();
+ Feature feature = Feature.valueOf( id );
String ref = ElementHelper.getAttribute( child, "ref" );
String type = ElementHelper.getAttribute( child, "type"
);
boolean alias = ElementHelper.getBooleanAttribute(
child, "alias" );
@@ -660,96 +660,44 @@
"Element name not recognized ["
+ child.getTagName()
+ "] (expecting 'filter').";
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
}
return filters;
}
}
- private DataDirective[] buildDataTypes( Element element ) throws
Exception
+ private TypeDirective[] buildTypeDirectives( Element element ) throws
Exception
{
if( null == element )
{
- return new DataDirective[0];
+ return new TypeDirective[0];
}
Element[] children = ElementHelper.getChildren( element );
- DataDirective[] data = new DataDirective[ children.length ];
+ TypeDirective[] data = new TypeDirective[ children.length ];
for( int i=0; i<children.length; i++ )
{
Element child = children[i];
- data[i] = buildDataType( child );
+ data[i] = buildTypeDirective( child );
}
return data;
}
- private DataDirective buildDataType( Element element ) throws Exception
+ private TypeDirective buildTypeDirective( Element element ) throws
Exception
{
- TypeInfo info = element.getSchemaTypeInfo();
- String namespace = info.getTypeNamespace();
- String typeName = info.getTypeName();
-
- if( null == namespace )
- {
- throw new NullPointerException( "namespace" );
- }
-
- if( MODULE_XSD_URI.equals( namespace ) )
- {
- // it's a generic type declaration
-
- final String id = getID( element );
- final Properties properties = getProperties( element );
- final Version version = getVersion( element );
- return new TypeDirective( id, version, properties );
- }
- else if( info.isDerivedFrom( MODULE_XSD_URI, "AbstractType",
TypeInfo.DERIVATION_EXTENSION ) )
- {
- if(
- PART_XSD_URI.equals( namespace )
- || info.isDerivedFrom( PART_XSD_URI, "StrategyType",
TypeInfo.DERIVATION_EXTENSION ) )
- {
- final Version version = getVersion( element );
- return new TypeDirective( element, "part", version );
- }
- else
- {
- // id attribute is required
-
- final String id = getID( element );
- final Version version = getVersion( element );
- return new TypeDirective( element, id, version );
- }
- }
- else
- {
- final String error =
- "Unsupported element encountered during type directive
production."
- + "\nNamespace: "
- + namespace
- + "\nType: "
- + info.getTypeName()
- + "\nName: "
- + element.getTagName();
- throw new DecodingException( element, error );
- }
+ final String id = getID( element );
+ final Properties properties = getProperties( element );
+ final String version = getVersion( element );
+ final String source = getSource( element );
+ final String name = ElementHelper.getAttribute( element, "name" );
+ boolean alias = getAliasPolicy( element );
+ ProductionPolicy production = getProductionPolicy( element );
+ return new TypeDirective( production, id, name, version, alias,
source, properties );
}
- private Version getVersion( Element element )
+ private String getVersion( Element element )
{
- final String version = ElementHelper.getAttribute( element,
"version" );
- if( null != version )
- {
- return Version.parse( version );
- }
- else if( getAliasFlag( element ) )
- {
- return Version.NULL_VERSION;
- }
- else
- {
- return null;
- }
+ return ElementHelper.getAttribute( element, "version" );
}
private Properties buildProperties( Element element )
@@ -806,28 +754,6 @@
}
}
- private TypeBuilder loadTypeBuilder( URI uri ) throws Exception
- {
- ClassLoader classloader = TypeBuilder.class.getClassLoader();
- Object[] args = new Object[0];
- Part part = Part.load( uri );
- Object handler = part.instantiate( args );
- if( handler instanceof TypeBuilder )
- {
- return (TypeBuilder) handler;
- }
- else
- {
- final String error =
- "Plugin ["
- + uri
- + "] does not implement the "
- + TypeBuilder.class.getName()
- + " interface.";
- throw new IllegalArgumentException( error );
- }
- }
-
/**
* Return the id attribute of the supplied element.
* @param element the DOM element
@@ -841,7 +767,7 @@
{
final String error =
"Missing type 'id'.";
- throw new DecodingException( element, error );
+ throw new DecodingException( error, null, element );
}
else
{
@@ -850,15 +776,38 @@
}
/**
+ * Return the source attribute of the supplied element.
+ * @param element the DOM element
+ * @return the source value
+ */
+ protected String getSource( Element element )
+ {
+ return ElementHelper.getAttribute( element, "source" );
+ }
+
+ /**
* Return the alias attribute of the supplied element.
* @param element the DOM element
* @return the alias production flag value
*/
- protected boolean getAliasFlag( Element element )
+ protected boolean getAliasPolicy( Element element )
{
return ElementHelper.getBooleanAttribute( element, "alias", false );
}
+ private ProductionPolicy getProductionPolicy( Element element )
+ {
+ boolean flag = ElementHelper.getBooleanAttribute( element, "test",
false );
+ if( flag )
+ {
+ return ProductionPolicy.TEST;
+ }
+ else
+ {
+ return ProductionPolicy.DELIVERABLE;
+ }
+ }
+
/**
* Return properties declared within the supplied element as immediate
* child <property> elements.
Modified:
trunk/main/depot/library/src/main/dpml/library/info/LibraryDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/LibraryDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/LibraryDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Arrays;
import java.util.Properties;
Modified:
trunk/main/depot/library/src/main/dpml/library/info/LibraryEncoder.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/LibraryEncoder.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/LibraryEncoder.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.io.OutputStream;
import java.io.IOException;
@@ -24,11 +24,13 @@
import java.io.OutputStreamWriter;
import java.util.Properties;
-import net.dpml.lang.Category;
+import dpml.util.Category;
import net.dpml.lang.Version;
-import net.dpml.library.info.IncludeDirective.Mode;
+import dpml.library.Classifier;
+import dpml.library.Scope;
+import dpml.library.info.IncludeDirective.Mode;
/**
* Utility class used for construction of a module model from an XML source.
@@ -279,18 +281,20 @@
{
String id = type.getID();
writer.write( "\n" + lead + "<type id=\"" + id + "\"" );
- Version version = type.getVersion();
+ String version = type.getVersion();
if( null != version )
{
- if( Version.NULL_VERSION.equals( version ) )
- {
- writer.write( " alias=\"true\"" );
- }
- else
- {
- writer.write( " version=\"" + version.getMajor() + "." +
version.getMinor() + "\"" );
- }
+ writer.write( " version=\"" + version + "\"" );
}
+ String name = type.getName();
+ if( null != name )
+ {
+ writer.write( " name=\"" + name + "\"" );
+ }
+ if( type.getAliasProduction() )
+ {
+ writer.write( " alias=\"true\"" );
+ }
writer.write( "/>" );
}
@@ -308,7 +312,7 @@
if( includes.length > 0 )
{
Scope scope = dependency.getScope();
- String label = scope.toString().toLowerCase();
+ String label = scope.name().toLowerCase();
writer.write( "\n" + lead + " <" + label + ">" );
for( int j=0; j<includes.length; j++ )
{
@@ -334,7 +338,7 @@
Category category = include.getCategory();
if( !Category.PRIVATE.equals( category ) )
{
- String name =
category.getName().toLowerCase();
+ String name = category.name().toLowerCase();
writer.write( " tag=\"" + name + "\"" );
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/ModuleDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/ModuleDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,14 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Arrays;
import java.util.Properties;
+import dpml.library.Classifier;
+import dpml.library.Scope;
+
/**
* The ModuleDirective class describes a module data-structure.
*
@@ -50,7 +53,7 @@
*/
public static ModuleDirective createModuleDirective(
String name, String version, Classifier classifier, String basedir,
- InfoDirective info, DataDirective[] data,
+ InfoDirective info, TypeDirective[] data,
DependencyDirective[] dependencies, Properties properties,
FilterDirective[] filters, ResourceDirective[] resources )
{
@@ -74,7 +77,7 @@
enclosing =
new ModuleDirective(
elem, null, Classifier.EXTERNAL, null, null,
- new DataDirective[0], new DependencyDirective[0],
+ new TypeDirective[0], new DependencyDirective[0],
new ResourceDirective[]{enclosing}, null, null );
}
}
@@ -100,7 +103,7 @@
{
this(
name, version, Classifier.ANONYMOUS, null, null,
- new DataDirective[0], new DependencyDirective[0],
+ new TypeDirective[0], new DependencyDirective[0],
new ResourceDirective[]{resource}, null, null );
}
@@ -119,7 +122,7 @@
*/
public ModuleDirective(
String name, String version, Classifier classifier, String basedir,
- InfoDirective info, DataDirective[] data,
+ InfoDirective info, TypeDirective[] data,
DependencyDirective[] dependencies, ResourceDirective[] resources,
Properties properties, FilterDirective[] filters )
{
Added:
trunk/main/depot/library/src/main/dpml/library/info/ProductionPolicy.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ProductionPolicy.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/ProductionPolicy.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007 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 dpml.library.info;
+
+/**
+ * Enumeration identifying BUILD, RUNTIME and TEST phases.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public enum ProductionPolicy
+{
+ /**
+ * Deliverable resource.
+ */
+ DELIVERABLE,
+
+ /**
+ * Test resource
+ */
+ TEST
+}
+
Modified:
trunk/main/depot/library/src/main/dpml/library/info/ResourceDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ResourceDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/ResourceDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,14 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Properties;
-import net.dpml.lang.Enum;
+import dpml.library.Classifier;
+import dpml.library.Scope;
import net.dpml.transit.Artifact;
@@ -54,7 +55,6 @@
private final String m_version;
private final String m_basedir;
private final TypeDirective[] m_types;
- private final DataDirective[] m_data;
private final DependencyDirective[] m_dependencies;
private final Classifier m_classifier;
private final FilterDirective[] m_filters;
@@ -85,7 +85,7 @@
* @param classifier LOCAL or EXTERNAL classifier
* @param basedir the project basedir
* @param info info descriptor
- * @param data types produced by the resource
+ * @param types types produced by the resource
* @param dependencies resource dependencies
* @param properties suppliementary properties
* @param filters project filters
@@ -93,7 +93,7 @@
*/
public static ResourceDirective createResourceDirective(
String name, String version, Classifier classifier, String basedir,
- InfoDirective info, DataDirective[] data,
+ InfoDirective info, TypeDirective[] types,
DependencyDirective[] dependencies, Properties properties,
FilterDirective[] filters )
{
@@ -109,7 +109,7 @@
{
resource =
new ResourceDirective(
- elem, version, classifier, basedir, info, data,
dependencies,
+ elem, version, classifier, basedir, info, types,
dependencies,
properties, filters );
}
else
@@ -117,7 +117,7 @@
resource =
new ModuleDirective(
elem, null, Classifier.EXTERNAL, null, null,
- new DataDirective[0], new DependencyDirective[0],
+ new TypeDirective[0], new DependencyDirective[0],
new ResourceDirective[]{resource}, null, null );
}
}
@@ -126,7 +126,7 @@
else
{
return new ResourceDirective(
- name, version, classifier, basedir, info, data,
+ name, version, classifier, basedir, info, types,
dependencies, properties, filters );
}
}
@@ -150,7 +150,6 @@
m_name = name;
m_types = new TypeDirective[]{new TypeDirective( type )};
- m_data = m_types;
m_dependencies = new DependencyDirective[0];
m_classifier = Classifier.ANONYMOUS;
m_version = version;
@@ -174,7 +173,7 @@
*/
ResourceDirective(
String name, String version, Classifier classifier, String basedir,
- InfoDirective info, DataDirective[] data,
+ InfoDirective info, TypeDirective[] types,
DependencyDirective[] dependencies, Properties properties,
FilterDirective[] filters )
{
@@ -184,9 +183,9 @@
{
throw new NullPointerException( "name" );
}
- if( null == data )
+ if( null == types )
{
- throw new NullPointerException( "data" );
+ throw new NullPointerException( "types" );
}
if( null == dependencies )
{
@@ -223,17 +222,7 @@
m_filters = filters;
}
- ArrayList list = new ArrayList();
- for( int i=0; i<data.length; i++ )
- {
- DataDirective directive = data[i];
- if( directive instanceof TypeDirective )
- {
- list.add( directive );
- }
- }
- m_types = (TypeDirective[]) list.toArray( new TypeDirective[0] );
- m_data = data;
+ m_types = types;
}
/**
@@ -329,16 +318,6 @@
}
/**
- * Return an array of supporting production data directives
- * (including all produced types).
- * @return the data directives
- */
- public DataDirective[] getDataDirectives()
- {
- return m_data;
- }
-
- /**
* Return an named type.
* @param name the type name
* @return the type directives
@@ -357,7 +336,7 @@
}
throw new TypeUnknownException( name );
}
-
+
/**
* Return an array of dependency directives.
* @return the dependency directive array
@@ -415,7 +394,7 @@
{
return false;
}
- else if( !Arrays.equals( m_data, object.m_data ) )
+ else if( !Arrays.equals( m_types, object.m_types ) )
{
return false;
}
@@ -442,70 +421,9 @@
hash ^= super.hashValue( m_version );
hash ^= super.hashValue( m_basedir );
hash ^= super.hashValue( m_info );
- hash ^= super.hashArray( m_data );
+ hash ^= super.hashArray( m_types );
hash ^= super.hashArray( m_dependencies );
hash ^= super.hashArray( m_filters );
return hash;
}
-
- /**
- * Resource classifier enumeration.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital
Product Meta Library</a>
- */
- public static final class Classifier extends Enum
- {
- static final long serialVersionUID = 1L;
-
- /**
- * Anonymous resources.
- */
- public static final Classifier ANONYMOUS = new Classifier(
"anonymous" );
-
- /**
- * External resource.
- */
- public static final Classifier EXTERNAL = new Classifier( "external"
);
-
- /**
- * Local resources.
- */
- public static final Classifier LOCAL = new Classifier( "local" );
-
- /**
- * Internal constructor.
- * @param label the enumeration label.
- */
- private Classifier( String label )
- {
- super( label );
- }
-
- /**
- * Create a classified matching the supplied name.
- * @param value the classifier name
- * @return the classifier
- * @exception IllegalArgumentException if the supplied value is not
recognized
- */
- public static Classifier parse( String value ) throws
IllegalArgumentException
- {
- if( value.equalsIgnoreCase( "external" ) )
- {
- return EXTERNAL;
- }
- else if( value.equalsIgnoreCase( "local" ) )
- {
- return LOCAL;
- }
- else if( value.equalsIgnoreCase( "anonymous" ) )
- {
- return ANONYMOUS;
- }
- else
- {
- final String error =
- "Unrecognized module classifier argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
- }
}
Modified: trunk/main/depot/library/src/main/dpml/library/info/Scope.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/info/Scope.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/Scope.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,94 +16,30 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.lang.ValuedEnum;
-
/**
* Enumeration identifying BUILD, RUNTIME and TEST phases.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public final class Scope extends ValuedEnum implements Comparable
+public enum Scope
{
- static final long serialVersionUID = 1L;
-
/**
* Build scope.
*/
- public static final Scope BUILD = new Scope( "build", 0 );
+ BUILD,
/**
* Runtime scope.
*/
- public static final Scope RUNTIME = new Scope( "runtime", 1 );
+ RUNTIME,
/**
* Test scope.
*/
- public static final Scope TEST = new Scope( "test", 2 );
-
- /**
- * Array of scope enumeration values.
- */
- private static final Scope[] ENUM_VALUES = new Scope[]{BUILD, RUNTIME,
TEST};
-
- /**
- * Returns an array of activation enum values.
- * @return the activation policies array
- */
- public static Scope[] values()
- {
- return ENUM_VALUES;
- }
+ TEST;
- /**
- * Internal constructor.
- * @param label the enumeration label.
- * @param index the enumeration index.
- */
- private Scope( String label, int index )
- {
- super( label, index );
- }
-
- /**
- * Return a string representation of the scope.
- * @return the string value
- */
- public String toString()
- {
- return getName().toUpperCase();
- }
-
- /**
- * Return a scope value matching the supplied value.
- * @param value the scope name
- * @return the scope
- * @exception IllegalArgumentException if the name if not recognized
- */
- public static Scope parse( String value ) throws IllegalArgumentException
- {
- if( value.equalsIgnoreCase( "build" ) )
- {
- return BUILD;
- }
- else if( value.equalsIgnoreCase( "runtime" ) )
- {
- return RUNTIME;
- }
- else if( value.equalsIgnoreCase( "test" ) )
- {
- return TEST;
- }
- else
- {
- final String error =
- "Unrecognized scope argument [" + value + "]";
- throw new IllegalArgumentException( error );
- }
- }
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/SimpleFilterDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/SimpleFilterDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/SimpleFilterDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,13 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
+import dpml.util.ObjectUtils;
+
/**
* Simple value filter.
*
@@ -78,7 +80,7 @@
public int hashCode()
{
int hash = super.hashCode();
- hash ^= super.hashValue( m_value );
+ hash ^= ObjectUtils.hashValue( m_value );
return hash;
}
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/TypeDirective.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/TypeDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/info/TypeDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,61 +16,46 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.util.Properties;
-import net.dpml.lang.Version;
+import dpml.util.ObjectUtils;
-import net.dpml.library.Type;
+import dpml.library.Type;
-import org.w3c.dom.Element;
-
/**
* The ModuleDirective class describes a module data-structure.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class TypeDirective extends DataDirective implements Type
+public class TypeDirective extends AbstractDirective
{
+ private final String m_id;
+ private final String m_version;
+ private final String m_source;
+ private final boolean m_alias;
+ private final boolean m_test;
private final String m_name;
- private final Version m_version;
/**
* Creation of a new type directive.
- * @param name the name
+ * @param id the type id
*/
- public TypeDirective( String name )
+ public TypeDirective( String id )
{
- this( name, null );
+ this( id, null );
}
/**
* Creation of a new type directive.
- * @param name the name
- * @param version alias version
- */
- public TypeDirective( String name, Version version )
- {
- this( (Element) null, name, version );
- }
-
- /**
- * Creation of a new type directive.
- * @param element DOM element defining the type
* @param id the type id
* @param version alias version
*/
- public TypeDirective( Element element, String id, Version version )
+ public TypeDirective( String id, String version )
{
- super( element );
- if( null == id )
- {
- throw new NullPointerException( "id" );
- }
- m_name = id;
- m_version = version;
+ this( ProductionPolicy.DELIVERABLE, id, null, version, false, null,
null );
}
/**
@@ -79,15 +64,26 @@
* @param version alias version
* @param properties supplimentary properties
*/
- public TypeDirective( String id, Version version, Properties properties )
+ public TypeDirective(
+ ProductionPolicy policy, String id, String name, String version,
boolean alias, String source, Properties properties )
{
super( properties );
+
+ if( null == policy )
+ {
+ throw new NullPointerException( "policy" );
+ }
if( null == id )
{
throw new NullPointerException( "id" );
}
- m_name = id;
+
+ m_id = id;
+ m_name = name;
m_version = version;
+ m_source = source;
+ m_alias = alias;
+ m_test = ProductionPolicy.TEST.equals( policy );
}
/**
@@ -96,19 +92,55 @@
*/
public String getID()
{
- return m_name;
+ return m_id;
}
/**
* Return the alias version.
* @return the alias version
*/
- public Version getVersion()
+ public String getVersion()
{
return m_version;
}
/**
+ * Return the type source relative to the project basedir
+ * @return the source relative file path
+ */
+ public String getSource()
+ {
+ return m_source;
+ }
+
+ /**
+ * Return the test flag.
+ * @return the test flag
+ */
+ public boolean getTest()
+ {
+ return m_test;
+ }
+
+ /**
+ * Return the alias production flag.
+ * @return the alias flag
+ */
+ public boolean getAliasProduction()
+ {
+ return m_alias;
+ }
+
+ /**
+ * Return the overriding name.
+ * @return the name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
* Compare this object with another for equality.
* @param other the other object
* @return true if equal
@@ -118,13 +150,17 @@
if( super.equals( other ) && ( other instanceof TypeDirective ) )
{
TypeDirective object = (TypeDirective) other;
- if( !m_name.equals( object.m_name ) )
+ if( !m_id.equals( object.m_id ) )
{
return false;
}
+ if( !equals( m_version, object.m_version ) )
+ {
+ return false;
+ }
else
{
- return equals( m_version, object.m_version );
+ return equals( m_name, object.m_name );
}
}
else
@@ -139,9 +175,9 @@
*/
public int hashCode()
{
- int hash = super.hashCode();
+ int hash = getClass().hashCode();
+ hash ^= hashValue( m_id );
hash ^= hashValue( m_name );
- hash ^= hashValue( m_version );
return hash;
}
@@ -151,6 +187,14 @@
*/
public String toString()
{
- return "type:" + m_name;
+ if( null == m_name )
+ {
+ return "type:" + m_id;
+ }
+ else
+ {
+ return "type:" + m_id + ":" + m_name;
+ }
}
+
}
Modified:
trunk/main/depot/library/src/main/dpml/library/info/TypeUnknownException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/TypeUnknownException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/TypeUnknownException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* A TypeUnknownException is raised in response to a request for a type
Modified:
trunk/main/depot/library/src/main/dpml/library/info/ValidationException.java
===================================================================
---
trunk/main/depot/library/src/main/net/dpml/library/info/ValidationException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/main/dpml/library/info/ValidationException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* Internal exception throw to indicate an invalid structure.
Added: trunk/main/depot/library/src/main/dpml/library/package-info.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/package-info.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/package-info.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * <p>Project management library and supporting services.</p>
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+package dpml.library;
Deleted: trunk/main/depot/library/src/main/dpml/library/package.html
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/package.html
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/main/dpml/library/package.html 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,8 +0,0 @@
-
-<body>
-
-<p>
-Library interfaces.
-</p>
-
-</body>
Copied: trunk/main/depot/library/src/test/dpml (from rev 1789,
trunk/main/depot/library/src/test/net/dpml)
Modified: trunk/main/depot/library/src/test/dpml/library/XMLTestCase.java
===================================================================
--- trunk/main/depot/library/src/test/net/dpml/library/XMLTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/XMLTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,16 +16,18 @@
* limitations under the License.
*/
-package net.dpml.library;
+package dpml.library;
import java.io.File;
-import net.dpml.library.info.LibraryDirective;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.TypeDirective;
-import net.dpml.library.info.LibraryDecoder;
+import dpml.library.info.LibraryDirective;
+import dpml.library.info.ModuleDirective;
+import dpml.library.info.ResourceDirective;
+import dpml.library.info.TypeDirective;
+import dpml.library.info.LibraryDecoder;
+import dpml.util.StandardClassLoader;
+
import junit.framework.TestCase;
@@ -39,7 +41,7 @@
{
static
{
- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ System.setProperty( "java.protocol.handler.pkgs", "dpml.transit" );
}
private LibraryDecoder m_decoder;
@@ -199,6 +201,7 @@
private LibraryDirective getDirective( String path ) throws Exception
{
+ Thread.currentThread().setContextClassLoader(
XMLTestCase.class.getClassLoader() );
String base = System.getProperty( "project.test.dir" );
File test = new File( base );
File file = new File( test, path );
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/AbsoluteTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/AbsoluteTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/impl/AbsoluteTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,15 +16,15 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.util.DefaultLogger;
+
import java.io.File;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-
+import dpml.library.Module;
+import dpml.library.Resource;
import net.dpml.util.Logger;
-import net.dpml.util.DefaultLogger;
/**
* The ImportDirective class describes a the inclusion of a typed value.
@@ -36,7 +36,7 @@
{
static
{
- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ System.setProperty( "java.protocol.handler.pkgs", "dpml.transit" );
}
private DefaultLibrary m_library;
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/AbstractTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/AbstractTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/impl/AbstractTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,8 +16,10 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
+import dpml.util.DefaultLogger;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -26,11 +28,10 @@
import junit.framework.TestCase;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Resource;
+import dpml.library.Scope;
import net.dpml.util.Logger;
-import net.dpml.transit.monitor.LoggingAdapter;
/**
* Abstract library testcase.
@@ -40,9 +41,14 @@
*/
abstract class AbstractTestCase extends TestCase
{
- private Logger m_logger = new LoggingAdapter( "test" );
+ private Logger m_logger = new DefaultLogger( "test" );
private DefaultLibrary m_library;
+ static
+ {
+ Thread.currentThread().setContextClassLoader(
AbstractTestCase.class.getClassLoader() );
+ }
+
/**
* Return the library established by setup.
* @return the library
@@ -219,6 +225,6 @@
"java.util.logging.config.class",
System.getProperty(
"java.util.logging.config.class",
- "net.dpml.util.ConfigurationHandler" ) );
+ "dpml.util.ConfigurationHandler" ) );
}
}
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/AnonymousTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/AnonymousTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/AnonymousTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Scope;
/**
* Test DefaultLibrary implementation.
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/DefaultDictionaryTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/DefaultDictionaryTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/DefaultDictionaryTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
-import net.dpml.library.Resource;
+import dpml.library.Resource;
/**
* Testing the DefaultDictionary implementation.
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/DefaultLibraryTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/DefaultLibraryTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/DefaultLibraryTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,12 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
-import net.dpml.lang.Version;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Type;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.Type;
-
import org.w3c.dom.Element;
/**
@@ -125,50 +123,4 @@
assertEquals( "spec-to-path", spec, path );
}
- /**
- * Mock type class.
- */
- private static class MockType implements Type
- {
- private String m_name;
- private Version m_version;
-
- /**
- * Creation of a new mock type instance.
- * @param name the type name
- * @param alias the alias production flag
- */
- public MockType( String name, Version version )
- {
- m_name = name;
- m_version = version;
- }
-
- /**
- * Return the type name.
- * @return the name
- */
- public String getID()
- {
- return m_name;
- }
-
- /**
- * Return the alias version.
- * @return the version
- */
- public Version getVersion()
- {
- return m_version;
- }
-
- /**
- * Return the type datastructure.
- * @return the data
- */
- public Element getElement()
- {
- return null;
- }
- }
}
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/DefaultModuleTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/DefaultModuleTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/DefaultModuleTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Scope;
/**
* Testing the DefaultModule implementation.
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/DefaultResourceTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/DefaultResourceTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,16 +16,16 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
import java.io.File;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
-import net.dpml.library.Type;
+import dpml.library.Resource;
+import dpml.library.Scope;
+import dpml.library.Type;
import net.dpml.transit.Artifact;
-import net.dpml.lang.Category;
+import dpml.util.Category;
/**
* Testing the DefaultResource implementation.
@@ -54,7 +54,7 @@
{
Resource resource = getLibrary().getResource( "junit/junit" );
String version = resource.getVersion();
- assertEquals( "version", "@JUNIT_VERSION@", version );
+ assertEquals( "version", "3.8.1", version );
}
/**
@@ -150,7 +150,7 @@
for( int i=0; i<types.length; i++ )
{
Type type = types[i];
- Artifact artifact = resource.getArtifact( type.getID() );
+ Artifact artifact = type.getArtifact();
String urn =
"artifact:"
+ type.getID()
@@ -413,7 +413,7 @@
}
else
{
- System.out.println( "# " + path + ", " +
category.getName().toUpperCase() );
+ System.out.println( "# " + path + ", " +
category.name().toUpperCase() );
for( int i=0; i<chain.length; i++ )
{
System.out.println( "# (" + ( i+1 ) + ") " + chain[i] );
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/DuplicatesTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/DuplicatesTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/DuplicatesTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,13 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
import java.io.File;
-import net.dpml.library.info.LibraryDecoder;
+import dpml.library.info.LibraryDecoder;
-import net.dpml.transit.monitor.LoggingAdapter;
-
+import dpml.util.DefaultLogger;
import net.dpml.util.Logger;
import junit.framework.TestCase;
@@ -62,8 +61,7 @@
String base = System.getProperty( "project.test.dir" );
File test = new File( base );
File file = new File( test, "samples/duplicates.xml" );
- Logger logger = new LoggingAdapter( "test" );
+ Logger logger = new DefaultLogger( "test" );
DefaultLibrary library = new DefaultLibrary( logger, file );
}
-
}
Deleted:
trunk/main/depot/library/src/test/dpml/library/impl/ExportTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/ExportTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/impl/ExportTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,166 +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.library.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.Arrays;
-
-import net.dpml.library.Module;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.ResourceDirective;
-import net.dpml.library.info.TypeDirective;
-import net.dpml.library.info.LibraryDecoder;
-import net.dpml.library.info.LibraryEncoder;
-
-
-/**
- * Test DefaultLibrary implementation.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ExportTestCase extends AbstractTestCase
-{
- /**
- * Test library properties.
- * @exception Exception if an error occurs during test execution
- */
- public void testExport() throws Exception
- {
- String spec = "dpml";
- Module module = getLibrary().getModule( spec );
- ModuleDirective directive = module.export();
- String testPath = System.getProperty( "project.test.dir" );
- File test = new File( testPath );
- File export = new File( test, "export.xml" );
- LibraryDecoder decoder = new LibraryDecoder();
- LibraryEncoder encoder = new LibraryEncoder();
- encoder.export( directive, new FileOutputStream( export ) );
- ResourceDirective result = decoder.buildResource( export.toURI() );
- compareResourceDirective( directive, result );
- assertEquals( "export", directive, result );
- }
-
- private void compareResourceDirective( ResourceDirective a,
ResourceDirective b )
- {
- if( equals( a, b ) )
- {
- return;
- }
-
- System.out.println( "exported resource: " + a.getName() + " is not
equals to constructed resource." );
-
- if( !a.getName().equals( b.getName() ) )
- {
- System.out.println( "# different names" );
- }
- if( !a.getVersion().equals( b.getVersion() ) )
- {
- System.out.println( "# different versions" );
- }
- if( !equals( a.getBasedir(), b.getBasedir() ) )
- {
- System.out.println( "# different basedirs" );
- }
- if( !Arrays.equals( a.getTypeDirectives(), b.getTypeDirectives() ) )
- {
- System.out.println( "# different types" );
- compareTypes( a.getTypeDirectives(), b.getTypeDirectives() );
- }
- if( !Arrays.equals( a.getDependencyDirectives(),
b.getDependencyDirectives() ) )
- {
- System.out.println( "# different dependencies" );
- }
- if( !a.getClassifier().equals( b.getClassifier() ) )
- {
- System.out.println( "# different classifiers" );
- }
- if( a instanceof ModuleDirective )
- {
- compareModuleDirective( (ModuleDirective) a, (ModuleDirective) b
);
- }
- }
-
- private void compareModuleDirective( ModuleDirective a, ModuleDirective
b )
- {
- ResourceDirective[] ar = a.getResourceDirectives();
- ResourceDirective[] br = b.getResourceDirectives();
- if( ar.length != br.length )
- {
- System.out.println( "# different subsidiary resource count" );
- }
- else
- {
- for( int i=0; i<ar.length; i++ )
- {
- ResourceDirective r = ar[i];
- ResourceDirective rx = br[i];
- if( !r.equals( rx ) )
- {
- compareResourceDirective( r, rx );
- }
- }
- }
- }
-
- private boolean equals( Object a, Object b )
- {
- if( null == a )
- {
- return ( null == b );
- }
- else
- {
- return a.equals( b );
- }
- }
-
- private void compareTypes( TypeDirective[] a, TypeDirective[] b )
- {
- if( a.length != b.length )
- {
- System.out.println( "# different type count" );
- }
- else
- {
- for( int i=0; i<a.length; i++ )
- {
- compareType( a[i], b[i] );
- }
- }
- }
-
- private void compareType( TypeDirective a, TypeDirective b )
- {
- if( !a.equals( b ) )
- {
- if( !a.getID().equals( b.getID() ) )
- {
- System.out.println( "# different type ids: " + a.getID() +
", " + b.getID() );
- }
- else
- {
- System.out.println( "# different types for id: " + a.getID()
);
- System.out.println( "# A: " + a );
- System.out.println( "# B: " + b );
- }
- }
- }
-}
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/FiltersTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/FiltersTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/impl/FiltersTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,18 +16,18 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
import java.io.File;
-import net.dpml.library.Filter;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
+import dpml.library.Filter;
+import dpml.library.Module;
+import dpml.library.Resource;
-import net.dpml.library.info.LibraryDecoder;
+import dpml.library.info.LibraryDecoder;
import net.dpml.util.Logger;
-import net.dpml.util.DefaultLogger;
+import dpml.util.DefaultLogger;
import junit.framework.TestCase;
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/InfoTestCase.java
===================================================================
--- trunk/main/depot/library/src/test/net/dpml/library/impl/InfoTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/impl/InfoTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,15 +16,15 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
import java.io.File;
-import net.dpml.library.Info;
-import net.dpml.library.Module;
+import dpml.library.Info;
+import dpml.library.Module;
import net.dpml.util.Logger;
-import net.dpml.util.DefaultLogger;
+import dpml.util.DefaultLogger;
import junit.framework.TestCase;
Modified:
trunk/main/depot/library/src/test/dpml/library/impl/PropertiesTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/impl/PropertiesTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/impl/PropertiesTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,12 @@
* limitations under the License.
*/
-package net.dpml.library.impl;
+package dpml.library.impl;
import java.io.File;
import net.dpml.util.Logger;
-import net.dpml.util.DefaultLogger;
+import dpml.util.DefaultLogger;
/**
* The ImportDirective class describes a the inclusion of a typed value.
Modified:
trunk/main/depot/library/src/test/dpml/library/info/AbstractTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/AbstractTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/info/AbstractTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Modified:
trunk/main/depot/library/src/test/dpml/library/info/DependencyDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/DependencyDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/DependencyDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,8 +16,11 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
+import dpml.library.Scope;
+
+
/**
* The ModuleDirective class describes a module data-structure.
*
Modified:
trunk/main/depot/library/src/test/dpml/library/info/ImportDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ImportDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/ImportDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* The ImportDirective class describes a the inclusion of a typed value.
Modified:
trunk/main/depot/library/src/test/dpml/library/info/IncludeDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/IncludeDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/IncludeDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.lang.Category;
+import dpml.util.Category;
/**
* The IncludeDirective class describes a the inclusion of a typed value.
Modified:
trunk/main/depot/library/src/test/dpml/library/info/InfoDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/InfoDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/InfoDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* The ImportDirective class describes a the inclusion of a typed value.
Modified:
trunk/main/depot/library/src/test/dpml/library/info/LibraryDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/LibraryDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/LibraryDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* The ModuleDirective class describes a module data-structure.
Modified:
trunk/main/depot/library/src/test/dpml/library/info/ModuleDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ModuleDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/ModuleDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.library.info.ResourceDirective.Classifier;
+import dpml.library.Classifier;
/**
* The ModuleDirective class describes a module data-structure.
@@ -55,7 +55,7 @@
private final DependencyDirective[] m_dependencies =
DependencyDirectiveTestCase.DEPENDENCIES;
private final ResourceDirective[] m_resources =
ResourceDirectiveTestCase.RESOURCES;
private final FilterDirective[] m_filters = new FilterDirective[0];
- private final DataDirective[] m_data = TypeDirectiveTestCase.TYPES;
+ private final TypeDirective[] m_data = TypeDirectiveTestCase.TYPES;
private ModuleDirective m_module;
Modified:
trunk/main/depot/library/src/test/dpml/library/info/ResourceDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ResourceDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/ResourceDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.library.info.ResourceDirective.Classifier;
+import dpml.library.Classifier;
/**
* The ModuleDirective class describes a module data-structure.
@@ -33,7 +33,7 @@
static final DependencyDirective[] DEPENDENCIES =
DependencyDirectiveTestCase.DEPENDENCIES;
static final TypeDirective[] TYPES = TypeDirectiveTestCase.TYPES;
static final ResourceDirective[] RESOURCES = new ResourceDirective[3];
- static final DataDirective[] DATA = new DataDirective[0];
+ static final TypeDirective[] DATA = new TypeDirective[0];
static final FilterDirective[] FILTERS = new FilterDirective[0];
static
Modified:
trunk/main/depot/library/src/test/dpml/library/info/ScopeTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/ScopeTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/library/src/test/dpml/library/info/ScopeTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
/**
* Test the scope enumeration.
@@ -33,7 +33,7 @@
*/
public void testBuildScope()
{
- Scope scope = Scope.parse( "build" );
+ Scope scope = Scope.valueOf( "BUILD" );
assertEquals( "scope", scope, Scope.BUILD );
}
@@ -42,7 +42,7 @@
*/
public void testRuntimeScope()
{
- Scope scope = Scope.parse( "runtime" );
+ Scope scope = Scope.valueOf( "RUNTIME" );
assertEquals( "scope", scope, Scope.RUNTIME );
}
@@ -51,7 +51,7 @@
*/
public void testTestScope()
{
- Scope scope = Scope.parse( "test" );
+ Scope scope = Scope.valueOf( "TEST" );
assertEquals( "scope", scope, Scope.TEST );
}
@@ -62,7 +62,7 @@
{
try
{
- Scope scope = Scope.parse( "abc" );
+ Scope scope = Scope.valueOf( "abc" );
fail( "Did not throw IllegalArgumentException" );
}
catch( IllegalArgumentException e )
@@ -79,15 +79,4 @@
Scope[] scopes = Scope.values();
assertEquals( "scope count", 3, scopes.length );
}
-
- /**
- * Test directive serialization.
- * @exception Exception if an error occurs
- */
- public void testSerialization() throws Exception
- {
- Scope scope = Scope.parse( "test" );
- doSerializationTest( scope );
- }
-
}
Modified:
trunk/main/depot/library/src/test/dpml/library/info/TypeDirectiveTestCase.java
===================================================================
---
trunk/main/depot/library/src/test/net/dpml/library/info/TypeDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/library/src/test/dpml/library/info/TypeDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,9 @@
* limitations under the License.
*/
-package net.dpml.library.info;
+package dpml.library.info;
-import net.dpml.lang.Version;
-
/**
* The ModuleDirective class describes a module data-structure.
*
@@ -32,9 +30,10 @@
static final TypeDirective[] TYPES = new TypeDirective[3];
static
{
- TYPES[0] = new TypeDirective( "jar", null, PROPERTIES );
- TYPES[1] = new TypeDirective( "plugin", Version.NULL_VERSION,
PROPERTIES );
- TYPES[2] = new TypeDirective( "widget", Version.parse( "1.2" ),
PROPERTIES );
+ TYPES[0] = new TypeDirective( "jar" );
+ TYPES[1] = new TypeDirective( "plugin", "0.0,0" );
+ TYPES[2] = new TypeDirective(
+ ProductionPolicy.DELIVERABLE, "widget", null, "1.2", false, null,
PROPERTIES );
}
/**
@@ -45,7 +44,7 @@
{
try
{
- TypeDirective type = new TypeDirective( null,
Version.NULL_VERSION, PROPERTIES );
+ TypeDirective type = new TypeDirective( null );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -57,9 +56,9 @@
/**
* Test the type directive name accessor.
*/
- public void testTypeName()
+ public void testTypeID()
{
- TypeDirective type = new TypeDirective( "abc", Version.parse( "1.2"
), PROPERTIES );
+ TypeDirective type = new TypeDirective( "abc" );
assertEquals( "type", "abc", type.getID() );
}
@@ -68,7 +67,7 @@
*/
public void testNullTypeVersion()
{
- TypeDirective type = new TypeDirective( "abc", null, PROPERTIES );
+ TypeDirective type = new TypeDirective( "abc", null );
assertEquals( "null-version", null, type.getVersion() );
}
@@ -77,28 +76,18 @@
*/
public void testExplicitTypeVersion()
{
- Version version = Version.parse( "1.2" );
- TypeDirective type = new TypeDirective( "abc", version, PROPERTIES );
+ String version = "1.2";
+ TypeDirective type = new TypeDirective( "abc", version );
assertEquals( "version", version, type.getVersion() );
}
/**
- * Test the type directive alias accessor.
- */
- public void testLogicalNullVersion()
- {
- Version version = Version.NULL_VERSION;
- TypeDirective type = new TypeDirective( "abc", version, PROPERTIES );
- assertEquals( "version", version, type.getVersion() );
- }
-
- /**
* Test the type directive serialization.
* @exception Exception if an error occurs
*/
public void testSerialization() throws Exception
{
- TypeDirective type = new TypeDirective( "abc", Version.parse( "1.2"
), PROPERTIES );
+ TypeDirective type = new TypeDirective( "abc", "1.2" );
doSerializationTest( type );
}
}
Modified: trunk/main/depot/module.xml
===================================================================
--- trunk/main/depot/module.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/module.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,195 +1,51 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<module name="depot"
- xmlns="link:xsd:dpml/lang/dpml-module#1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:part="link:xsd:dpml/lang/dpml-part#1.0">
+<module name="depot" xmlns="dpml:library">
- <properties>
- <property name="project.minor.version" value="2"/>
- <property name="project.micro.version" value="0"/>
- </properties>
-
- <project name="dpml-library" basedir="library">
- <info title="DPML Project Management Library">
- <description>Module, project and resource management
system.</description>
- </info>
- <types>
- <type id="jar"/>
- </types>
- <dependencies>
- <runtime>
- <include ref="dpml/transit/dpml-transit-main"/>
- </runtime>
- <test>
- <include ref="ant/ant-junit"/>
- </test>
- </dependencies>
- <filters>
- <feature token="MODULE-XSD-URI" ref="dpml/lang/dpml-module" id="uri"
type="xsd" alias="true"/>
- <feature token="PART-XSD-URI" ref="dpml/lang/dpml-part" id="uri"
type="xsd" alias="true"/>
- <feature token="JUNIT_VERSION" ref="junit/junit" id="version"/>
- <feature token="PROJECT_VERSION" id="version"/>
- <feature token="ANT-BUILDER-URI" ref="dpml/depot/dpml-tools-builder"
id="uri" type="part" alias="true"/>
- </filters>
- </project>
+ <project file="library/project.xml"/>
+ <project file="build/project.xml"/>
+ <project file="tools/project.xml"/>
+ <project file="plugins/convert/project.xml"/>
+ <project file="plugins/checkstyle/project.xml"/>
- <project name="dpml-library-build" basedir="build">
- <info title="DPML Depot Build Tool">
- <description>Multi-project build automation tool.</description>
+ <!--
+ <project name="dpml-depot-javac" basedir="plugins/javac">
+ <info title="DPML Javac Compiler">
+ <description>Javac Compiler plugin.</description>
</info>
<types>
<type id="jar"/>
- <part:plugin alias="true"
class="net.dpml.library.console.BuilderPlugin"/>
+ <type id="part" alias="true" source="target/plugin.xml"/>
</types>
<dependencies>
- <build>
- <include key="dpml-tools-builder"/>
- </build>
<runtime>
- <include ref="dpml/depot/dpml-library"/>
- <include ref="dpml/util/dpml-util-cli"/>
- <include ref="dpml/transit/dpml-transit-main"/>
+ <include ref="dpml/depot/dpml-depot-builder"/>
+ <include uri="artifact:jar:openjdk/javac/javac"/>
+ <include ref="ant/ant-launcher"/>
</runtime>
- <test>
- <include ref="ant/ant-junit"/>
- </test>
</dependencies>
- <filters>
- <feature token="ANT-BUILDER-URI" ref="dpml/depot/dpml-tools-builder"
id="uri" type="part" alias="true"/>
- </filters>
</project>
+ -->
- <project name="dpml-depot-console" basedir="core">
- <info title="DPML Console">
- <description>Internal subsystem application handler.</description>
+ <!--
+ <project name="dpml-depot-adapter" basedir="adapter">
+ <info title="DPML Javac Compiler">
+ <description>Javac Compiler plugin.</description>
</info>
<properties>
- <property name="depot.short.filename" value="${project.name}.jar"/>
- <property name="transit.short.filename" value="dpml-transit-main.jar"/>
- <property name="project.jar.main.class" value="net.dpml.depot.Main"/>
+ <property name="project.javac.source" value="1.5"/>
+ <property name="project.javac.target" value="1.5"/>
</properties>
<types>
<type id="jar"/>
+ <type id="part" alias="true" source="target/plugin.xml"/>
</types>
<dependencies>
<runtime>
- <include ref="dpml/transit/dpml-transit-main"/>
+ <include ref="dpml/depot/dpml-depot-library"/>
+ <include uri="artifact:jar:openjdk/javac/javac"/>
</runtime>
- <test>
- <include ref="ant/ant-junit"/>
- </test>
</dependencies>
- <filters>
- <filter token="DEPOT-PATH" value="${depot.short.filename}"/>
- <filter token="DEPOT-MAIN-CLASS" value="${project.jar.main.class}"/>
- <filter token="TRANSIT-PATH" value="${transit.short.filename}"/>
- <filter token="DEPOT-CLASSLOADER-CLASS"
value="net.dpml.lang.SystemClassLoader"/>
- <feature token="BUILD-ID" id="version"/>
- <feature token="DEPOT-CONSOLE-URI" id="uri" type="jar"/>
- <feature token="TRANSIT-CORE-URI" id="uri" type="jar"
ref="dpml/transit/dpml-transit-main" />
- <feature token="TRANSIT-CONSOLE-URI" id="uri" type="part" alias="true"
ref="dpml/transit/dpml-transit-console" />
- <feature token="DEPOT-BUILDER-URI" id="uri" type="part" alias="true"
ref="dpml/depot/dpml-library-build" />
- <feature token="DEPOT-EXEC-URI" id="uri" type="part" alias="true"
ref="dpml/station/dpml-station-exec" />
- <feature token="DEPOT-STATION-URI" id="uri" type="part" alias="true"
ref="dpml/station/dpml-station-console" />
- <feature token="DEPOT-STATION-SERVER-URI" id="uri" type="part"
alias="true" ref="dpml/station/dpml-station-server" />
- </filters>
</project>
-
- <project name="dpml-tools-builder" basedir="tools">
- <info title="DPML Depot Toolkit">
- <description>Antlib supporting Depot-based build
automation.</description>
- </info>
- <types>
- <type id="jar"/>
- <part:plugin alias="true" class="net.dpml.tools.impl.StandardBuilder"/>
- </types>
- <dependencies>
- <runtime>
- <include ref="dpml/depot/dpml-library"/>
- <include ref="dpml/transit/dpml-transit-tools"/>
- <include ref="ant/ant-junit" tag="system"/>
- <include ref="ant/ant" tag="system"/>
- <include ref="ant/ant-xslp" tag="system"/>
- <include ref="ant/ant-trax" tag="system"/>
- </runtime>
- </dependencies>
- <filters>
- <feature token="PART-XSD-URI" id="uri" type="xsd" alias="true"
ref="dpml/lang/dpml-part" />
- <feature token="PROJECT-URI" id="uri" type="part"/>
- <feature token="PROJECT-LINK-URI" id="uri" type="part" alias="true"/>
- <feature token="PROJECT-NAME" id="name"/>
- <feature token="PROJECT-GROUP" id="group"/>
- <feature token="PROJECT-VERSION" id="version"/>
- <feature token="ANT-VERSION" id="version" ref="ant/ant"/>
- <feature token="JUNIT-VERSION" id="version" ref="junit/junit"/>
- <filter token="PLUGIN-CLASS"
value="net.dpml.tools.impl.StandardBuilder"/>
- <feature token="DEPOT-CHECKSTYLE-PLUGIN-URI" id="uri" type="part"
ref="dpml/depot/dpml-depot-checkstyle" />
- <feature token="DDEPOT-CHECKSTYLE-PLUGIN-LINK-URI" id="uri"
type="part" alias="true"
- ref="dpml/depot/dpml-depot-checkstyle" />
- <feature token="TRANSIT-CORE-VERSION" id="version"
ref="dpml/transit/dpml-transit-main"/>
- <feature token="TRANSIT-TOOLS-VERSION" id="version"
ref="dpml/transit/dpml-transit-tools"/>
- <feature token="LIBRARY-VERSION" id="version"
ref="dpml/depot/dpml-library"/>
- </filters>
- </project>
-
- <project name="dpml-depot-checkstyle" basedir="plugins/checkstyle">
- <info title="DPML Checkstyle Plugin">
- <description>Checkstyle plugin for Depot.</description>
- </info>
- <types>
- <type id="jar"/>
- <part:resource alias="true" urn="dpml:checkstyle"
path="net/dpml/tools/checkstyle/antlib.xml"/>
- </types>
- <dependencies>
- <runtime>
- <include ref="dpml/depot/dpml-tools-builder"/>
- <include uri="artifact:jar:checkstyle/checkstyle#4.1">
- <property name="project.api.host" value="http://api.dpml.net"/>
- <property name="project.api.root"
value="${project.api.host}/${project.group}/${project.version}"/>
- </include>
- <include uri="artifact:jar:commons-logging/commons-logging#1.0.4" />
- <include
uri="artifact:jar:commons-collections/commons-collections#3.1" />
- <include
uri="artifact:jar:commons-beanutils/commons-beanutils-core#1.7.0" />
- <include uri="artifact:jar:bcel/bcel#5.1" />
- <include uri="artifact:jar:antlr/antlr#2.7.2" />
- </runtime>
- </dependencies>
- </project>
-
- <project name="dpml-depot-convert" basedir="plugins/convert">
- <info title="DPML Java to HTML Converter">
- <description>Checkstyle plugin for Depot.</description>
- </info>
- <types>
- <type id="jar"/>
- <part:resource alias="true" urn="dpml:convert"
path="net/dpml/tools/convert/antlib.xml"/>
- </types>
- <dependencies>
- <runtime>
- <include uri="artifact:jar:java2html/java2html#4.2"/>
- <include ref="ant/ant-launcher"/>
- </runtime>
- </dependencies>
- </project>
+ -->
- <project name="dpml-depot-test" basedir="test">
- <info title="DPML Java to HTML Converter">
- <description>Depot Tests.</description>
- </info>
- <properties>
- <property name="project.major.version" value="0"/>
- <property name="project.minor.version" value="0"/>
- <property name="project.micro.version" value="0"/>
- </properties>
- <dependencies>
- <build>
- <include ref="dpml/depot/dpml-tools-builder"/>
- <include ref="ant/ant-junit"/>
- </build>
- <test>
- <include ref="ant/ant-junit"/>
- </test>
- </dependencies>
- </project>
-
</module>
Property changes on: trunk/main/depot/plugins
___________________________________________________________________
Name: svn:ignore
- validator
+ validator
javac
Modified: trunk/main/depot/plugins/checkstyle/build.xml
===================================================================
--- trunk/main/depot/plugins/checkstyle/build.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/plugins/checkstyle/build.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project name="dpml-depot-checkstyle" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
+ xmlns:x="antlib:dpml.tools">
- <transit:import uri="local:template:dpml/tools/standard"/>
+ <x:import uri="local:template:dpml/tools/standard"/>
<target name="install" depends="standard.install">
<property name="prefs" location="${dpml.prefs}/dpml/tools"/>
Added: trunk/main/depot/plugins/checkstyle/etc/resource.xml
===================================================================
--- trunk/main/depot/plugins/checkstyle/etc/resource.xml 2007-02-08
23:30:11 UTC (rev 1817)
+++ trunk/main/depot/plugins/checkstyle/etc/resource.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<resource xmlns="dpml:antlib" urn="dpml:checkstyle"
path="dpml/tools/checkstyle/antlib.xml"/>
Added: trunk/main/depot/plugins/checkstyle/project.xml
===================================================================
--- trunk/main/depot/plugins/checkstyle/project.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/plugins/checkstyle/project.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project xmlns="dpml:library" name="dpml-depot-checkstyle">
+
+ <info title="DPML Checkstyle Plugin">
+ <description>Checkstyle plugin for Depot.</description>
+ </info>
+
+ <types>
+ <type id="jar"/>
+ <type id="part" alias="true" source="target/resource.xml"/>
+ </types>
+
+ <dependencies>
+ <runtime>
+ <include ref="dpml/depot/dpml-depot-builder"/>
+ <include uri="artifact:jar:checkstyle/checkstyle#4.1">
+ <property name="project.api.host" value="http://api.dpml.net"/>
+ <property name="project.api.root"
value="${project.api.host}/${project.group}/${project.version}"/>
+ </include>
+ <include uri="artifact:jar:commons-logging/commons-logging#1.0.4" />
+ <include
uri="artifact:jar:commons-collections/commons-collections#3.1" />
+ <include
uri="artifact:jar:commons-beanutils/commons-beanutils-core#1.7.0" />
+ <include uri="artifact:jar:bcel/bcel#5.1" />
+ <include uri="artifact:jar:antlr/antlr#2.7.2" />
+ </runtime>
+ </dependencies>
+
+</project>
Copied: trunk/main/depot/plugins/checkstyle/src/main/dpml (from rev 1789,
trunk/main/depot/plugins/checkstyle/src/main/net/dpml)
Modified:
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/CheckstyleTask.java
===================================================================
---
trunk/main/depot/plugins/checkstyle/src/main/net/dpml/tools/checkstyle/CheckstyleTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/CheckstyleTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.checkstyle;
+package dpml.tools.checkstyle;
import java.io.File;
import java.net.URI;
@@ -24,10 +24,10 @@
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
-import net.dpml.library.Resource;
-import net.dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Module;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -123,12 +123,22 @@
*/
public void execute()
{
- Resource resource = m_context.getResource();
- if( m_implicit )
+ try
{
- addTargetToFileset( resource );
+ Resource resource = m_context.getResource();
+ if( m_implicit )
+ {
+ addTargetToFileset( resource );
+ }
+ super.execute();
}
- super.execute();
+ catch( Throwable e )
+ {
+ final String error =
+ "Checkstyle execution failure.";
+ e.printStackTrace();
+ //throw new BuildException( error, e, getLocation() );
+ }
}
private void addTargetToFileset( Resource resource )
Modified:
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/antlib.xml
===================================================================
---
trunk/main/depot/plugins/checkstyle/src/main/net/dpml/tools/checkstyle/antlib.xml
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/plugins/checkstyle/src/main/dpml/tools/checkstyle/antlib.xml
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<antlib>
- <taskdef name="checkstyle"
classname="net.dpml.tools.checkstyle.CheckstyleTask"/>
+ <taskdef name="checkstyle"
classname="dpml.tools.checkstyle.CheckstyleTask"/>
</antlib>
Added: trunk/main/depot/plugins/convert/build.xml
===================================================================
--- trunk/main/depot/plugins/convert/build.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/plugins/convert/build.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-depot-checkstyle" default="install" basedir="."
+ xmlns:x="antlib:dpml.tools">
+
+ <x:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="javadoc"/>
+
+</project>
Added: trunk/main/depot/plugins/convert/etc/resource.xml
===================================================================
--- trunk/main/depot/plugins/convert/etc/resource.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/plugins/convert/etc/resource.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<resource xmlns="dpml:antlib" urn="dpml:convert"
path="dpml/tools/convert/antlib.xml"/>
Added: trunk/main/depot/plugins/convert/project.xml
===================================================================
--- trunk/main/depot/plugins/convert/project.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/plugins/convert/project.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project xmlns="dpml:library" name="dpml-depot-convert">
+
+ <info title="DPML Java to HTML Converter">
+ <description>Converts java source files to HTML pages.</description>
+ </info>
+
+ <types>
+ <type id="jar"/>
+ <type id="part" alias="true" source="target/resource.xml"/>
+ </types>
+
+ <dependencies>
+ <runtime>
+ <include uri="artifact:jar:java2html/java2html#4.2"/>
+ <include ref="org/apache/ant/ant"/>
+ </runtime>
+ </dependencies>
+
+</project>
Copied: trunk/main/depot/plugins/convert/src/main/dpml (from rev 1789,
trunk/main/depot/plugins/convert/src/main/net/dpml)
Added: trunk/main/depot/tools/CHANGES.TXT
===================================================================
--- trunk/main/depot/tools/CHANGES.TXT 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/tools/CHANGES.TXT 2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,25 @@
+
+Changes in 2.0 (pre)
+====================
+
+net.dpml.tools.impl
+-------------------
+
+1. removed presumption of source and target versions
+ int the Javac task (was linked to 1.4, now requires
+ developer to declare constraints as build properties
+ if required - i.e. we now default to the javac tool
+ policy)
+2. general code implovement via generics
+3. rationalization of the <type> production element
+ - removal of custom in-line type declaration
+ in favour of:
+ <type id="part" source="plugin.xml"/>
+ - support for test verus production types, where
+ test-based resources go to the target/test
+ directory and are not included as formal
+ project deliverables - e.g.:
+ <type id="jar" test="true"/>
+
+
+
Modified: trunk/main/depot/tools/bootstrap.properties
===================================================================
--- trunk/main/depot/tools/bootstrap.properties 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/tools/bootstrap.properties 2007-02-08 23:31:25 UTC (rev
1818)
@@ -1,7 +1,3 @@
project.group = dpml/depot
-project.name = dpml-tools-builder
-tools.ant.version = 1.6.5
-junit.version = 3.8.1
-junit.filename = junit-${junit.version}.jar
-junit.uri = artifact:jar:junit/junit#${junit.version}
+project.name = dpml-depot-builder
Modified: trunk/main/depot/tools/bootstrap.xml
===================================================================
--- trunk/main/depot/tools/bootstrap.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/tools/bootstrap.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="dpml-tools-builder" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit">
+<project name="dpml-depot-builder" default="install" basedir=".">
<property file="${basedir}/bootstrap.properties"/>
<property file="../../bootstrap.properties"/>
- <transit:import
file="${dpml.prefs}/dpml/transit/templates/bootstrap.template"/>
-
+ <property name="bootstrap.template"
location="${basedir}/../../bootstrap.xml"/>
+ <import file="${bootstrap.template}"/>
+
<target name="init" depends="bootstrap.init">
- <filter token="PART-XSD-URI" value="link:xsd:dpml/lang/dpml-part#1.0"/>
+ <filter token="PART-XSD-URI" value="dpml:part"/>
<filter token="PROJECT-URI"
value="artifact:part:${project.group}/${project.name}#${project.version}" />
<filter token="PROJECT-LINK-URI"
value="link:part:${project.group}/${project.name}" />
<filter token="PROJECT-NAME" value="${project.name}" />
<filter token="PROJECT-GROUP" value="${project.group}"/>
<filter token="PROJECT-VERSION" value="${project.version}"/>
- <filter token="ANT-VERSION" value="${tools.ant.version}"/>
+ <filter token="ANT-VERSION" value="${transit-ant.version}"/>
<filter token="JUNIT-VERSION" value="${junit.version}"/>
- <filter token="PLUGIN-CLASS"
value="net.dpml.tools.impl.StandardBuilder"/>
+ <filter token="PLUGIN-CLASS" value="dpml.tools.impl.StandardBuilder"/>
<filter token="DEPOT-CHECKSTYLE-PLUGIN-URI"
-
value="artifact:part:${project.group}/dpml-depot-checkstyle#SNAPSHOT"/>
+
value="artifact:part:${project.group}/dpml-depot-checkstyle#BOOTSTRAP"/>
<filter token="DEPOT-CHECKSTYLE-PLUGIN-LINK-URI"
value="link:part:${project.group}/dpml-depot-checkstyle"/>
<filter token="TRANSIT-CORE-VERSION" value="BOOTSTRAP"/>
@@ -27,21 +27,16 @@
</target>
<target name="setup-path" depends="bootstrap.setup-path">
- <transit:get property="junit.path" uri="${junit.uri}"/>
- <transit:get property="library.path"
- uri="artifact:jar:dpml/depot/dpml-library#BOOTSTRAP"/>
- <transit:get property="transit.path"
- uri="artifact:jar:dpml/transit/dpml-transit-main#BOOTSTRAP"/>
<path id="project.main.path">
- <pathelement
-
location="${dpml.local.cache}/dpml/transit/jars/dpml-transit-main-BOOTSTRAP.jar"/>
- <pathelement location="${library.path}"/>
+ <pathelement
location="${dpml.local.cache}/dpml/transit/jars/dpml-transit-main-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/lang/jars/dpml-lang-part-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/depot/jars/dpml-depot-library-BOOTSTRAP.jar"/>
+ <pathelement
location="${dpml.local.cache}/dpml/depot/jars/dpml-depot-build-BOOTSTRAP.jar"/>
<pathelement location="${target.classes.dir}"/>
</path>
<path id="project.test.path">
- <pathelement location="${junit.path}"/>
- <pathelement location="${library.path}"/>
- <pathelement location="${transit.path}"/>
+ <path refid="project.main.path"/>
+ <pathelement
location="${dpml.local.cache}/junit/jars/${junit.filename}"/>
<pathelement
location="${target.deliverables.jars.dir}/${project.filename}"/>
</path>
</target>
Modified: trunk/main/depot/tools/build.xml
===================================================================
--- trunk/main/depot/tools/build.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/tools/build.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="dpml-tools-builder" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
+<project name="dpml-depot-builder" default="install" basedir="."
+ xmlns:x="antlib:dpml.tools">
- <transit:import uri="local:template:dpml/tools/standard"/>
+ <x:import uri="local:template:dpml/tools/standard"/>
<target name="install" depends="standard.install">
<property name="tools.prefs" location="${dpml.prefs}/dpml/tools"/>
Modified: trunk/main/depot/tools/etc/bootstrap/builder.xml
===================================================================
--- trunk/main/depot/tools/etc/bootstrap/builder.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/tools/etc/bootstrap/builder.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<part xmlns="@PART-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<part xmlns="dpml:part">
<info title="Depot Builder">
<description>
@@ -7,22 +7,21 @@
</description>
</info>
- <strategy xsi:type="plugin" class="@PLUGIN-CLASS@"/>
+ <component xmlns="dpml:metro" type="dpml.tools.impl.StandardBuilder"
+ handler="net.dpml.runtime.ComponentStrategyHandler"/>
<classpath>
- <system>
- <uri>artifact:jar:ant/ant-launcher#@ANT-VERSION@</uri>
- <uri>artifact:jar:ant/ant#@ANT-VERSION@</uri>
- <uri>artifact:jar:junit/junit#@JUNIT-VERSION@</uri>
- <uri>artifact:jar:ant/ant-junit#@ANT-VERSION@</uri>
- <uri>artifact:jar:ant/ant-xslp#@ANT-VERSION@</uri>
- <uri>artifact:jar:ant/ant-trax#@ANT-VERSION@</uri>
- </system>
<private>
-
<uri>artifact:jar:dpml/transit/dpml-transit-main#@TRANSIT-CORE-VERSION@</uri>
-
<uri>artifact:jar:dpml/transit/dpml-transit-tools#@TRANSIT-TOOLS-VERSION@</uri>
- <uri>artifact:jar:dpml/depot/dpml-library#@LIBRARY-VERSION@</uri>
-
<uri>artifact:jar:@PROJECT-GROUP@/@PROJECT-NAME@#@PROJECT-VERSION@</uri>
+ <uri>artifact:jar:junit/junit#@JUNIT-VERSION@</uri>
+ <uri>artifact:jar:org/apache/ant/ant-launcher#@ANT-VERSION@</uri>
+ <uri>artifact:jar:org/apache/ant/ant#@ANT-VERSION@</uri>
+ <uri>artifact:jar:org/apache/ant/ant-trax#@ANT-VERSION@</uri>
+ <uri>artifact:jar:org/apache/ant/ant-junit#@ANT-VERSION@</uri>
+ <uri>artifact:jar:dpml/transit/dpml-transit-main#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/lang/dpml-lang-part#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/depot/dpml-depot-library#BOOTSTRAP</uri>
+ <uri>artifact:jar:dpml/depot/dpml-depot-build#BOOTSTRAP</uri>
+ <uri>artifact:jar:@PROJECT-GROUP@/@PROJECT-NAME@#BOOTSTRAP</uri>
</private>
</classpath>
Added: trunk/main/depot/tools/etc/component.xml
===================================================================
--- trunk/main/depot/tools/etc/component.xml 2007-02-08 23:30:11 UTC (rev
1817)
+++ trunk/main/depot/tools/etc/component.xml 2007-02-08 23:31:25 UTC (rev
1818)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<component xmlns="dpml:metro" type="dpml.tools.impl.StandardBuilder"/>
Modified: trunk/main/depot/tools/etc/prefs/templates/standard.template
===================================================================
--- trunk/main/depot/tools/etc/prefs/templates/standard.template
2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/tools/etc/prefs/templates/standard.template
2007-02-08 23:31:25 UTC (rev 1818)
@@ -17,13 +17,8 @@
-->
<project name="standard" default="install"
- xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="dpml:depot" >
+ xmlns:x="antlib:dpml.tools" >
- <transit:plugin uri="@PROJECT-LINK-URI@">
- <antlib urn="dpml:depot" resource="net/dpml/tools/tasks/antlib.xml"/>
- </transit:plugin>
-
<target name="init">
<x:init/>
</target>
@@ -70,6 +65,10 @@
</xslt>
</target>
+ <target name="javadoc" depends="init">
+ <x:javadoc/>
+ </target>
+
</project>
Modified: trunk/main/depot/tools/etc/prefs/xmls/builder.xml
===================================================================
--- trunk/main/depot/tools/etc/prefs/xmls/builder.xml 2007-02-08 23:30:11
UTC (rev 1817)
+++ trunk/main/depot/tools/etc/prefs/xmls/builder.xml 2007-02-08 23:31:25
UTC (rev 1818)
@@ -9,7 +9,7 @@
<properties/>
<listeners>
- <listener name="standard"
class="net.dpml.tools.impl.StandardBuildListener" priority="0"/>
+ <listener name="standard" class="dpml.tools.impl.StandardBuildListener"
priority="0"/>
</listeners>
</builder>
Added: trunk/main/depot/tools/project.xml
===================================================================
--- trunk/main/depot/tools/project.xml 2007-02-08 23:30:11 UTC (rev 1817)
+++ trunk/main/depot/tools/project.xml 2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project xmlns="dpml:library" name="dpml-depot-builder">
+
+ <info title="DPML Depot Toolkit">
+ <description>Antlib supporting Depot-based build
automation.</description>
+ </info>
+
+ <types>
+ <type id="jar"/>
+ <type id="part" source="target/component.xml" alias="true"/>
+ </types>
+
+ <dependencies>
+ <runtime>
+ <include ref="dpml/lang/dpml-lang-part"/>
+ <include ref="dpml/depot/dpml-depot-library"/>
+ <include ref="dpml/depot/dpml-depot-build"/>
+ <include ref="org/apache/ant/ant"/>
+ <include ref="org/apache/ant/ant-junit"/>
+ <include ref="org/apache/ant/ant-trax"/>
+ <!--<include uri="artifact:jar:openjdk/javac/javac"/>-->
+ </runtime>
+ </dependencies>
+
+ <filters>
+ <filter token="PLUGIN-CLASS" value="dpml.tools.impl.StandardBuilder"/>
+ <feature token="PART-XSD-URI" id="uri" type="xsd" alias="true"
ref="dpml/lang/dpml-lang-part" />
+ <feature token="PART-XSD-SPEC-URI" id="uri" type="xsd" alias="true"
ref="dpml/lang/dpml-lang-part" />
+ <feature token="PROJECT-URI" id="uri" type="part"/>
+ <feature token="PROJECT-LINK-URI" id="uri" type="part" alias="true"/>
+ <feature token="PROJECT-NAME" id="name"/>
+ <feature token="PROJECT-GROUP" id="group"/>
+ <feature token="PROJECT-VERSION" id="version"/>
+ <feature token="ANT-VERSION" id="version" ref="org/apache/ant/ant"/>
+ <feature token="JUNIT-VERSION" id="version" ref="junit/junit"/>
+ <feature token="DEPOT-CHECKSTYLE-PLUGIN-URI" id="uri" type="part"
ref="dpml/depot/dpml-depot-checkstyle" />
+ <feature token="DEPOT-CHECKSTYLE-PLUGIN-LINK-URI" id="uri" type="part"
alias="true"
+ ref="dpml/depot/dpml-depot-checkstyle" />
+ <feature token="TRANSIT-CORE-VERSION" id="version"
ref="dpml/transit/dpml-transit-main"/>
+ <!--<feature token="TRANSIT-TOOLS-VERSION" id="version"
ref="dpml/transit/dpml-transit-tools"/>-->
+ <feature token="LIBRARY-VERSION" id="version"
ref="dpml/depot/dpml-depot-library"/>
+ </filters>
+
+</project>
Copied: trunk/main/depot/tools/src/main/dpml (from rev 1789,
trunk/main/depot/tools/src/main/net/dpml)
Deleted: trunk/main/depot/tools/src/main/dpml/tools/BuildError.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/BuildError.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/BuildError.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2006 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;
-
-import org.apache.tools.ant.Location;
-
-/**
- * A BuildError is thrown when a fatal error occurs during build execution.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class BuildError extends Error
-{
- private final Location m_location;
-
- /**
- * Creation of a new BuildError.
- * @param message the exception message
- */
- public BuildError( String message )
- {
- this( message, null );
- }
-
- /**
- * Creation of a new BuildError.
- * @param message the exception message
- * @param cause the causal exception
- */
- public BuildError( String message, Throwable cause )
- {
- this( message, cause, null );
- }
-
- /**
- * Creation of a new BuildError.
- * @param message the exception message
- * @param cause the causal exception
- * @param location the location of the error
- */
- public BuildError( String message, Throwable cause, Location location )
- {
- super( message, cause );
-
- m_location = location;
- }
-
- /**
- * Return the location of the build error.
- * @return the build location
- */
- public Location getLocation()
- {
- return m_location;
- }
-}
Added: trunk/main/depot/tools/src/main/dpml/tools/BuilderError.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/BuilderError.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/BuilderError.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006 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 dpml.tools;
+
+import org.apache.tools.ant.Location;
+
+import dpml.build.BuildError;
+
+/**
+ * A BuildError is thrown when a fatal error occurs during build execution.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class BuilderError extends BuildError
+{
+ private final Location m_location;
+
+ /**
+ * Creation of a new BuildError.
+ * @param message the exception message
+ */
+ public BuilderError( String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Creation of a new BuildError.
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public BuilderError( String message, Throwable cause )
+ {
+ this( message, cause, null );
+ }
+
+ /**
+ * Creation of a new BuildError.
+ * @param message the exception message
+ * @param cause the causal exception
+ * @param location the location of the error
+ */
+ public BuilderError( String message, Throwable cause, Location location )
+ {
+ super( message, cause );
+
+ m_location = location;
+ }
+
+ /**
+ * Return the location of the build error.
+ * @return the build location
+ */
+ public Location getLocation()
+ {
+ return m_location;
+ }
+}
Modified: trunk/main/depot/tools/src/main/dpml/tools/Context.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/Context.java 2006-11-30
21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/Context.java 2007-02-08
23:31:25 UTC (rev 1818)
@@ -16,13 +16,15 @@
* limitations under the License.
*/
-package net.dpml.tools;
+package dpml.tools;
import java.io.File;
+import java.io.IOException;
-import net.dpml.library.Library;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Library;
+import dpml.library.Resource;
+import dpml.library.Scope;
+import dpml.library.Type;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
@@ -62,7 +64,7 @@
/**
*Initialize the context.
*/
- void init();
+ void init() throws IOException;
/**
* Return an Ant path suitable for compile or runtime usage. If the
supplied scope is
@@ -242,7 +244,7 @@
* @param type the deliverable type
* @return the directory
*/
- File getTargetDeliverable( String type );
+ //File getTargetDeliverable( String type );
/**
* Create a file relative to the resource basedir.
@@ -253,39 +255,39 @@
/**
* Return a filename using the layout strategy employed by the cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the filename
*/
- String getLayoutFilename( String id );
+ String getLayoutFilename( Type type );
/**
* Return the directory path representing the module structure and type
* using the layout strategy employed by the cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the path from the root of the cache to the directory
containing the artifact
*/
- String getLayoutBase( String id );
+ String getLayoutBase( Type type );
/**
* Return the full path to an artifact using the layout employed by the
cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the full path including base path and filename
*/
- String getLayoutPath( String id );
+ String getLayoutPath( Type type );
/**
* Utility operation to construct a new classpath path instance.
* @param scope the build scope
* @return the path
*/
- Path createPath( Scope scope );
+ Path createPath( Scope scope ) throws IOException;
/**
* Utility operation to construct a new path using a supplied array of
resources.
* @param resources the resource to use in path construction
* @return the path
*/
- Path createPath( Resource[] resources );
+ Path createPath( Resource[] resources ) throws IOException;
/**
* Utility operation to construct a new path using a supplied array of
resources.
@@ -294,6 +296,6 @@
* @param filter if true restrict path entries to resources that produce
jars
* @return the path
*/
- Path createPath( Resource[] resources, boolean resolve, boolean filter );
+ Path createPath( Resource[] resources, boolean resolve, boolean filter )
throws IOException;
}
Added: trunk/main/depot/tools/src/main/dpml/tools/antlib.xml
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/antlib.xml 2006-11-30
21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/antlib.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<antlib xmlns:current="ant:current">
+
+ <!-- TRANSIT TASKS -->
+
+ <!--<taskdef name="init" classname="dpml.tools.transit.MainTask"/>-->
+ <!--<taskdef name="plugin"
classname="dpml.tools.transit.PluginTask"/>-->
+ <taskdef name="import"
classname="dpml.tools.transit.ImportArtifactTask"/>
+ <taskdef name="get" classname="dpml.tools.transit.GetTask"/>
+
+ <!-- DEPOT TASKS -->
+
+ <taskdef name="clean" classname="dpml.tools.tasks.CleanTask"/>
+ <taskdef name="init"
classname="dpml.tools.tasks.InitializationTask"/>
+ <taskdef name="prepare" classname="dpml.tools.tasks.PrepareTask"/>
+ <taskdef name="build" classname="dpml.tools.tasks.BuildTask"/>
+ <taskdef name="package" classname="dpml.tools.tasks.PackageTask"/>
+ <taskdef name="test" classname="dpml.tools.tasks.TestTask"/>
+ <taskdef name="install" classname="dpml.tools.tasks.InstallTask"/>
+
+ <taskdef name="jar" classname="dpml.tools.tasks.JarTask"/>
+ <taskdef name="junit" classname="dpml.tools.tasks.JUnitTestTask"/>
+ <taskdef name="property" classname="dpml.tools.tasks.PropertyTask"/>
+ <taskdef name="filter" classname="dpml.tools.tasks.FilterTask"/>
+ <taskdef name="module" classname="dpml.tools.tasks.ModuleTask"/>
+ <taskdef name="reactor" classname="dpml.tools.tasks.ReactorTask"/>
+ <taskdef name="plugin" classname="dpml.tools.tasks.PluginTask"/>
+ <taskdef name="replicate" classname="dpml.tools.tasks.ReplicateTask"/>
+ <taskdef name="javadoc" classname="dpml.tools.tasks.JavadocTask"/>
+ <taskdef name="docs" classname="dpml.tools.tasks.DocTask"/>
+ <taskdef name="rmic" classname="dpml.tools.tasks.RMICTask"/>
+
+ <!--<taskdef name="javac"
classname="dpml.tools.tasks.JavacTask"/>-->
+ <!--<taskdef name="export"
classname="dpml.tools.tasks.PluginExportTask"/>-->
+
+</antlib>
Deleted: trunk/main/depot/tools/src/main/dpml/tools/impl/BuilderError.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/impl/BuilderError.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/impl/BuilderError.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,47 +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;
-
-/**
- * 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/src/main/dpml/tools/impl/DefaultContext.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/impl/DefaultContext.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/impl/DefaultContext.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Stephen J. McConnell.
+ * Copyright 2005-2006 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.
@@ -16,36 +16,43 @@
* limitations under the License.
*/
-package net.dpml.tools.impl;
+package dpml.tools.impl;
+import dpml.build.Builder;
+import dpml.build.BuildError;
+
+import dpml.tools.BuilderError;
+
+import dpml.library.impl.DefaultLibrary;
+
+import dpml.tools.Context;
+import dpml.tools.info.ListenerDirective;
+
+import dpml.util.DefaultLogger;
+
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.Strategy;
+import net.dpml.lang.ServiceRegistry;
+import net.dpml.lang.SimpleServiceRegistry;
-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 dpml.library.Scope;
+import dpml.library.Library;
+import dpml.library.Resource;
+import dpml.library.Type;
+import dpml.library.Filter;
-import net.dpml.tools.info.ListenerDirective;
-
-import net.dpml.tools.Context;
-
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
-import net.dpml.transit.link.LinkManager;
+import net.dpml.transit.LinkManager;
import net.dpml.transit.Layout;
-import net.dpml.transit.ClassicLayout;
+import net.dpml.transit.layout.ClassicLayout;
import net.dpml.util.Logger;
-import net.dpml.util.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -135,7 +142,7 @@
{
final String error =
"Error while attempting to setup the filter [" + token +
"].";
- throw new BuildException( error, e );
+ throw new BuilderError( error, e );
}
}
@@ -194,16 +201,17 @@
{
Type type = types[i];
String id = type.getID();
- File file = getTargetDeliverable( id );
+ String name = type.getCompoundName();
+ File file = type.getFile( true );
String path = file.getCanonicalPath();
- setProperty( "project.deliverable." + id + ".path", path );
+ setProperty( "project.deliverable." + name + ".path", path );
File dir = file.getParentFile();
String spec = dir.getCanonicalPath();
- setProperty( "project.deliverable." + id + ".dir", spec );
- String base = getLayoutBase( id );
- setProperty( "project.cache." + id + ".dir", base );
- String address = getLayoutPath( id );
- setProperty( "project.cache." + id + ".path", address );
+ setProperty( "project.deliverable." + name + ".dir", spec );
+ String base = getLayoutBase( type );
+ setProperty( "project.cache." + name + ".dir", base );
+ String address = getLayoutPath( type );
+ setProperty( "project.cache." + name + ".path", address );
}
}
@@ -238,7 +246,7 @@
* Initialize the context during which runtime and test path objects are
* established as project references.
*/
- public void init()
+ public void init() throws IOException
{
if( m_runtime != null )
{
@@ -254,10 +262,8 @@
m_test = createPath( Scope.TEST );
if( m_resource.isa( "jar" ) )
{
- File deliverables = getTargetDeliverablesDirectory();
- File jars = new File( deliverables, "jars" );
- String filename = getLayoutFilename( "jar" );
- File jar = new File( jars, filename );
+ Type type = m_resource.getType( "jar" );
+ File jar = type.getFile( true );
m_test.createPathElement().setLocation( jar );
}
final File testClasses = getTargetClassesTestDirectory();
@@ -317,9 +323,24 @@
{
if( m_runtime == null )
{
- init();
+ try
+ {
+ init();
+ }
+ catch( IOException e )
+ {
+ final String error =
+ "Unable to resolve path for the scope ["
+ + scope
+ + "] in the resource ["
+ + m_resource.getResourcePath()
+ + "] ("
+ + m_resource.getBaseDir()
+ + ").";
+ throw new BuildError( error, e );
+ }
}
- if( scope.isLessThan( Scope.TEST ) )
+ if( scope.compareTo( Scope.TEST ) < 0 )
{
return m_runtime;
}
@@ -581,20 +602,6 @@
}
/**
- * Return the project target deliverables directory.
- * @param type the deliverable type
- * @return the directory
- */
- public File getTargetDeliverable( String type )
- {
- Artifact artifact = m_resource.getArtifact( type );
- String path = CLASSIC_LAYOUT.resolveFilename( artifact );
- String types = type + "s";
- File root = new File( getTargetDeliverablesDirectory(), types );
- return new File( root, path );
- }
-
- /**
* Create a file relative to the resource basedir.
* @param path the relative path
* @return the directory
@@ -607,35 +614,43 @@
/**
* Return a filename using the layout strategy employed by the cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the filename
*/
- public String getLayoutFilename( String id )
+ public String getLayoutFilename( Type type )
{
- Artifact artifact = m_resource.getArtifact( id );
- return Transit.getInstance().getCacheLayout().resolveFilename(
artifact );
+ return type.getLayoutPath();
}
/**
* Return the directory path representing the module structure and type
* using the layout strategy employed by the cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the path from the root of the cache to the directory
containing the artifact
*/
- public String getLayoutBase( String id )
+ public String getLayoutBase( Type type ) // TODO: cleanup and move to
resource
{
- Artifact artifact = m_resource.getArtifact( id );
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+ Artifact artifact = type.getArtifact();
return Transit.getInstance().getCacheLayout().resolveBase( artifact
);
}
/**
* Return the full path to an artifact using the layout employed by the
cache.
- * @param id the artifact type
+ * @param type the artifact type
* @return the full path including base path and filename
*/
- public String getLayoutPath( String id )
+ public String getLayoutPath( Type type ) // TODO: cleanup and move to
resource
{
- Artifact artifact = m_resource.getArtifact( id );
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+
+ Artifact artifact = type.getArtifact();
return Transit.getInstance().getCacheLayout().resolvePath( artifact
);
}
@@ -644,19 +659,19 @@
* @param scope the build scope
* @return the path
*/
- public Path createPath( Scope scope )
+ public Path createPath( Scope scope ) throws IOException
{
- try
- {
+ //try
+ //{
Resource[] resources = m_resource.getClasspathProviders( scope );
return createPath( resources, true, true );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while constructing path instance for the
scope: " + scope;
- throw new RuntimeException( error, e );
- }
+ //}
+ //catch( Exception e )
+ //{
+ // final String error =
+ // "Unexpected error while constructing path instance for the
scope: " + scope;
+ // throw new BuilderError( error, e );
+ //}
}
/**
@@ -664,7 +679,7 @@
* @param resources the resource to use in path construction
* @return the path
*/
- public Path createPath( Resource[] resources )
+ public Path createPath( Resource[] resources ) throws IOException
{
return createPath( resources, true, false );
}
@@ -676,7 +691,7 @@
* @param filter if true restrict path entries to resources that produce
jars
* @return the path
*/
- public Path createPath( Resource[] resources, boolean resolve, boolean
filter )
+ public Path createPath( Resource[] resources, boolean resolve, boolean
filter ) throws IOException
{
final Path path = new Path( m_project );
File cache = (File) m_project.getReference( "dpml.cache" );
@@ -685,18 +700,33 @@
Resource resource = resources[i];
if( !resource.equals( getResource() ) )
{
- if( filter && resource.isa( "jar" ) )
+ if( filter )
{
- Artifact artifact = resource.getArtifact( "jar" );
- addToPath( cache, path, artifact, resolve );
+ if( resource.isa( "jar" ) )
+ {
+ Type type = resource.getType( "jar" );
+ if( !type.getTest() )
+ {
+ if( resolve )
+ {
+ Artifact artifact =
type.getResolvedArtifact();
+ }
+ File file = type.getFile();
+ path.createPathElement().setLocation( file );
+ }
+ }
}
else
{
Type[] types = resource.getTypes();
for( int j=0; j<types.length; j++ )
{
- Artifact artifact = resource.getArtifact(
types[j].getID() );
- addToPath( cache, path, artifact, resolve );
+ Type type = types[j];
+ if( !type.getTest() )
+ {
+ File file = type.getFile();
+ path.createPathElement().setLocation( file );
+ }
}
}
}
@@ -704,62 +734,6 @@
return path;
}
- private void addToPath( File cache, Path path, Artifact artifact,
boolean resolve )
- {
- Artifact target = getTargetArtifact( artifact );
- String location =
Transit.getInstance().getCacheLayout().resolvePath( target );
- File file = new File( cache, location );
- path.createPathElement().setLocation( file );
-
- if( resolve )
- {
- resolveArtifact( artifact );
- }
- }
-
- private Artifact getTargetArtifact( Artifact artifact )
- {
- String scheme = artifact.getScheme();
- if( !Artifact.LINK.equals( scheme ) )
- {
- return artifact;
- }
- else
- {
- try
- {
- LinkManager manager = Transit.getInstance().getLinkManager();
- URI uri = manager.getTargetURI( artifact.toURI() );
- return Artifact.createArtifact( uri );
- }
- catch( IOException e )
- {
- final String error =
- "Unable to resolve link artifact ["
- + artifact
- + "].";
- throw new BuildException( error, e );
- }
- }
- }
-
- private void resolveArtifact( Artifact artifact )
- {
- try
- {
- URL url = artifact.toURL();
- url.openStream();
- }
- catch( IOException e )
- {
- final String error =
- "Unable to resolve artifact ["
- + artifact
- + "].";
- throw new BuildException( error, e );
- }
- }
-
private static Resource newResource( File basedir ) throws Exception
{
Logger logger = new DefaultLogger();
@@ -790,35 +764,21 @@
{
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 );
- }
+ String classname = listener.getClassname();
+ return loadBuildListener( name, uri, classname );
}
-
- private Object loadInstance( String name, URI uri, String classname )
+
+ private BuildListener loadBuildListener( String name, URI uri, String
classname )
{
+ ServiceRegistry registry = new SimpleServiceRegistry( this );
if( null == uri )
{
try
{
ClassLoader classloader = getClass().getClassLoader();
- Class clazz = classloader.loadClass( classname );
- Object[] args = new Object[]{this};
- return Plugin.instantiate( clazz, args );
+ Class<?> clazz = classloader.loadClass( classname );
+ Strategy strategy = Strategy.load( clazz, registry, name );
+ return strategy.getInstance( BuildListener.class );
}
catch( Throwable e )
{
@@ -834,25 +794,24 @@
ClassLoader context =
Thread.currentThread().getContextClassLoader();
try
{
- ClassLoader classloader = getClass().getClassLoader();
+ ClassLoader classloader = Builder.class.getClassLoader();
Thread.currentThread().setContextClassLoader( classloader );
- Object[] params = new Object[]{this};
- Part part = Part.load( uri );
+ Strategy strategy = Strategy.load( classloader, registry,
uri, name );
if( null == classname )
{
- return part.instantiate( params );
+ return strategy.getInstance( BuildListener.class );
}
else
{
- ClassLoader loader = part.getClassLoader();
- Class c = loader.loadClass( classname );
- return Plugin.instantiate( c, params );
+ ClassLoader loader = strategy.getClassLoader();
+ Class<?> c = loader.loadClass( classname );
+ return Strategy.load( c, registry, (String) null
).getInstance( BuildListener.class );
}
}
catch( Throwable e )
{
final String error =
- "Internal error while attempting to load plugin."
+ "Internal error while attempting to load build listener."
+ "\nURI: " + uri
+ "\nName: " + name;
throw new BuilderError( error, e );
Modified:
trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuildListener.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuildListener.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package net.dpml.tools.impl;
+package dpml.tools.impl;
-import net.dpml.library.Resource;
+import dpml.library.Resource;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.BuildEvent;
Modified: trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuilder.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/impl/StandardBuilder.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/impl/StandardBuilder.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,25 +16,31 @@
* limitations under the License.
*/
-package net.dpml.tools.impl;
+package dpml.tools.impl;
+import dpml.build.Builder;
+import dpml.build.BuildError;
+
+import dpml.library.impl.DefaultLibrary;
+
+import dpml.tools.Context;
+import dpml.tools.BuilderError;
+import dpml.tools.info.BuilderDirective;
+import dpml.tools.info.BuilderDirectiveHelper;
+
+import dpml.tools.transit.MainTask;
+
import java.io.File;
import java.net.URI;
import java.net.URL;
import java.util.Vector;
-import net.dpml.library.Builder;
-import net.dpml.library.Library;
-import net.dpml.library.Resource;
+import net.dpml.annotation.Component;
-import net.dpml.tools.Context;
-import net.dpml.tools.BuildError;
-import net.dpml.tools.info.BuilderDirective;
-import net.dpml.tools.info.BuilderDirectiveHelper;
+import dpml.library.Library;
+import dpml.library.Resource;
import net.dpml.transit.Artifact;
-import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.tools.MainTask;
import net.dpml.util.Logger;
@@ -46,6 +52,8 @@
import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.DemuxInputStream;
+import static net.dpml.annotation.LifestylePolicy.SINGLETON;
+
/**
* The StandardBuilder is a plugin established by the Tools build controller
* used for the building of a project based on the Ant build system in
conjunction
@@ -54,6 +62,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
+@Component( name="builder", lifestyle=SINGLETON )
public class StandardBuilder implements Builder
{
//
------------------------------------------------------------------------
@@ -91,40 +100,21 @@
//
------------------------------------------------------------------------
private Logger m_logger;
- private TransitModel m_model;
private Library m_library;
private boolean m_verbose;
- private Throwable m_result;
//
------------------------------------------------------------------------
// constructors
//
------------------------------------------------------------------------
- /**
- * Creation of a new standard builder.
- *
- * @param logger assigned logging channel
- * @param library the library
- */
- public StandardBuilder( Logger logger, Library library )
+ public StandardBuilder( Logger logger, Library library, Boolean verbose
) throws Exception
{
- 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;
- Thread.currentThread().setContextClassLoader(
Builder.class.getClassLoader() );
+ //Thread.currentThread().setContextClassLoader(
Builder.class.getClassLoader() );
+ Thread.currentThread().setContextClassLoader(
StandardBuilder.class.getClassLoader() );
}
//
------------------------------------------------------------------------
@@ -137,7 +127,7 @@
* @param targets an array of build target names
* @return the build success status
*/
- public boolean build( Resource resource, String[] targets )
+ public boolean build( Resource resource, String[] targets ) throws
Exception
{
Project project = null;
File template = null;
@@ -147,34 +137,26 @@
}
catch( Throwable e )
{
- m_result = e;
- if( m_logger.isErrorEnabled() )
- {
- final String error =
- "Failed to construct embedded project."
- + "\nResource: " + resource.getResourcePath()
- + "\nBasedir: " + resource.getBaseDir();
- m_logger.error( error, e );
- }
- return false;
+ final String error =
+ "Failed to construct embedded Ant project."
+ + "\nResource: " + resource.getResourcePath()
+ + "\nBasedir: " + resource.getBaseDir();
+ throw new BuilderError( error, e );
}
+
try
{
template = getTemplateFile( resource );
}
catch( Throwable e )
{
- m_result = e;
- if( m_logger.isErrorEnabled() )
- {
- final String error =
- "Failed to load template file."
- + "\nResource: " + resource.getResourcePath()
- + "\nBasedir: " + resource.getBaseDir();
- m_logger.error( error, e );
- }
- return false;
+ final String error =
+ "Failed to load template file."
+ + "\nResource: " + resource.getResourcePath()
+ + "\nBasedir: " + resource.getBaseDir();
+ throw new BuilderError( error, e );
}
+
return build( resource, project, template, targets );
}
@@ -245,7 +227,7 @@
{
final String error =
"Resource template property 'project.template' is
undefined.";
- throw new BuildException( error );
+ throw new BuilderError( error );
}
}
catch( BuildException e )
@@ -254,12 +236,11 @@
}
catch( Throwable e )
{
- m_result = e;
final String error =
"Unexpected error while attempting to resolve project
template."
+ "\nResource path: "
+ resource.getResourcePath();
- throw new BuildError( error, e );
+ throw new BuilderError( error, e );
}
}
@@ -267,90 +248,84 @@
// implementation
//
------------------------------------------------------------------------
- boolean build( Resource resource, Project project, File template,
String[] targets )
+ boolean build( Resource resource, Project project, File template,
String[] targets ) throws Exception
{
- try
+ ProjectHelper helper = (ProjectHelper) project.getReference(
"ant.projectHelper" );
+
+ if( null != template )
{
- ProjectHelper helper = (ProjectHelper) project.getReference(
"ant.projectHelper" );
-
- if( null != template )
+ helper.parse( project, template );
+ }
+
+ Vector<String> vector = new Vector<String>();
+ if( targets.length == 0 )
+ {
+ if( null != project.getDefaultTarget() )
{
- helper.parse( project, template );
+ vector.addElement( project.getDefaultTarget() );
}
-
- Vector vector = new Vector();
-
- if( targets.length == 0 )
- {
- if( null != project.getDefaultTarget() )
- {
- vector.addElement( project.getDefaultTarget() );
- }
- else
- {
- vector.addElement( CONFIGURATION.getDefaultPhase() );
- }
- }
else
{
- for( int i=0; i<targets.length; i++ )
- {
- String target = targets[i];
- vector.addElement( target );
- }
+ vector.addElement( CONFIGURATION.getDefaultPhase() );
}
-
- if( vector.size() == 0 )
+ }
+ else
+ {
+ for( int i=0; i<targets.length; i++ )
{
- final String errorMessage =
- "No targets requested and no default target declared.";
- throw new BuildException( errorMessage );
+ String target = targets[i];
+ vector.addElement( target );
}
-
+ }
+
+ if( vector.size() == 0 )
+ {
+ final String errorMessage =
+ "No targets requested and no default target declared.";
+ throw new BuildException( errorMessage );
+ }
+
+ Throwable error = null;
+ try
+ {
project.executeTargets( vector );
return true;
}
catch( BuildException e )
{
- m_result = e;
- if( m_logger.isDebugEnabled() )
+ error = e;
+ return false;
+ /*
+ if( cause instanceof RuntimeException )
{
- final String error =
- "Build failure."
- + "\nProject: " + resource.getResourcePath()
- + "\nBasedir: " + resource.getBaseDir()
- + "\nTemplate: " + template
- + "\nLocation: " + e.getLocation();
- Throwable cause = e.getCause();
- m_logger.error( error, cause );
+ throw (RuntimeException) cause;
}
- return false;
- }
- catch( Throwable e )
- {
- System.out.println(
- "# UNEXPECTED: "
- + e.toString()
- + " ("
- + m_logger.isErrorEnabled()
- + ")" );
-
- m_result = e;
- if( m_logger.isErrorEnabled() )
+ else if( cause instanceof Error )
{
- final String error =
- "Build error."
- + "\nProject: " + resource.getResourcePath()
- + "\nBasedir: " + resource.getBaseDir()
- + "\nTemplate: " + template;
- m_logger.error( error, e );
+ throw (Error) cause;
}
- return false;
+ else
+ {
+ return false;
+ }
+ */
}
finally
{
- project.fireBuildFinished( m_result );
+ project.fireBuildFinished( error );
}
+ /*
+ catch( RuntimeException e )
+ {
+ project.fireBuildFinished( e );
+ throw e;
+ }
+ catch( Error e )
+ {
+ project.fireBuildFinished( e );
+ throw e;
+ }
+ */
}
private File getTemplateFile( String spec )
@@ -376,6 +351,8 @@
{
Project project = newProject();
Context context = new DefaultContext( resource, project );
+ project.setName( resource.getName() );
+ project.setBaseDir( resource.getBaseDir() );
return project;
}
catch( Exception e )
@@ -383,7 +360,7 @@
final String error =
"Unable to establish build context."
+ "\nProject: " + resource;
- throw new BuildError( error, e );
+ throw new BuilderError( error, e );
}
}
Modified:
trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirective.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/info/BuilderDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,12 @@
* limitations under the License.
*/
-package net.dpml.tools.info;
+package dpml.tools.info;
import java.util.Arrays;
import java.util.Properties;
-import net.dpml.library.info.AbstractDirective;
+import dpml.library.info.AbstractDirective;
import net.dpml.lang.UnknownKeyException;
Modified:
trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirectiveHelper.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/main/dpml/tools/info/BuilderDirectiveHelper.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.info;
+package dpml.tools.info;
import java.io.File;
import java.io.IOException;
@@ -31,7 +31,7 @@
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
-import net.dpml.util.ElementHelper;
+import dpml.util.ElementHelper;
import org.w3c.dom.Element;
@@ -108,7 +108,7 @@
*/
public static BuilderDirective build() throws Exception
{
- File prefs = Transit.DPML_PREFS;
+ File prefs = Transit.PREFS;
File config = new File( prefs, "dpml/tools/xmls/builder.xml" );
if( config.exists() )
{
Modified:
trunk/main/depot/tools/src/main/dpml/tools/info/ListenerDirective.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/info/ListenerDirective.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/info/ListenerDirective.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,12 @@
* limitations under the License.
*/
-package net.dpml.tools.info;
+package dpml.tools.info;
import java.net.URI;
import java.util.Properties;
-import net.dpml.library.info.AbstractDirective;
+import dpml.library.info.AbstractDirective;
/**
* The ListenerDirective is an immutable descriptor used to define
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/BuildTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/BuildTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/BuildTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,13 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
-import net.dpml.library.info.Scope;
+import dpml.library.Scope;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/CleanTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/CleanTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/CleanTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Delete;
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/DocTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/DocTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/DocTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
import java.io.FileFilter;
@@ -52,7 +52,7 @@
*/
public class DocTask extends GenericTask
{
- private static final String ORG_NAME_VALUE = "The Digital Product Meta
Library";
+ private static final String ORG_NAME_VALUE = "The Digital Product
Management Laboratory";
private static final String DOC_TEMP_VALUE = "docs";
private static final String DOC_SRC_VALUE = "docs";
private static final String DOC_RESOURCES_VALUE = "resources";
@@ -310,7 +310,7 @@
private File getThemesDirectory()
{
- return new File( Transit.DPML_PREFS, "dpml/tools/themes" );
+ return new File( Transit.PREFS, "dpml/tools/themes" );
}
private String getHomePath()
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/FeatureTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/FeatureTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/FeatureTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
-import net.dpml.library.Resource;
-import net.dpml.library.Feature;
-import net.dpml.library.Type;
+import dpml.library.Resource;
+import dpml.library.Feature;
+import dpml.library.Type;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -92,7 +92,7 @@
}
Resource resource = getResource();
- Feature feature = Feature.parse( m_feature );
+ Feature feature = Feature.valueOf( m_feature.toUpperCase() );
if( null == m_type )
{
return Feature.resolve( resource, feature );
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/FilterTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/FilterTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/FilterTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Filter;
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/GenericTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/GenericTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/GenericTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,18 +16,20 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.util.StandardClassLoader;
+import dpml.library.impl.InvalidNameException;
+
import java.io.File;
+import dpml.tools.Context;
+import dpml.tools.impl.DefaultContext;
-import net.dpml.tools.Context;
-import net.dpml.tools.impl.DefaultContext;
+import dpml.library.Library;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
-import net.dpml.library.Library;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
-
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -37,6 +39,7 @@
import org.apache.tools.ant.taskdefs.Delete;
import org.apache.tools.ant.taskdefs.Checksum;
import org.apache.tools.ant.taskdefs.ExecTask;
+import org.apache.tools.ant.util.FileUtils;
/**
@@ -120,15 +123,16 @@
}
else
{
- //System.out.println(
- // net.dpml.lang.StandardClassLoader.toString(
- // object.getClass().getClassLoader(),
- // Context.class.getClassLoader() ) );
-
+ final String classpath = StandardClassLoader.toString(
+ object.getClass().getClassLoader(),
+ Context.class.getClassLoader() );
+
final String error =
"Object assigned under the 'project.context' key is not
assignable to a context instance."
+ "\nObject: " + object.getClass().getName()
- + "\nExpecting: " + Context.class.getName();
+ + "\nExpecting: " + Context.class.getName()
+ + classpath;
+
throw new IllegalStateException( error );
}
}
@@ -149,6 +153,11 @@
{
return new DefaultContext( project );
}
+ catch( InvalidNameException e )
+ {
+ String error = e.getMessage();
+ throw new BuildException( error, e, getLocation() );
+ }
catch( ResourceNotFoundException e )
{
final String message = e.getMessage();
@@ -255,7 +264,7 @@
*/
public void asc( final File file )
{
- final String path = Project.translatePath( file.toString() );
+ final String path = FileUtils.translatePath( file.toString() );
final File asc = new File( file.toString() + "." + ASC_EXT );
if( asc.exists() )
{
@@ -283,6 +292,19 @@
execute.execute();
}
}
+
+ protected String getProperty( String key, String value )
+ {
+ String v = getProject().getProperty( key );
+ if( null != v )
+ {
+ return v;
+ }
+ else
+ {
+ return getResource().getProperty( key, value );
+ }
+ }
private static final int TIMEOUT = 10000;
}
Modified:
trunk/main/depot/tools/src/main/dpml/tools/tasks/InitializationTask.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InitializationTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/InitializationTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,9 +16,9 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
/**
* General initialization during which context establishment is
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/InstallTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InstallTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/InstallTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,8 +16,10 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.tools.BuilderError;
+
import java.io.File;
import java.io.OutputStream;
import java.io.FileOutputStream;
@@ -29,14 +31,17 @@
import net.dpml.lang.Version;
-import net.dpml.library.Module;
-import net.dpml.library.Resource;
-import net.dpml.library.Type;
+import dpml.library.Module;
+import dpml.library.Resource;
+import dpml.library.Type;
import net.dpml.transit.Artifact;
-import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.link.ArtifactLinkManager;
+import net.dpml.transit.Transit;
+import net.dpml.transit.ArtifactNotFoundException;
+import net.dpml.transit.LinkManager;
+import net.dpml.transit.Layout;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
@@ -63,57 +68,198 @@
private void installDeliverables()
{
Resource resource = getResource();
- String resourceVersion = resource.getVersion();
- boolean snapshot = "SNAPSHOT".equals( resourceVersion );
- boolean bootstrap = "BOOTSTRAP".equals( resourceVersion );
- boolean validation = resource.getBooleanProperty(
"project.validation.enabled", false );
- boolean validate = !snapshot && !bootstrap && validation;
Type[] types = resource.getTypes();
if( types.length == 0 )
{
return;
}
+ String resourceVersion = resource.getVersion();
+ boolean snapshot = "SNAPSHOT".equals( resourceVersion );
+ boolean bootstrap = "BOOTSTRAP".equals( resourceVersion );
+ boolean validation = resource.getBooleanProperty(
"project.validation.enabled", false );
+ boolean validate = !snapshot && !bootstrap && validation;
+
+ checkTypeProduction( resource );
+ installTypes( resource );
+
+ /*
final File deliverables =
getContext().getTargetDeliverablesDirectory();
for( int i=0; i < types.length; i++ )
{
Type type = types[i];
- checkType( resource, type, validate );
+ if( !type.getTest() )
+ {
+ checkType( resource, type, validate );
+ }
}
-
- if( deliverables.exists() )
+ */
+
+ //if( deliverables.exists() )
+ //{
+ // log( "Installing deliverables from [" + deliverables + "]",
Project.MSG_VERBOSE );
+ // final File cache = (File) getProject().getReference(
"dpml.cache" );
+ // log( "To cache dir [" + cache + "]", Project.MSG_VERBOSE );
+ // try
+ // {
+ // final FileSet fileset = new FileSet();
+ // fileset.setProject( getProject() );
+ // fileset.setDir( deliverables );
+ // fileset.createInclude().setName( "**/*" );
+ // Module parent = resource.getParent();
+ // if( null == parent )
+ // {
+ // copy( cache, fileset, true );
+ // }
+ // else
+ // {
+ // final String group = parent.getResourcePath();
+ // final File destination = new File( cache, group );
+ // copy( destination, fileset, true );
+ // }
+ // }
+ // catch( Throwable e )
+ // {
+ // final String error =
+ // "Unexpected error while constructing ant fileset."
+ // + "\nDeliverables dir: " + deliverables;
+ // throw new BuildException( error, e );
+ // }
+ //}
+ }
+
+ private void installTypes( Resource resource )
+ {
+ Type[] types = resource.getTypes();
+ for( Type type : types )
{
- log( "Installing deliverables from [" + deliverables + "]",
Project.MSG_VERBOSE );
- final File cache = (File) getProject().getReference(
"dpml.cache" );
- log( "To cache dir [" + cache + "]", Project.MSG_VERBOSE );
+ if( !type.getTest() )
+ {
+ installType( resource, type );
+ }
+ }
+ }
+
+ private void installType( Resource resource, Type type )
+ {
+ File local = type.getFile( true );
+ File cached = type.getFile( false );
+ log( "installing " + type.getCompoundName() + " to " + cached );
+ File parent = cached.getParentFile();
+ if( null != parent )
+ {
+ parent.mkdirs();
+ }
+
+ final Copy copy = (Copy) getProject().createTask( "copy" );
+ copy.setTaskName( "install" );
+ copy.setFile( local );
+ copy.setTofile( cached );
+ copy.setFiltering( false );
+ copy.setOverwrite( true );
+ copy.setPreserveLastModified( true );
+ copy.init();
+ copy.execute();
+
+ // take care of alias production
+
+ if( type.getAliasProduction() )
+ {
+ String id = type.getID();
try
{
- final FileSet fileset = new FileSet();
- fileset.setProject( getProject() );
- fileset.setDir( deliverables );
- fileset.createInclude().setName( "**/*" );
- Module parent = resource.getParent();
- if( null == parent )
+ Artifact artifact = type.getArtifact();
+ String uri = artifact.toURI().toASCIIString();
+ String link = type.getName() + "." + id + ".link";
+ File group = type.getFile( true ).getParentFile();
+ File out = new File( group, link );
+
+ boolean flag = true;
+ if( out.exists() )
{
- copy( cache, fileset, true );
+ LinkManager manager =
Transit.getInstance().getLinkManager();
+ URI enclosed = manager.getTargetURI( out.toURI() );
+ if( artifact.toURI().equals( enclosed ) )
+ {
+ flag = false;
+ }
}
- else
+
+ if( flag )
{
- final String group = parent.getResourcePath();
- final File destination = new File( cache, group );
- copy( destination, fileset, true );
+ log( "creating " + type.getID() + " alias" );
+ //final String message =
+ // link.toString()
+ // + "\n target: "
+ // + uri.toString();
+ //log( message, Project.MSG_VERBOSE );
+ out.createNewFile();
+ final OutputStream output = new FileOutputStream( out );
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( uri );
+ writer.close();
+ output.close();
+
}
+
+ final Copy cc = (Copy) getProject().createTask( "copy" );
+ cc.setTaskName( "install" );
+ cc.setFile( out );
+ File cache = Transit.getInstance().getCacheDirectory();
+ Layout layout = Transit.getInstance().getCacheLayout();
+ Artifact linkArtifact = type.getLinkArtifact();
+ String layoutPath = layout.resolvePath( linkArtifact );
+ File cachedLink = new File( cache, layoutPath );
+ cc.setTofile( cachedLink );
+ log( "installing " + type.getID() + " alias to " +
cachedLink );
+ cc.setFiltering( false );
+ cc.setOverwrite( true );
+ cc.setPreserveLastModified( true );
+ cc.init();
+ cc.execute();
}
- catch( Throwable e )
+ catch( Exception e )
{
final String error =
- "Unexpected error while constructing ant fileset."
- + "\nDeliverables dir: " + deliverables;
- throw new BuildException( error, e );
+ "Internal error while attempting to create a link for the
resource type ["
+ + id
+ + "] in project ["
+ + resource
+ + "].";
+ throw new BuildException( error, e, getLocation() );
}
}
}
+ private void checkTypeProduction( Resource resource )
+ {
+ Type[] types = resource.getTypes();
+ for( Type type : types )
+ {
+ if( !type.getTest() )
+ {
+ boolean exists = checkTypeProduction( resource, type );
+ if( !exists )
+ {
+ final String error =
+ "Project ["
+ + resource
+ + "] declares that it produces the resource type ["
+ + type.getCompoundName()
+ + "] however no artifacts of that type are present in
the target directory.";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+ }
+ }
+
+ private boolean checkTypeProduction( Resource resource, Type type )
+ {
+ File local = type.getFile( true );
+ return local.exists();
+ }
+
+ /*
private void checkType( Resource resource, Type type, boolean validate )
{
//
@@ -143,25 +289,27 @@
// install process.
//
- Version version = type.getVersion();
- if( null != version )
+ if( type.getAliasProduction() )
{
+ Version version = type.getTypeVersion();
try
{
- Artifact artifact = resource.getArtifact( id );
+ Artifact artifact = resource.getArtifact( type, false );
String uri = artifact.toURI().toASCIIString();
String link = null;
- if( Version.NULL_VERSION.equals( version ) )
+ //if( Version.NULL_VERSION.equals( version ) )
+ if( null == version )
{
- link = resource.getName() + "." + id + ".link";
+ link = resource.getName( type ) + "." + id + ".link";
}
else
{
- link = resource.getName()
+ link = resource.getName( type )
+ "-"
- + version.getMajor()
- + "."
- + version.getMinor()
+ + version.toString()
+ //+ version.getMajor()
+ //+ "."
+ //+ version.getMinor()
+ "."
+ id + ".link";
}
@@ -169,7 +317,7 @@
boolean flag = true;
if( out.exists() )
{
- ArtifactLinkManager manager = new ArtifactLinkManager();
+ LinkManager manager =
Transit.getInstance().getLinkManager();
URI enclosed = manager.getTargetURI( out.toURI() );
if( artifact.toURI().equals( enclosed ) )
{
@@ -209,19 +357,19 @@
validateType( resource, type, target );
}
}
+ */
private void validateType( Resource resource, Type type, File target )
{
- String id = type.getID();
try
{
- Artifact artifact = resource.getArtifact( id );
+ Artifact artifact = type.getResolvedArtifact();
URL url = artifact.toURL();
File file = (File) url.getContent( new Class[]{File.class} );
if( file.exists() )
{
log( "validating " + target.getName() );
- compare( file, target, id );
+ compare( file, target, type );
}
}
catch( ArtifactNotFoundException anfe )
@@ -231,19 +379,20 @@
catch( IOException ioe )
{
final String error =
- "IO error while attempting to cross-check resource type: " + id
+ "IO error while attempting to cross-check resource type: "
+ + type
+ "\n" + ioe.toString();
- throw new BuildException( error, ioe, getLocation() );
+ throw new BuilderError( error, ioe, getLocation() );
}
}
- private void compare( File old, File target, String id )
+ private void compare( File old, File target, Type type )
{
String oldValue = getChecksum( old );
String newValue = getChecksum( target );
if( !oldValue.equals( newValue ) )
{
- String path = getContext().getLayoutFilename( id );
+ String path = getContext().getLayoutFilename( type );
final String error =
"A versioned resource created in this build has a different
MD5 signature "
+ "compared to an existing resource of the same name in the
cache directory. "
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/JUnitTestTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/JUnitTestTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/JUnitTestTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
import java.io.IOException;
@@ -27,14 +27,14 @@
import java.util.Properties;
import java.util.StringTokenizer;
-import net.dpml.library.Type;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Type;
+import dpml.library.Resource;
+import dpml.library.Scope;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import net.dpml.transit.Transit;
-import net.dpml.util.PropertyResolver;
+import dpml.util.PropertyResolver;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -153,8 +153,8 @@
private static final String TEST_ENV_VALUE = "env";
private static final boolean DEBUG_VALUE = true;
private static final boolean FORK_VALUE = true;
- private static final boolean HALT_ON_ERROR_VALUE = false;
- private static final boolean HALT_ON_FAILURE_VALUE = false;
+ private static final boolean HALT_ON_ERROR_VALUE = true;
+ private static final boolean HALT_ON_FAILURE_VALUE = true;
private File m_source;
private String m_classPathRef;
@@ -277,11 +277,12 @@
final FileSet fileset = createFileSet( src );
final JUnitTask junit = (JUnitTask) project.createTask( "junit" );
junit.setTaskName( getTaskName() );
+ junit.setOutputToFormatters( true );
final JUnitTask.SummaryAttribute summary = getSummaryAttribute();
junit.setPrintsummary( summary );
- junit.setShowOutput( true );
+ junit.setShowOutput( true);
junit.setTempdir( working );
junit.setReloading( true );
junit.setFiltertrace( true );
@@ -300,9 +301,28 @@
mkDir( reports );
final BatchTest batch = junit.createBatchTest();
+ batch.setFork( getForkProperty() );
batch.addFileSet( fileset );
batch.setTodir( reports );
+ junit.setErrorProperty( ERROR_KEY );
+ junit.setFailureProperty( FAILURE_KEY );
+ batch.setErrorProperty( ERROR_KEY );
+ batch.setFailureProperty( FAILURE_KEY );
+
+ final boolean haltOnErrorPolicy = getHaltOnErrorPolicy();
+ if( haltOnErrorPolicy )
+ {
+ junit.setHaltonerror( true );
+ batch.setHaltonerror( true );
+ }
+ final boolean haltOnFailurePolicy = getHaltOnFailurePolicy();
+ if( haltOnFailurePolicy )
+ {
+ junit.setHaltonfailure( true );
+ batch.setHaltonfailure( true );
+ }
+
final FormatterElement plain = newConfiguredFormatter( "plain" );
junit.addFormatter( plain );
@@ -383,7 +403,7 @@
logging.setKey( "java.util.logging.config.class" );
if( "dpml".equals( formatter ) )
{
- logging.setValue( "net.dpml.util.ConfigurationHandler" );
+ logging.setValue( "dpml.util.ConfigurationHandler" );
}
else
{
@@ -394,31 +414,19 @@
final Environment.Variable endorsed = new Environment.Variable();
endorsed.setKey( "java.endorsed.dirs" );
- endorsed.setValue( new File( Transit.DPML_SYSTEM, "lib/endorsed"
).getAbsolutePath() );
+ endorsed.setValue( new File( Transit.SYSTEM, "lib/endorsed"
).getAbsolutePath() );
junit.addConfiguredSysproperty( endorsed );
configureDeliverableSysProperties( junit );
configureForExecution( junit );
- junit.setErrorProperty( ERROR_KEY );
- junit.setFailureProperty( FAILURE_KEY );
- final boolean haltOnErrorPolicy = getHaltOnErrorPolicy();
- if( haltOnErrorPolicy )
- {
- junit.setHaltonerror( true );
- }
- final boolean haltOnFailurePolicy = getHaltOnFailurePolicy();
- if( haltOnFailurePolicy )
- {
- junit.setHaltonfailure( true );
- }
-
junit.init();
junit.execute();
}
private void setupTestProperties( JUnitTask junit, Project project, File
working )
{
+ Resource resource = getResource();
File base = project.getBaseDir();
final File properties = new File( base, "test.properties" );
if( properties.exists() )
@@ -429,8 +437,10 @@
props.setProperty( "project.test.dir",
working.getCanonicalPath() );
InputStream input = new FileInputStream( properties );
props.load( input );
+ Properties system = System.getProperties();
+ props = PropertyResolver.resolve( system, props );
+ props = resource.resolveProperties( props );
Enumeration enumeration = props.propertyNames();
- props = PropertyResolver.resolve( props );
while( enumeration.hasMoreElements() )
{
String name = (String) enumeration.nextElement();
@@ -457,7 +467,8 @@
{
task.setFork( true );
Project project = getProject();
- task.setDir( project.getBaseDir() );
+ File basedir = getResource().getBaseDir();
+ task.setDir( basedir );
JUnitTask.ForkMode mode = getForkMode();
if( null == mode )
{
@@ -494,7 +505,7 @@
{
Type type = types[i];
String id = type.getID();
- File file = context.getTargetDeliverable( id );
+ File file = type.getFile( true );
String path = file.getCanonicalPath();
final Environment.Variable variable = new
Environment.Variable();
variable.setKey( "project.deliverable." + id + ".path" );
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/JarTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/JarTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/JarTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,14 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
import net.dpml.lang.Version;
-import net.dpml.library.Resource;
-import net.dpml.library.Type;
+import dpml.library.Resource;
+import dpml.library.Type;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Jar;
@@ -129,13 +129,23 @@
return;
}
File jar = createJarFile( source );
- checksum( jar );
- asc( jar );
+ Resource resource = getResource();
+ Type type = resource.getType( "jar" );
+ if( !type.getTest() )
+ {
+ checksum( jar );
+ asc( jar );
+ }
}
private File createJarFile( final File classes )
{
final File temp = getTempFile();
+ final File tempdir = temp.getParentFile();
+ if( null != tempdir )
+ {
+ mkDir( tempdir );
+ }
final Jar jar = (Jar) getProject().createTask( "jar" );
jar.setTaskName( getTaskName() );
@@ -148,8 +158,10 @@
File dest = getDestination();
final File dir = dest.getParentFile();
- mkDir( dir );
-
+ if( null != dir )
+ {
+ mkDir( dir );
+ }
final Copy copy = (Copy) getProject().createTask( "copy" );
copy.setTaskName( getTaskName() );
copy.setFile( temp );
@@ -162,15 +174,18 @@
private File getTempFile()
{
- final File target = getContext().getTargetDirectory();
+ final File temp = getContext().getTargetTempDirectory();
final String path = getTempFilename();
- return new File( target, path );
+ return new File( temp, path );
}
private String getTempFilename()
{
Resource resource = getResource();
- String name = resource.getName();
+ Type type = resource.getType( "jar" );
+ String name = type.getName();
+ return name + "." + type.getID();
+ /*
Version version = resource.getDecimalVersion();
if( null != version )
{
@@ -181,6 +196,7 @@
String spec = resource.getVersion();
return name + "-" + spec + ".jar";
}
+ */
}
private Type getType()
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/JavacTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/JavacTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/JavacTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,14 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
-import net.dpml.library.Resource;
-import net.dpml.library.info.Scope;
+import dpml.library.Resource;
+import dpml.library.Scope;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -81,8 +81,8 @@
private static final boolean DEBUG_VALUE = true;
private static final boolean FORK_VALUE = false;
private static final boolean DEPRECATION_VALUE = true;
- private static final String SOURCE_VALUE = "1.4";
- private static final String TARGET_VALUE = "1.4";
+ //private static final String SOURCE_VALUE = "1.4";
+ //private static final String TARGET_VALUE = "1.4";
private final Context m_context;
@@ -181,7 +181,7 @@
javac.setTaskName( getTaskName() );
javac.setIncludeantruntime( false );
String lint = getProperty( "project.javac.lint", null );
- if( null != lint )
+ if( ( null != lint ) && !"".equals( lint ) )
{
javac.createCompilerArg().setValue( "-Xlint:" + lint );
}
@@ -205,8 +205,14 @@
javac.setDeprecation( getDeprecationProperty() );
javac.setDebug( getDebugProperty() );
javac.setFork( getForkProperty() );
- javac.setSource( getSourceProperty() );
- javac.setTarget( getTargetProperty() );
+ if( null != getSourceProperty() )
+ {
+ javac.setSource( getSourceProperty() );
+ }
+ if( null != getTargetProperty() )
+ {
+ javac.setTarget( getTargetProperty() );
+ }
javac.setClasspath( classpath );
javac.init();
javac.execute();
@@ -250,12 +256,12 @@
private String getSourceProperty()
{
- return getProperty( SOURCE_KEY, SOURCE_VALUE );
+ return getProperty( SOURCE_KEY, null );
}
private String getTargetProperty()
{
- return getProperty( TARGET_KEY, TARGET_VALUE );
+ return getProperty( TARGET_KEY, null );
}
private boolean getBooleanProperty( final String key, final boolean
fallback )
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/JavadocTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/JavadocTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/JavadocTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 Stephen McConnell
+ * Copyright 2004-2007 Stephen McConnell
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,17 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.build.BuildError;
+
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import net.dpml.library.info.Scope;
-import net.dpml.library.Resource;
+import dpml.library.Scope;
+import dpml.library.Resource;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -56,17 +59,24 @@
*/
public static final String JAVADOC_LINK_SOURCE_KEY =
"project.javadoc.linksource";
+ /**
+ * Property key for declaration of excluded packages.
+ */
+ public static final String JAVADOC_EXCLUDES = "project.javadoc.excludes";
+
//-----------------------------------------------------------------------
// state
//-----------------------------------------------------------------------
private String m_title;
- private List m_links = new ArrayList();
- private List m_groups = new ArrayList();
+ private String m_windowTitle;
+ private List<Link> m_links = new ArrayList<Link>();
+ private List<Group> m_groups = new ArrayList<Group>();
private File m_overview;
private AccessType m_access;
private File m_dest;
-
+ private List<Javadoc.PackageName> m_excludes = new
ArrayList<Javadoc.PackageName>();
+
//-----------------------------------------------------------------------
// JavadocTask
//-----------------------------------------------------------------------
@@ -93,6 +103,15 @@
}
/**
+ * Set the javadoc window title.
+ * @param title the title
+ */
+ public void setWindowtitle( final String title )
+ {
+ m_windowTitle = title;
+ }
+
+ /**
* Set the javadoc overview file.
* @param overview the overview file
*/
@@ -141,19 +160,25 @@
m_access = access;
}
+ public Javadoc.PackageName createExclude()
+ {
+ Javadoc.PackageName packageName = new Javadoc.PackageName();
+ m_excludes.add( packageName );
+ return packageName;
+ }
+
//-----------------------------------------------------------------------
// Task
//-----------------------------------------------------------------------
/**
* Task execution.
- * @exception BuildException if a build error occurs
*/
- public void execute() throws BuildException
+ public void execute()
{
final Resource resource = getResource();
- log( "Generating javadoc for project: " + resource,
Project.MSG_VERBOSE );
+ log( "Generating javadoc for project: " + resource );
File api = getDestination();
mkDir( api );
@@ -164,8 +189,21 @@
//
Resource[] providers = resource.getClasspathProviders( Scope.RUNTIME
);
- final Path classpath = getContext().createPath( providers, true,
true );
- process( resource, classpath, api );
+ try
+ {
+ final Path classpath = getContext().createPath( providers, true,
true );
+ process( resource, classpath, api );
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "Unable to resolve the runtime classpath for the resource ["
+ + resource.getResourcePath()
+ + "] ("
+ + resource.getBaseDir()
+ + ").";
+ throw new BuildError( error, ioe );
+ }
}
private File getDestination()
@@ -186,7 +224,7 @@
private Group[] getGroups()
{
- return (Group[]) m_groups.toArray( new Group[0] );
+ return m_groups.toArray( new Group[0] );
}
private void process(
@@ -201,6 +239,18 @@
javadoc.setUse( true );
javadoc.createClasspath().add( classpath );
+ String excludes = getPackageExcludes();
+ if( null != excludes )
+ {
+ javadoc.setExcludePackageNames( excludes );
+ }
+
+ Javadoc.PackageName[] excludesList = m_excludes.toArray( new
Javadoc.PackageName[0] );
+ for( Javadoc.PackageName exclude : excludesList )
+ {
+ javadoc.addExcludePackage( exclude );
+ }
+
final Path source = javadoc.createSourcepath();
addSourcePath( resource, javadoc, source );
@@ -222,7 +272,7 @@
}
aggregateLinks( javadoc, resource );
- Link[] links = (Link[]) m_links.toArray( new Link[0] );
+ Link[] links = m_links.toArray( new Link[0] );
for( int i=0; i<links.length; i++ )
{
Link link = links[i];
@@ -232,9 +282,18 @@
arg.setHref( href );
}
+ final String title = resource.getName() + " API";
+ if( null != m_windowTitle )
+ {
+ javadoc.setWindowtitle( m_windowTitle );
+ }
+ else
+ {
+ javadoc.setWindowtitle( title );
+ }
+
if( null == m_title )
{
- final String title = resource.getName() + " API";
javadoc.setDoctitle( title );
}
else
@@ -286,9 +345,17 @@
}
}
}
+
+ private String getPackageExcludes()
+ {
+ Resource resource = getResource();
+ return getProperty( JAVADOC_EXCLUDES, null );
+ }
private void addSourcePath( Resource resource, Javadoc javadoc, Path
source )
{
+ String excludes = getPackageExcludes();
+
//
// check for a classic src directory
//
@@ -303,6 +370,10 @@
final DirSet packages = new DirSet();
packages.setDir( src );
packages.setIncludes( "**/*" );
+ if( null != excludes )
+ {
+ packages.setExcludes( excludes );
+ }
javadoc.addPackageset( packages );
}
}
@@ -328,6 +399,11 @@
final DirSet packages = new DirSet();
packages.setDir( src );
packages.setIncludes( "**/**" );
+ //String excludes = getPackageExcludes( provider
);
+ if( null != excludes )
+ {
+ packages.setExcludes( excludes );
+ }
javadoc.addPackageset( packages );
}
}
@@ -389,7 +465,7 @@
public static class Group
{
private String m_title;
- private ArrayList m_packages = new ArrayList();
+ private ArrayList<Group.Package> m_packages = new
ArrayList<Group.Package>();
/**
* Set the package group title.
@@ -424,7 +500,7 @@
*/
public Group.Package[] getPackages()
{
- return (Group.Package[]) m_packages.toArray( new
Group.Package[0] );
+ return m_packages.toArray( new Group.Package[0] );
}
/**
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/ModuleTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/ModuleTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/ModuleTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,18 +16,19 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
import java.io.FileOutputStream;
-import net.dpml.library.Resource;
-import net.dpml.library.Module;
-import net.dpml.library.info.Scope;
-import net.dpml.library.info.ModuleDirective;
-import net.dpml.library.info.LibraryEncoder;
+import dpml.library.Resource;
+import dpml.library.Module;
+import dpml.library.Scope;
+import dpml.library.Type;
+import dpml.library.info.ModuleDirective;
+import dpml.library.info.LibraryEncoder;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -60,10 +61,9 @@
{
Project project = getProject();
final Context context = getContext();
- final String path = context.getLayoutFilename( "module" );
- final File deliverables = context.getTargetDeliverablesDirectory();
- final File modules = new File( deliverables, "modules" );
- final File module = new File( modules, path );
+ Resource resource = getResource();
+ Type type = resource.getType( "module" );
+ File module = type.getFile( true );
writeModuleFile( module );
}
@@ -73,8 +73,34 @@
if( resource instanceof Module )
{
Module module = (Module) resource;
- ModuleDirective directive = (ModuleDirective) module.export();
- writeModuleDirective( directive, file );
+ FileOutputStream output = null;
+ try
+ {
+ log( "Exporting module to: " + file );
+ final LibraryEncoder encoder = new LibraryEncoder();
+ file.getParentFile().mkdirs();
+ output = new FileOutputStream( file );
+ module.export( output );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Failed to export module.";
+ throw new BuildException( error, e, getLocation() );
+ }
+ finally
+ {
+ if( null != output )
+ {
+ try
+ {
+ output.close();
+ }
+ catch( Exception ioe )
+ {
+ }
+ }
+ }
}
else
{
@@ -83,36 +109,4 @@
throw new BuildException( error, getLocation() );
}
}
-
- private void writeModuleDirective( ModuleDirective directive, File file )
- {
- FileOutputStream output = null;
- try
- {
- log( "Exporting module to: " + file );
- final LibraryEncoder encoder = new LibraryEncoder();
- file.getParentFile().mkdirs();
- output = new FileOutputStream( file );
- encoder.export( directive, output );
- }
- catch( Exception e )
- {
- final String error =
- "Failed to export module.";
- throw new BuildException( error, e, getLocation() );
- }
- finally
- {
- if( null != output )
- {
- try
- {
- output.close();
- }
- catch( Exception ioe )
- {
- }
- }
- }
- }
}
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/PackageTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/PackageTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/PackageTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,18 +16,45 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.lang.Classpath;
+import dpml.lang.Info;
+import dpml.lang.Part;
+import dpml.lang.DOM3DocumentBuilder;
+
+import dpml.tools.Context;
+import dpml.tools.BuilderError;
+
import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.util.List;
+import java.util.ArrayList;
-import net.dpml.library.Resource;
+import dpml.util.Category;
+import net.dpml.lang.Strategy;
+import net.dpml.lang.StrategyHandler;
+import net.dpml.lang.PartContentHandler;
-import net.dpml.tools.Context;
-import net.dpml.tools.BuildError;
+import dpml.library.Resource;
+import dpml.library.Type;
+import dpml.library.Scope;
+import net.dpml.transit.Artifact;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Mkdir;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
/**
* Cleanup of generated target directory.
*
@@ -36,6 +63,8 @@
*/
public class PackageTask extends GenericTask
{
+ private static final DOM3DocumentBuilder BUILDER = new
DOM3DocumentBuilder();
+
/**
* Compiles main and test classes resulting in the creation of the
* target/classes/main and target/classes/test directories.
@@ -46,6 +75,13 @@
Project project = context.getProject();
Resource resource = context.getResource();
+ Type[] types = resource.getTypes();
+ for( Type type : types )
+ {
+ build( project, context, resource, type );
+ }
+
+ /*
// handle jar file packaging
if( resource.isa( "jar" ) )
@@ -87,7 +123,7 @@
"Unexpected failure during part externalization in ["
+ resource.getName()
+ "]";
- throw new BuildError( error, e, getLocation() );
+ throw new BuilderError( error, e, getLocation() );
}
}
@@ -101,14 +137,295 @@
task.init();
task.execute();
}
+ */
}
- private File getJarFile( Context context )
+ private void build( Project project, Context context, Resource resource,
Type type )
{
- Project project = context.getProject();
- File deliverables = context.getTargetDeliverablesDirectory();
- File jars = new File( deliverables, "jars" );
- String filename = context.getLayoutFilename( "jar" );
- return new File( jars, filename );
+ String id = type.getID();
+ if( "jar".equals( id ) )
+ {
+ File base = context.getTargetClassesMainDirectory();
+ if( base.exists() )
+ {
+ final File jar = type.getFile( true );
+ final JarTask task = new JarTask();
+ task.setProject( project );
+ task.setTaskName( "jar" );
+ task.setSrc( base );
+ task.setDest( jar );
+ task.init();
+ task.execute();
+ }
+ }
+ else if( "part".equals( id ) )
+ {
+ buildPart( project, context, resource, type );
+ }
+ else if( "module".equals( id ) )
+ {
+ final ModuleTask task = new ModuleTask();
+ task.setProject( project );
+ task.setTaskName( "module" );
+ task.init();
+ task.execute();
+ }
+ else if( null != type.getSource() )
+ {
+ buildByCopy( type );
+ }
}
+
+ private void buildByCopy( Type type )
+ {
+ log( "Copying [" + type.getName() + "#" + type.getID() + "] to
deliverables" );
+
+ String path = type.getSource();
+ Resource resource = type.getResource();
+ File base = resource.getBaseDir();
+ File source = new File( base, path );
+ File file = type.getFile( true );
+ File dir = file.getParentFile();
+ if( null != dir )
+ {
+ dir.mkdirs();
+ }
+
+ boolean flag = type.getBooleanProperty(
"project.package.include-in-classes", false );
+ if( flag )
+ {
+ String group = getGroup( resource );
+ String filename = type.getName() + "." + type.getID();
+ File ddir = new File( base, "target/classes/main" );
+ File root = new File( ddir, group );
+ root.mkdirs();
+ File destination = new File( root, filename );
+ final Copy ccopy = (Copy) getProject().createTask( "copy" );
+ ccopy.setTaskName( getTaskName() );
+ ccopy.setFile( source );
+ ccopy.setTofile( destination );
+ ccopy.init();
+ ccopy.execute();
+ }
+
+ final Copy copy = (Copy) getProject().createTask( "copy" );
+ copy.setTaskName( getTaskName() );
+ copy.setFile( source );
+ copy.setTofile( file );
+ copy.init();
+ copy.execute();
+ }
+
+ private String getGroup( Resource resource )
+ {
+ Resource parent = resource.getParent();
+ if( null == parent )
+ {
+ return null;
+ }
+ else
+ {
+ return parent.getResourcePath();
+ }
+ }
+
+ private void buildPart( Project project, Context context, Resource
resource, Type type )
+ {
+ String source = type.getSource();
+ if( null == source )
+ {
+ final String error =
+ "Missing source declaration in part type production statement.
["
+ + resource.getName()
+ + "]";
+ throw new BuilderError( error, null, getLocation() );
+ }
+ else
+ {
+ String resolved = resource.resolve( source );
+ log( "Creating part: " + resolved );
+ File basedir = resource.getBaseDir();
+ File input = new File( basedir, resolved );
+ if( !input.exists() )
+ {
+ final String error =
+ "Part input not found."
+ + "\nPath: " + source
+ + "\nExpanded: " + resolved
+ + "\nFile: " + input.getAbsolutePath();
+ throw new BuilderError( error, null, getLocation() );
+ }
+ else
+ {
+ OutputStream output = null;
+ try
+ {
+
+ Info info = getInfo( resource );
+ Classpath classpath = getClasspath( resource,
type.getTest() );
+ URI uri = input.toURI();
+ final Document document = BUILDER.parse( uri );
+ final Element root = document.getDocumentElement();
+ StrategyHandler handler =
PartContentHandler.getStrategyHandler( root );
+
+ ClassLoader parent = ClassLoader.getSystemClassLoader();
+ ClassLoader classloader = getRuntimeClassLoader( parent,
resource );
+ Strategy strategy = handler.build( classloader, root,
resource, null, null );
+ Part part = new Part( info, classpath, strategy );
+ File file = type.getFile( true );
+ File dir = file.getParentFile();
+ if( null != dir )
+ {
+ dir.mkdirs();
+ }
+ file.createNewFile();
+ output = new FileOutputStream( file );
+ part.save( output );
+ if( !type.getTest() )
+ {
+ checksum( file );
+ asc( file );
+ }
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to construct part deliverable: "
+ + "\nError: " + e.getClass().getName()
+ + "\nCause: " + e.getCause()
+ + "\nMessage: " + e.getMessage();
+ throw new BuilderError( error, e, getLocation() );
+ }
+ finally
+ {
+ if( null != output )
+ {
+ try
+ {
+ output.close();
+ }
+ catch( IOException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private Info getInfo( Resource resource )
+ {
+ Type type = resource.getType( "part" );
+ Artifact artifact = type.getArtifact();
+ URI uri = artifact.toURI();
+ String title = resource.getInfo().getTitle();
+ String description = resource.getInfo().getDescription();
+ return new Info( uri, title, description );
+ }
+
+ protected Classpath getClasspath( Resource resource, boolean test )
throws IOException
+ {
+ URI[] sysUris = getURIs( resource, Category.SYSTEM );
+ URI[] publicUris = getURIs( resource, Category.PUBLIC );
+ URI[] protectedUris = getURIs( resource, Category.PROTECTED );
+ URI[] privateUris = getURIs( resource, Category.PRIVATE, true, test
);
+ return new Classpath( sysUris, publicUris, protectedUris,
privateUris );
+ }
+
+ private URI[] getURIs( Resource resource, Category category ) throws
IOException
+ {
+ return getURIs( resource, category, false, false );
+ }
+
+ private URI[] getURIs( Resource resource, Category category, boolean
self, boolean test ) throws IOException
+ {
+ Resource[] resources = resource.getClasspathProviders( category );
+ ArrayList<URI> list = new ArrayList<URI>();
+ for( int i=0; i<resources.length; i++ )
+ {
+ Resource r = resources[i];
+ addURI( list, r );
+ }
+ if( self && resource.isa( "jar" ) )
+ {
+ addSelf( list, resource, test );
+ }
+ URI[] uris = list.toArray( new URI[0] );
+ return uris;
+ }
+
+ private void addURI( List<URI> list, Resource resource ) throws
IOException
+ {
+ addURI( list, resource, true );
+ }
+
+ private void addURI( List<URI> list, Resource resource, boolean resolve
) throws IOException
+ {
+ if( resource.isa( "jar" ) )
+ {
+ Type type = resource.getType( "jar" );
+ Artifact artifact = getArtifact( type, resolve );
+ URI uri = artifact.toURI();
+ list.add( uri );
+ }
+ }
+
+ private Artifact getArtifact( Type type, boolean resolve ) throws
IOException
+ {
+ if( resolve )
+ {
+ return type.getResolvedArtifact();
+ }
+ else
+ {
+ return type.getArtifact();
+ }
+ }
+
+ private void addSelf( List<URI> list, Resource resource, boolean test )
throws IOException
+ {
+ if( test )
+ {
+ try
+ {
+ Type type = resource.getType( "jar" );
+ File local = type.getFile( true );
+ list.add( local.toURI() );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while attempting to resolve resource.";
+ IOException ioe = new IOException( error );
+ ioe.initCause( e );
+ throw ioe;
+ }
+ }
+ else
+ {
+ addURI( list, resource, false );
+ }
+ }
+
+ ClassLoader getRuntimeClassLoader( ClassLoader parent, Resource resource
) throws Exception
+ {
+ boolean flag = resource.isa( "jar" );
+ ArrayList<URL> list = new ArrayList<URL>();
+ Resource[] providers = resource.getClasspathProviders( Scope.RUNTIME
);
+ for( Resource provider : providers )
+ {
+ Type type = provider.getType( "jar" );
+ URI uri = type.getResolvedArtifact().toURI();
+ list.add( Artifact.toURL( uri ) );
+ }
+ if( flag )
+ {
+ Type type = resource.getType( "jar" );
+ File local = type.getFile( true );
+ list.add( local.toURI().toURL() );
+ }
+ URL[] urls = list.toArray( new URL[0] );
+ return new URLClassLoader( urls, parent );
+ }
}
Deleted: trunk/main/depot/tools/src/main/dpml/tools/tasks/PartTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/PartTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/PartTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -1,321 +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.tasks;
-
-import java.io.File;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.dpml.lang.Classpath;
-import net.dpml.lang.Category;
-import net.dpml.lang.Info;
-import net.dpml.lang.Part;
-import net.dpml.lang.PartDecoder;
-
-import net.dpml.library.Type;
-import net.dpml.library.Resource;
-
-import net.dpml.transit.Artifact;
-
-import net.dpml.tools.Context;
-import net.dpml.tools.BuildError;
-
-import net.dpml.util.DefaultLogger;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-
-import org.w3c.dom.Element;
-
-/**
- * Creation of an part definition in XML.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PartTask extends GenericTask
-{
- /**
- * Constant artifact type for a plugin.
- */
- public static final String TYPE = "part";
-
- /**
- * Property key used to identify the plugin title.
- */
- public static final String PLUGIN_TITLE_KEY = "project.title";
-
- /**
- * Property key used to identify the plugin description.
- */
- public static final String PLUGIN_DESCRIPTION_KEY =
"project.description";
-
- /**
- * Property key used to identify a custom plugin handler classname.
- */
- public static final String PLUGIN_HANDLER_KEY = "project.plugin.handler";
-
- private boolean m_test = false;
-
- private File m_output;
-
- /**
- * Set the test build policy. The default is to include
- * the project artifact in the classpath of a created part, however - in
a
- * test scenario we don't want to do this. Setting test to true will
result
- * in the association of a local file uri to the project resource.
- *
- * @param test true if this is a local test part
- */
- public void setTest( boolean test )
- {
- m_test = test;
- }
-
- /**
- * Override the default output destination.
- *
- * @param file the overriding destination
- */
- public void setDest( File file )
- {
- m_output = file;
- }
-
- /**
- * Task execution.
- */
- public void execute()
- {
- Resource resource = getResource();
- Part part = build( resource );
- writePart( part );
- }
-
- /**
- * Externalize the part as a deliverable.
- * @param part the part to be externalized as XML
- */
- public void writePart( Part part )
- {
- File file = getOutputFile();
- if( file.exists() )
- {
- try
- {
- Part existing = Part.load( file.toURI(), false );
- if( part.equals( existing ) )
- {
- return;
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Part comparisom failure.";
- throw new BuildError( error, e );
- }
- }
-
- log( "Building part: " + file );
- try
- {
- file.createNewFile();
- final OutputStream output = new FileOutputStream( file );
- try
- {
- part.encode( output );
- checksum( file );
- asc( file );
- }
- finally
- {
- try
- {
- output.close();
- }
- catch( IOException e )
- {
- e.printStackTrace();
- }
- }
- }
- catch( Exception e )
- {
- final String error =
- "Part externalization error.";
- throw new BuildError( error, e );
- }
- }
-
- private File getOutputFile()
- {
- if( null != m_output )
- {
- return m_output;
- }
- else
- {
- Context context = getContext();
- final String path = context.getLayoutFilename( TYPE );
- final File deliverables =
context.getTargetDeliverablesDirectory();
- final File parts = new File( deliverables, TYPE + "s" );
- final File file = new File( parts, path );
- parts.mkdirs();
- return file;
- }
- }
-
- /**
- * Build the part definition.
- * @param resource the resource
- * @return the part
- */
- protected Part build( Resource resource )
- {
- try
- {
- Info info = getInfo( resource );
- Classpath classpath = getClasspath( resource );
- Type type = resource.getType( TYPE );
- Element element = type.getElement();
- PartDecoder decoder = PartDecoder.getInstance();
- DefaultLogger logger = new DefaultLogger( getTaskName() );
- return decoder.build( logger, info, classpath, element, resource
);
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to build an external part
definition."
- + "\nResource: " + resource;
- throw new BuildError( error, e, getLocation() );
- }
- }
-
- /**
- * Construct the info object based on properties declared by the
- * supplied resource.
- * @param resource the resource
- * @return the info descriptor
- */
- protected Info getInfo( Resource resource )
- {
- Artifact artifact = resource.getArtifact( TYPE );
- URI uri = artifact.toURI();
- String title = resource.getInfo().getTitle();
- String description = resource.getInfo().getDescription();
- return new Info( uri, title, description );
- }
-
- private String getTitle( Resource resource )
- {
- return resource.getProperty( PLUGIN_TITLE_KEY );
- }
-
- private String getDescription( Resource resource )
- {
- return resource.getProperty( PLUGIN_DESCRIPTION_KEY );
- }
-
- /**
- * Construct the classpath for the supplied resource.
- * @param resource the resource
- * @return the classpath
- * @exception IOException is an IO error occurs
- */
- protected Classpath getClasspath( Resource resource ) throws IOException
- {
- URI[] sysUris = getURIs( resource, Category.SYSTEM );
- URI[] publicUris = getURIs( resource, Category.PUBLIC );
- URI[] protectedUris = getURIs( resource, Category.PROTECTED );
- URI[] privateUris = getURIs( resource, Category.PRIVATE, true );
- return new Classpath( sysUris, publicUris, protectedUris,
privateUris );
- }
-
- private URI[] getURIs( Resource resource, Category category ) throws
IOException
- {
- return getURIs( resource, category, false );
- }
-
- private URI[] getURIs( Resource resource, Category category, boolean
self ) throws IOException
- {
- Resource[] resources = resource.getClasspathProviders( category );
- ArrayList list = new ArrayList();
- for( int i=0; i<resources.length; i++ )
- {
- Resource r = resources[i];
- addURI( list, r );
- }
- if( self )
- {
- addURI( list, resource );
- }
- URI[] uris = (URI[]) list.toArray( new URI[0] );
- return uris;
- }
-
- private void addURI( List list, Resource resource ) throws IOException
- {
- if( resource.isa( "jar" ) )
- {
- try
- {
- URI uri = toURI( resource );
- list.add( uri );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while attempting to resolve resource.";
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
- }
-
- private URI toURI( Resource resource ) throws Exception
- {
- if( m_test && resource.equals( getResource() ) )
- {
- File local = getContext().getTargetDeliverable( "jar" );
- return local.toURI();
- }
- else
- {
- return resource.getArtifact( "jar" ).toURI();
- }
- }
-
- /**
- * 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();
- return context;
- }
-}
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/PluginTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/PluginTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/PluginTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,15 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
-import net.dpml.library.Library;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
+import dpml.tools.BuilderError;
+import dpml.tools.Context;
-import net.dpml.tools.Context;
+import dpml.library.Library;
+import dpml.library.Resource;
+import dpml.library.Type;
+import dpml.library.ResourceNotFoundException;
import org.apache.tools.ant.BuildException;
@@ -33,7 +35,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class PluginTask extends net.dpml.transit.tools.PluginTask
+public class PluginTask extends dpml.tools.transit.PluginTask
{
private String m_ref;
@@ -59,7 +61,7 @@
* Task execution.
*/
public void execute()
- {
+ {
if( null != m_ref )
{
Context context = (Context) getProject().getReference(
"project.context" );
@@ -73,19 +75,20 @@
try
{
Resource resource = library.getResource( m_ref );
- String uri = resource.getArtifact( "plugin"
).toURI().toString();
+ Type type = resource.getType( "part" );
+ String uri =
type.getResolvedArtifact().toURI().toASCIIString();
setUri( uri );
}
catch( ResourceNotFoundException e )
{
String message = e.getMessage();
- throw new BuildException( message, e, getLocation() );
+ throw new BuilderError( message, e, getLocation() );
}
catch( Exception e )
{
final String error =
"Unexpected error while attempting to initiaze plugin task
uri.";
- throw new BuildException( error, e );
+ throw new BuilderError( error, e );
}
}
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/PrepareTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/PrepareTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/PrepareTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,14 +16,16 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.tools.Context;
+import dpml.tools.BuilderError;
+
import java.io.File;
+import java.io.IOException;
-import net.dpml.library.Resource;
+import dpml.library.Resource;
-import net.dpml.tools.Context;
-
import org.apache.tools.ant.Project;
@@ -82,8 +84,22 @@
final Project project = getProject();
Resource resource = getResource();
Context context = getContext();
- context.init();
+ try
+ {
+ context.init();
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "Context initialization failure for the resource ["
+ + resource
+ + "] ("
+ + resource.getBaseDir()
+ + ").";
+ throw new BuilderError( error, ioe );
+ }
+
log( "basedir: " + getResource().getBaseDir(), Project.MSG_VERBOSE );
//
@@ -179,7 +195,7 @@
context.getProperty( ETC_FILTERED_EXCLUDES_KEY,
ETC_FILTERED_EXCLUDES_VALUE );
//
- // copy ${etc}/test content to ${target}/build/test
+ // copy ${etc}/test content to ${target}/test
//
final File data = context.getEtcDataDirectory();
@@ -197,7 +213,7 @@
final File etc = context.getEtcDirectory();
//
- // ${etc}/* directories (excluding test, main and deliverables)
+ // ${etc}/* directories (excluding main, test, and data)
// directly to the target directory
//
Modified:
trunk/main/depot/tools/src/main/dpml/tools/tasks/ProcessorInstantiationException.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/tasks/ProcessorInstantiationException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/main/dpml/tools/tasks/ProcessorInstantiationException.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
/**
* A ProcessorInstantiationException if an occur occurs when attempting to
load
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/PropertyTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/PropertyTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/PropertyTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Property;
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/RMICTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/RMICTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/RMICTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,15 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
-import net.dpml.library.info.Scope;
+import dpml.library.Scope;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -43,32 +45,21 @@
*/
public class RMICTask extends GenericTask
{
- private final Context m_context;
- private String[] m_includes = new String[0];
- private String[] m_excludes = new String[0];
+ static
+ {
+ System.setProperty(
+ "com.sun.CORBA.ORBDynamicStubFactoryFactoryClass",
+
"com.sun.corba.se.impl.presentation.rmi.StubFactoryFactoryStaticImpl" );
+ }
+
+ private List<Include> m_includes = new ArrayList<Include>();
+ private List<Include> m_excludes = new ArrayList<Include>();
private String m_classPathRef;
private File m_base;
-
- /**
- * Creation of a new RMICTask.
- * @param context the project context
- */
- public RMICTask( Context context )
+
+ public RMICTask()
{
super();
- m_context = context;
- try
- {
- setProject( context.getProject() );
- setTaskName( "rmic" );
- setBase( context.getTargetClassesMainDirectory() );
- context.getPath( Scope.RUNTIME );
- setClasspathRef( "project.compile.path" );
- }
- catch( Exception e )
- {
- throw new BuildException( e );
- }
}
/**
@@ -87,24 +78,25 @@
public void setBase( File base )
{
m_base = base;
+ }
+
+ public Include createInclude()
+ {
+ Include include = new Include();
+ m_includes.add( include );
+ return include;
}
- /**
- * Set the includes.
- * @param includes the include paths
- */
- public void setIncludes( String[] includes )
+ public Include createExclude()
{
- m_includes = includes;
+ Include include = new Include();
+ m_excludes.add( include );
+ return include;
}
- /**
- * Set the excludes.
- * @param excludes the excluded paths
- */
- public void setExcludes( String[] excludes )
+ public void init()
{
- m_excludes = excludes;
+ setTaskName( "rmic" );
}
/**
@@ -112,11 +104,10 @@
*/
public void execute()
{
+ Context context = getContext();
if( null == m_base )
{
- final String error =
- "Missing 'base' argument.";
- throw new BuildException( error, getLocation() );
+ setBase( context.getTargetClassesMainDirectory() );
}
if( !m_base.exists() )
@@ -126,24 +117,25 @@
final Rmic rmic = (Rmic) getProject().createTask( "rmic" );
rmic.setTaskName( "rmic" );
- final Project project = m_context.getProject();
+ final Project project = getProject();
rmic.setProject( project );
rmic.setBase( m_base );
final Path classpath = getClasspath();
+
rmic.setClasspath( classpath );
// populate includes/excludes
- for( int i=0; i<m_includes.length; i++ )
+ for( Include include : m_includes )
{
- String include = m_includes[i];
- rmic.createInclude().setName( include );
+ String name = include.getName();
+ rmic.createInclude().setName( name );
}
- for( int i=0; i<m_excludes.length; i++ )
+ for( Include exclude : m_excludes )
{
- String exclude = m_excludes[i];
- rmic.createExclude().setName( exclude );
+ String name = exclude.getName();
+ rmic.createExclude().setName( name );
}
// initialize and execute
@@ -160,9 +152,24 @@
}
else
{
- final String error =
- "Missing 'classpathRef' attribute.";
- throw new BuildException( error, getLocation() );
+ getContext().getPath( Scope.RUNTIME );
+ setClasspathRef( "project.compile.path" );
+ return getClasspath();
}
}
+
+ public static class Include
+ {
+ private String m_name;
+
+ public void setName( String name )
+ {
+ m_name = name;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+ }
}
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/ReactorTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/ReactorTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/ReactorTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,17 +16,19 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import net.dpml.lang.SimpleServiceRegistry;
+import dpml.util.DefaultLogger;
+
import java.io.File;
-import net.dpml.library.Resource;
-import net.dpml.library.impl.DefaultLibrary;
-
-import net.dpml.tools.impl.StandardBuilder;
-
-import net.dpml.transit.monitor.LoggingAdapter;
-
+import net.dpml.lang.Strategy;
+import net.dpml.lang.ServiceRegistry;
+import dpml.build.Builder;
+import dpml.library.Resource;
+import dpml.library.impl.DefaultLibrary;
+import dpml.tools.impl.StandardBuilder;
import net.dpml.util.Logger;
import org.apache.tools.ant.BuildException;
@@ -64,7 +66,7 @@
return new String[0];
}
}
-
+
/**
* Execute the task.
*/
@@ -72,9 +74,9 @@
{
try
{
- Logger logger = new LoggingAdapter();
+ Logger logger = new DefaultLogger( "dpml.depot" );
DefaultLibrary library = new DefaultLibrary( logger );
- StandardBuilder builder = new StandardBuilder( logger, library,
false );
+ StandardBuilder builder = new StandardBuilder( logger, library,
new Boolean( false ) );
File basedir = getProject().getBaseDir().getCanonicalFile();
Resource[] resources = library.select( basedir, false );
log( "Reactive selection: " + resources.length );
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/ReplicateTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/ReplicateTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/ReplicateTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,19 +16,20 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
+import dpml.build.BuildError;
+
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import net.dpml.lang.UnknownKeyException;
+import dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
+import dpml.library.Type;
+import dpml.library.Scope;
-import net.dpml.library.Resource;
-import net.dpml.library.ResourceNotFoundException;
-import net.dpml.library.Type;
-import net.dpml.library.info.Scope;
-
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
import net.dpml.transit.Layout;
@@ -51,8 +52,9 @@
private boolean m_verbose = false;
private boolean m_self = false;
+ private boolean m_failOnError = true;
- private ArrayList m_includes = new ArrayList();
+ private ArrayList<Include> m_includes = new ArrayList<Include>();
/**
* Set the key of the target project or resource.
@@ -94,6 +96,15 @@
}
/**
+ * Set the fail on error policy.
+ * @param flag the fail on error policy
+ */
+ public void setFailonerror( boolean flag )
+ {
+ m_failOnError = flag;
+ }
+
+ /**
* Settting self to TRUE will result in expansion of the path to include
* the target resource.
* @param flag the self inclusion flag
@@ -136,7 +147,7 @@
File destination = m_todir;
Layout layout = resolveLayout();
- ArrayList list = new ArrayList();
+ ArrayList<Resource> list = new ArrayList<Resource>();
String ref = getRef();
if( null != ref )
{
@@ -148,7 +159,7 @@
// add nested includes
//
- Include[] includes = (Include[]) m_includes.toArray( new Include[0]
);
+ Include[] includes = m_includes.toArray( new Include[0] );
for( int i=0; i<includes.length; i++ )
{
Include include = includes[i];
@@ -161,7 +172,7 @@
// get sorted list of resources
//
- Resource[] resources = (Resource[]) list.toArray( new Resource[0] );
+ Resource[] resources = list.toArray( new Resource[0] );
Resource[] selection = getContext().getLibrary().sort( resources );
File cache = (File) getProject().getReference( "dpml.cache" );
for( int i=0; i<selection.length; i++ )
@@ -181,15 +192,48 @@
for( int j=0; j<types.length; j++ )
{
Type type = types[j];
- String id = type.getID();
-
- Artifact artifact = resource.getArtifact( id );
- copyArtifact( artifact, cache, destination, layout );
- if( null != type.getVersion() )
+ if( type.getTest() )
{
- Artifact link = resource.getLinkArtifact( id );
- copyArtifact( link, cache, destination, layout );
+ return;
}
+ try
+ {
+ Artifact artifact = type.getResolvedArtifact();
+ copyArtifact( artifact, cache, destination, layout );
+ if( type.getAliasProduction() )
+ {
+ Artifact link = type.getLinkArtifact();
+ copyArtifact( link, cache, destination, layout );
+ }
+ }
+ catch( IllegalStateException e )
+ {
+ if( m_failOnError )
+ {
+ throw e;
+ }
+ else
+ {
+ log( e.getMessage() );
+ }
+ }
+ catch( IOException e )
+ {
+ if( m_failOnError )
+ {
+ final String error =
+ "Replication failure for the ["
+ + type
+ + "] type in the resource ["
+ + resource
+ + "].";
+ throw new BuildError( error, e );
+ }
+ else
+ {
+ log( e.getMessage() );
+ }
+ }
}
}
@@ -243,28 +287,23 @@
}
else
{
- try
+ Layout layout = Layout.getLayout( m_layout );
+ if( null == layout )
{
- return Transit.getInstance().getLayout( m_layout );
- }
- catch( UnknownKeyException e )
- {
final String error =
"Target layout id ["
+ m_layout
+ "] is unknown.";
- throw new BuildException( error, e, getLocation() );
+ throw new BuildException( error, getLocation() );
}
- catch( Exception e )
+ else
{
- final String error =
- "Unexpected error while resolving layout: " + m_layout;
- throw new BuildException( error, e, getLocation() );
+ return layout;
}
}
}
- private void aggregate( List list, Resource resource, boolean self )
+ private void aggregate( List<Resource> list, Resource resource, boolean
self )
{
Resource[] resources = resource.getAggregatedProviders(
Scope.RUNTIME, true, false );
for( int i=0; i<resources.length; i++ )
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/ResourceTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/ResourceTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/ResourceTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,12 +16,12 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
-import net.dpml.library.ResourceNotFoundException;
-import net.dpml.library.Resource;
+import dpml.library.ResourceNotFoundException;
+import dpml.library.Resource;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.BuildException;
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/TestTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/TestTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/TestTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,13 +16,15 @@
* limitations under the License.
*/
-package net.dpml.tools.tasks;
+package dpml.tools.tasks;
import java.io.File;
-import net.dpml.library.info.Scope;
+import dpml.library.Resource;
+import dpml.library.Scope;
+import dpml.library.Type;
-import net.dpml.tools.Context;
+import dpml.tools.Context;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
@@ -47,16 +49,25 @@
if( src.exists() )
{
Path path = context.getPath( Scope.TEST );
- final File jar = getJarFile( context );
- if( jar.exists() )
+ Resource resource = getResource();
+ if( resource.isa( "jar" ) )
{
+ Type type = resource.getType( "jar" );
+ File jar = type.getFile( true );
path.createPathElement().setLocation( jar );
}
- else if( context.getTargetClassesMainDirectory().exists() )
- {
- File main = context.getTargetClassesMainDirectory();
- path.createPathElement().setLocation( main );
- }
+
+ //final File jar = getJarFile( context );
+ //if( jar.exists() )
+ //{
+ // path.createPathElement().setLocation( jar );
+ //}
+ //else if( context.getTargetClassesMainDirectory().exists() )
+ //{
+ // File main = context.getTargetClassesMainDirectory();
+ // path.createPathElement().setLocation( main );
+ //}
+
final File dest = context.getTargetClassesTestDirectory();
path.createPathElement().setLocation( dest );
final JUnitTestTask task = new JUnitTestTask();
@@ -69,12 +80,12 @@
}
}
- private File getJarFile( Context context )
- {
- Project project = context.getProject();
- File deliverables = context.getTargetDeliverablesDirectory();
- File jars = new File( deliverables, "jars" );
- String filename = context.getLayoutFilename( "jar" );
- return new File( jars, filename );
- }
+ //private File getJarFile( Context context )
+ //{
+ // Project project = context.getProject();
+ // File deliverables = context.getTargetDeliverablesDirectory();
+ // File jars = new File( deliverables, "jars" );
+ // String filename = context.getLayoutFilename( "jar" );
+ // return new File( jars, filename );
+ //}
}
Modified: trunk/main/depot/tools/src/main/dpml/tools/tasks/antlib.xml
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/antlib.xml
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/tasks/antlib.xml 2007-02-08
23:31:25 UTC (rev 1818)
@@ -1,26 +1,28 @@
<?xml version="1.0"?>
<antlib>
- <taskdef name="clean" classname="net.dpml.tools.tasks.CleanTask"/>
- <taskdef name="init"
classname="net.dpml.tools.tasks.InitializationTask"/>
- <taskdef name="prepare" classname="net.dpml.tools.tasks.PrepareTask"/>
- <taskdef name="build" classname="net.dpml.tools.tasks.BuildTask"/>
- <taskdef name="package" classname="net.dpml.tools.tasks.PackageTask"/>
- <taskdef name="test" classname="net.dpml.tools.tasks.TestTask"/>
- <taskdef name="install" classname="net.dpml.tools.tasks.InstallTask"/>
+ <taskdef name="clean" classname="dpml.tools.tasks.CleanTask"/>
+ <taskdef name="init"
classname="dpml.tools.tasks.InitializationTask"/>
+ <taskdef name="prepare" classname="dpml.tools.tasks.PrepareTask"/>
+ <taskdef name="build" classname="dpml.tools.tasks.BuildTask"/>
+ <taskdef name="package" classname="dpml.tools.tasks.PackageTask"/>
+ <taskdef name="test" classname="dpml.tools.tasks.TestTask"/>
+ <taskdef name="install" classname="dpml.tools.tasks.InstallTask"/>
- <taskdef name="jar" classname="net.dpml.tools.tasks.JarTask"/>
- <taskdef name="junit"
classname="net.dpml.tools.tasks.JUnitTestTask"/>
- <taskdef name="property"
classname="net.dpml.tools.tasks.PropertyTask"/>
- <taskdef name="filter" classname="net.dpml.tools.tasks.FilterTask"/>
- <taskdef name="module" classname="net.dpml.tools.tasks.ModuleTask"/>
- <taskdef name="reactor" classname="net.dpml.tools.tasks.ReactorTask"/>
- <taskdef name="plugin" classname="net.dpml.tools.tasks.PluginTask"/>
- <taskdef name="replicate"
classname="net.dpml.tools.tasks.ReplicateTask"/>
- <taskdef name="javadoc" classname="net.dpml.tools.tasks.JavadocTask"/>
- <taskdef name="docs" classname="net.dpml.tools.tasks.DocTask"/>
+ <taskdef name="jar" classname="dpml.tools.tasks.JarTask"/>
+ <taskdef name="junit" classname="dpml.tools.tasks.JUnitTestTask"/>
+ <taskdef name="property" classname="dpml.tools.tasks.PropertyTask"/>
+ <taskdef name="filter" classname="dpml.tools.tasks.FilterTask"/>
+ <taskdef name="module" classname="dpml.tools.tasks.ModuleTask"/>
+ <taskdef name="reactor" classname="dpml.tools.tasks.ReactorTask"/>
+ <taskdef name="plugin" classname="dpml.tools.tasks.PluginTask"/>
+ <taskdef name="replicate" classname="dpml.tools.tasks.ReplicateTask"/>
+ <taskdef name="javadoc" classname="dpml.tools.tasks.JavadocTask"/>
+ <taskdef name="docs" classname="dpml.tools.tasks.DocTask"/>
- <!--<taskdef name="javac"
classname="net.dpml.tools.tasks.JavacTask"/>-->
- <!--<taskdef name="export"
classname="net.dpml.tools.tasks.PluginExportTask"/>-->
+ <taskdef name="rmic" classname="dpml.tools.tasks.RMICTask"/>
+ <!--<taskdef name="javac"
classname="dpml.tools.tasks.JavacTask"/>-->
+ <!--<taskdef name="export"
classname="dpml.tools.tasks.PluginExportTask"/>-->
+
</antlib>
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/AntAdapter.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/AntAdapter.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/AntAdapter.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import dpml.util.ExceptionHelper;
+import net.dpml.util.Logger;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Project;
+
+/**
+ * A ant montor for download messages.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class AntAdapter implements Logger
+{
+ /**
+ * The ant task that this adapter is assigned to.
+ */
+ private Task m_task;
+
+ /**
+ * Creation of a new ant logging adapter.
+ * @param task the task establishing the adapter
+ */
+ public AntAdapter( Task task )
+ {
+ m_task = task;
+ }
+
+ /**
+ * Return TRUE is trace level logging is enabled.
+ * @return the enabled state of trace logging
+ */
+ public boolean isTraceEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Return TRUE is debug level logging is enabled.
+ * @return the enabled state of debug logging
+ */
+ public boolean isDebugEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Return TRUE is info level logging is enabled.
+ * @return the enabled state of info logging
+ */
+ public boolean isInfoEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Return TRUE is warn level logging is enabled.
+ * @return the enabled state of warn logging
+ */
+ public boolean isWarnEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Return TRUE is error level logging is enabled.
+ * @return the enabled state of error logging
+ */
+ public boolean isErrorEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Record a debug level message.
+ * @param message the debug message to record
+ */
+ public void debug( String message )
+ {
+ m_task.log( message, Project.MSG_VERBOSE );
+ }
+
+ /**
+ * Record a trace level message.
+ * @param message the trace message to record
+ */
+ public void trace( String message )
+ {
+ m_task.log( message, Project.MSG_VERBOSE );
+ }
+
+ /**
+ * Record a informative message.
+ * @param message the info message to record
+ */
+ public void info( String message )
+ {
+ m_task.log( message, Project.MSG_INFO );
+ }
+
+ /**
+ * Record a warning message.
+ * @param message the warning message to record
+ */
+ public void warn( String message )
+ {
+ m_task.log( message, Project.MSG_WARN );
+ }
+
+ /**
+ * Record a warning message.
+ * @param message the warning message to record
+ * @param cause the causal exception
+ */
+ public void warn( String message, Throwable cause )
+ {
+ m_task.log( message, Project.MSG_WARN );
+ if( null != cause )
+ {
+ final String error = ExceptionHelper.packException( message,
cause, true );
+ m_task.log( error, Project.MSG_WARN );
+ }
+ }
+
+ /**
+ * Record a error level message.
+ * @param message the error message to record
+ */
+ public void error( String message )
+ {
+ error( message, null );
+ }
+
+ /**
+ * Record a error level message.
+ * @param message the error message to record
+ * @param e the error
+ */
+ public void error( String message, Throwable e )
+ {
+ m_task.log( message, Project.MSG_ERR );
+ if( null != e )
+ {
+ final String error = ExceptionHelper.packException( message, e,
true );
+ m_task.log( error, Project.MSG_ERR );
+ }
+ }
+
+ /**
+ * Create a new subsidiary logging channel.
+ * @param category the channel name relative to this logging channel
+ * @return the new logging channel
+ */
+ public Logger getChildLogger( String category )
+ {
+ return this;
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/GetTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/GetTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/GetTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005 Stephen 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 dpml.tools.transit;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+import net.dpml.transit.Artifact;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The get task handles the retrival of a rresource and the binding of the
resource filename
+ * to a project property.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class GetTask extends TransitTask
+{
+ /**
+ * The uri of the artifact to load.
+ */
+ private String m_uri;
+
+ /**
+ * The name of a property under which the locally cached artifact
filename will be bound.
+ */
+ private String m_name;
+
+ /**
+ * Set the project.
+ * @param project the current project
+ */
+ public void setProject( Project project )
+ {
+ setTaskName( "get" );
+ super.setProject( project );
+ }
+
+ /**
+ * Set the artifact uri of the plugin from which the task is to be loaded.
+ * @param uri an artifact plugin uri
+ */
+ public void setUri( String uri )
+ {
+ m_uri = uri;
+ }
+
+ /**
+ * Set the name of a property into which the local file path will be
assigned.
+ * @param name the ant property name
+ */
+ public void setProperty( String name )
+ {
+ m_name = name;
+ }
+
+ /**
+ * Return the artifact uri of the plugin.
+ * @return the artifact uri
+ */
+ private URI getURI()
+ {
+ try
+ {
+ return new URI( m_uri.toString() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Cound not convert the supplied uri spec ["
+ + m_uri
+ + "] to a formal URI.";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+
+ /**
+ * Return the ant property name.
+ * @return the property name
+ */
+ private String getPropertyName()
+ {
+ if( null == m_name )
+ {
+ final String error =
+ "The required 'property' attribute is not declared.";
+ throw new BuildException( error, getLocation() );
+ }
+ else
+ {
+ return m_name;
+ }
+ }
+
+ /**
+ * Load the resource and assign the locally cached file path to the
supplied property name.
+ * @exception BuildException if an error occurs during resource resolution
+ */
+ public void execute() throws BuildException
+ {
+ if( null == m_uri )
+ {
+ final String error =
+ "Missing uri attribute.";
+ throw new BuildException( error, getLocation() );
+ }
+
+ String name = getPropertyName();
+
+ try
+ {
+ URI uri = getURI();
+ String spec = getURI().toString();
+ log( "artifact: " + spec );
+ URL url = Artifact.toURL( uri );
+ URLConnection connection = url.openConnection();
+ connection.connect();
+ File file = (File) connection.getContent( new
Class[]{File.class} );
+ String path = file.getCanonicalPath();
+ getProject().setNewProperty( name, path );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to resolve artifact uri ["
+ + m_uri
+ + "]";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+}
Added:
trunk/main/depot/tools/src/main/dpml/tools/transit/ImportArtifactTask.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/transit/ImportArtifactTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/main/dpml/tools/transit/ImportArtifactTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URI;
+import java.util.Properties;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.ImportTask;
+
+import net.dpml.transit.Artifact;
+import dpml.util.PropertyResolver;
+
+import static net.dpml.transit.Transit.DATA;
+
+/**
+ * Ant task that provides support for the import of build file templates
+ * via an artifact url.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ImportArtifactTask extends ImportTask
+{
+ /**
+ * A flag indicating that nested directives have been provided.
+ */
+ private boolean m_flag = false;
+
+ private boolean m_init = false;
+
+ /**
+ * Set the project.
+ * @param project the current project
+ */
+ public void setProject( Project project )
+ {
+ super.setProject( project );
+ setTaskName( "import" );
+ }
+
+ /**
+ * Task initialization.
+ */
+ public synchronized void init()
+ {
+ if( !m_init )
+ {
+ TransitTask.initialize( this );
+ super.init();
+ m_init = true;
+ }
+ }
+
+ //
------------------------------------------------------------------------
+ // Task
+ //
------------------------------------------------------------------------
+
+ /**
+ * Set the file to import. Any symbolic references in the supplied
+ * file argument will be resolved prior to invoking the standard setFile
+ * operation.
+ *
+ * @param file the template filename
+ */
+ public void setFile( String file )
+ {
+ Properties properties = System.getProperties();
+ String path = PropertyResolver.resolve( properties, file );
+ super.setFile( path );
+ }
+
+ /**
+ * Set the artifact to import.
+ * @param uri the artifact to import into the build file
+ * @exception BuildException if an error occurs while attempting to
+ * resolve the artifact uri
+ */
+ public void setUri( URI uri ) throws BuildException
+ {
+ try
+ {
+ URL url = Artifact.toURL( uri );
+ File local = (File) url.getContent( new Class[]{File.class} );
+ super.setFile( local.getAbsolutePath() );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Could not import the resource from the uri ["
+ + uri
+ + "]";
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * Execute the import.
+ */
+ public void execute()
+ {
+ try
+ {
+ super.execute();
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Input (super).execute() failed.";
+ throw new BuildException( error, e );
+ }
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/MainTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/MainTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/MainTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.Project;
+
+/**
+ * Task that initializes the Transit sub-system during which a transit
+ * is assigned to the current project. In addition the initization
procedures
+ * establishes a set of ant properties enabling convenient script based
access
+ * to DPML dirctories.
+ *
+ * <pre>
+ <project name="example"
+ xmlns:transit="antlib:dpml.tools.transit">
+ <transit:init/>
+ <echo message="Home: ${dpml.home}"/>
+ <echo message="Cache: ${dpml.cache}"/>
+ <echo message="Templates: ${dpml.templates}"/>
+ <echo message="Docs: ${dpml.docs}"/>
+ <echo message="Docs: ${dpml.dist}"/>
+ </project></pre>
+ * <p>Output from the above example is shown below:</p>
+ * <pre>
+ [echo] Home: C:\system\dpml
+ [echo] Cache: C:\system\dpml\main
+ [echo] Templates: C:\system\dpml\templates
+ [echo] Docs: C:\system\dpml\docs
+ [echo] Docs: C:\system\dpml\dist
+ * </pre>
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class MainTask extends TransitTask
+{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * List of plugin declarations.
+ */
+ private List<MapDataType> m_mappings = new ArrayList<MapDataType>();
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Creation of a new Main task.
+ */
+ public MainTask()
+ {
+ super();
+ }
+
+ //
------------------------------------------------------------------------
+ // Task
+ //
------------------------------------------------------------------------
+
+ /**
+ * Create and return a new plugin definition.
+ * @return the plugin definition
+ */
+ public MapDataType createMap()
+ {
+ MapDataType map = new MapDataType();
+ m_mappings.add( map );
+ return map;
+ }
+
+ /**
+ * Set the project.
+ * @param project the current project
+ */
+ public void setProject( Project project )
+ {
+ setTaskName( "transit" );
+ super.setProject( project );
+ }
+
+ /**
+ * Updates properties on the current project and install any plugins
declared
+ * as children of the transit init tag.
+ *
+ * @exception BuildException if an execution error occurs
+ */
+ public void execute() throws BuildException
+ {
+ Project project = getProject();
+ TransitComponentHelper.initialize( project );
+ ComponentHelper ch = ComponentHelper.getComponentHelper( project );
+ MapDataType[] maps = (MapDataType[]) m_mappings.toArray( new
MapDataType[0] );
+ TransitComponentHelper.register( maps );
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/MapDataType.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/MapDataType.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/MapDataType.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import java.net.URI;
+
+/**
+ * Utility class that declares a map between a urn and a plugin uri.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class MapDataType
+{
+ private String m_urn;
+ private URI m_uri;
+
+ /**
+ * Set the urn value.
+ * @param urn the urn
+ */
+ public void setUrn( String urn )
+ {
+ m_urn = urn;
+ }
+
+ /**
+ * Get the urn value.
+ * @return the urn
+ */
+ public String getURN()
+ {
+ if( null == m_urn )
+ {
+ throw new IllegalStateException( "urn" );
+ }
+ return m_urn;
+ }
+
+ /**
+ * Set the uri value.
+ * @param uri the uri
+ */
+ public void setUri( URI uri )
+ {
+ m_uri = uri;
+ }
+
+ /**
+ * Get the uri value.
+ * @return the uri
+ */
+ public URI getURI()
+ {
+ if( null == m_urn )
+ {
+ throw new IllegalStateException( "uri" );
+ }
+ return m_uri;
+ }
+
+ /**
+ * Return the string representing of this instance.
+ * @return the string value
+ */
+ public String toString()
+ {
+ return "[map urn:" + m_urn + " uri:" + m_uri + "]";
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/NodeTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/NodeTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/NodeTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2005 Stephen 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 dpml.tools.transit;
+
+import java.util.LinkedList;
+import java.util.prefs.Preferences;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Task supports the creation of preference as readable xml files.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class NodeTask extends Task
+{
+ private String m_name;
+ private LinkedList<NodeTask> m_nodes = new LinkedList<NodeTask>();
+ private LinkedList<EntryTask> m_entries = new LinkedList<EntryTask>();
+
+ /**
+ * Set the preference node name.
+ * @param name the node name
+ */
+ public void setName( String name )
+ {
+ m_name = name;
+ }
+
+ /**
+ * Create and return a new nested node.
+ * @return the new node
+ */
+ public NodeTask createNode()
+ {
+ NodeTask node = new NodeTask();
+ m_nodes.add( node );
+ return node;
+ }
+
+ /**
+ * Create and return a new attribute entry.
+ * @return the new attribute
+ */
+ public EntryTask createEntry()
+ {
+ EntryTask entry = new EntryTask();
+ m_entries.add( entry );
+ return entry;
+ }
+
+ void apply( Preferences prefs )
+ {
+ EntryTask[] entries = (EntryTask[]) m_entries.toArray( new
EntryTask[0] );
+ for( int i=0; i<entries.length; i++ )
+ {
+ EntryTask entry = entries[i];
+ entry.apply( prefs );
+ }
+ NodeTask[] nodes = (NodeTask[]) m_nodes.toArray( new NodeTask[0] );
+ for( int i=0; i<nodes.length; i++ )
+ {
+ NodeTask node = nodes[i];
+ String name = node.getNodeName();
+ Preferences child = prefs.node( name );
+ node.apply( child );
+ }
+ }
+
+ private String getNodeName()
+ {
+ if( null == m_name )
+ {
+ final String error =
+ "Missing name attribute.";
+ throw new BuildException( error, getLocation() );
+ }
+ return m_name;
+ }
+
+ /**
+ * An attribute entry.
+ */
+ public class EntryTask extends Task
+ {
+ private String m_key;
+ private Object m_value;
+ private Preferences m_prefs;
+ private Class m_type;
+
+ /**
+ * Set the attribute key.
+ * @param key the attribute name
+ */
+ public void setKey( String key )
+ {
+ m_key = key;
+ }
+
+ /**
+ * Set the attribute string value.
+ * @param value the string value
+ */
+ public void setValue( String value )
+ {
+ checkValue();
+ m_value = value;
+ }
+
+ /**
+ * Set the attribute as a boolean value.
+ * @param value the boolean value
+ */
+ public void setBoolean( boolean value )
+ {
+ checkValue();
+ m_value = new Boolean( value );
+ }
+
+ /**
+ * Set the attribute as a int value.
+ * @param value the int value
+ */
+ public void setInt( int value )
+ {
+ checkValue();
+ m_value = new Integer( value );
+ }
+
+ /**
+ * Set the attribute as a double value.
+ * @param value the double value
+ */
+ public void setDouble( double value )
+ {
+ checkValue();
+ m_value = new Double( value );
+ }
+
+ /**
+ * Set the attribute as a float value.
+ * @param value the float value
+ */
+ public void setFloat( float value )
+ {
+ checkValue();
+ m_value = new Float( value );
+ }
+
+ private void checkValue()
+ {
+ if( null != m_value )
+ {
+ final String error =
+ "Entry value is already assigned to an instance of "
+ + m_value.getClass().getName()
+ + ".";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+
+ void apply( Preferences prefs )
+ {
+ if( null == m_key )
+ {
+ final String error =
+ "Missing key attribute.";
+ throw new BuildException( error, getLocation() );
+ }
+ if( null == m_value )
+ {
+ final String error =
+ "Missing value attribute.";
+ throw new BuildException( error, getLocation() );
+ }
+ Class c = m_value.getClass();
+ if( c == String.class )
+ {
+ prefs.put( m_key, (String) m_value );
+ }
+ else if( c == Boolean.class )
+ {
+ prefs.putBoolean( m_key, ( (Boolean) m_value
).booleanValue() );
+ }
+ else if( c == Integer.class )
+ {
+ prefs.putInt( m_key, ( (Integer) m_value ).intValue() );
+ }
+ else if( c == Double.class )
+ {
+ prefs.putDouble( m_key, ( (Double) m_value ).doubleValue() );
+ }
+ else if( c == Float.class )
+ {
+ prefs.putFloat( m_key, ( (Float) m_value ).floatValue() );
+ }
+ }
+ }
+}
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/PluginTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/PluginTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/PluginTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,624 @@
+/*
+ * Copyright 2004-2005 Stephen 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 dpml.tools.transit;
+
+import dpml.lang.Part;
+import dpml.util.ElementHelper;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Hashtable;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import net.dpml.lang.PartError;
+import net.dpml.lang.AntlibStrategy;
+import net.dpml.lang.Strategy;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ComponentHelper;
+
+import org.w3c.dom.Element;
+
+/**
+ * The plugin task handles the establishment of ant tasks, listeners, and
antlibs derived
+ * from a classloader established by the transit sub-system.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PluginTask extends TransitTask
+{
+ /**
+ * The uri of the plugin to load.
+ */
+ private String m_uri;
+
+ /**
+ * Overloaded plugin urn.
+ */
+ private String m_urn;
+
+ /**
+ * A list of tasks declared by the plugin declaration.
+ */
+ private List<Task> m_tasks = new ArrayList<Task>();
+
+ /**
+ * List of listeners declared by the plugin task declaration.
+ */
+ private List<Listener> m_listeners = new ArrayList<Listener>();
+
+ /**
+ * List of antlibs declared by the plugin task declaration.
+ */
+ private List<Antlib> m_antlibs = new ArrayList<Antlib>();
+
+ /**
+ * Plugin name delalred by the plugin task declaration.
+ */
+ private String m_name;
+
+ /**
+ * A flag indicating that nested directives have been provided.
+ */
+ private boolean m_flag = false;
+
+ /**
+ * A list of tasks declared by the plugin declaration.
+ */
+ private Hashtable<URI,Part> m_parts = new Hashtable<URI,Part>(); // hard
reference to loaded parts
+
+ /**
+ * Set the project.
+ * @param project the current project
+ */
+ public void setProject( Project project )
+ {
+ setTaskName( "plugin" );
+ super.setProject( project );
+ }
+
+ /**
+ * Create and associate a new antlib urn entry with the plugin.
+ * @return the new antlib entry
+ */
+ public Antlib createAntlib()
+ {
+ m_flag = true;
+ final Antlib antlib = new Antlib();
+ m_antlibs.add( antlib );
+ return antlib;
+ }
+
+ /**
+ * Create and associate a new task entry with the plugin.
+ * @return the new task entry
+ */
+ public Task createTask()
+ {
+ m_flag = true;
+ final Task task = new Task();
+ m_tasks.add( task );
+ return task;
+ }
+
+ /**
+ * Create and associate a new build listener with the plugin.
+ * @return the new listener entry
+ */
+ public Listener createListener()
+ {
+ m_flag = true;
+ final Listener listener = new Listener();
+ m_listeners.add( listener );
+ return listener;
+ }
+
+ /**
+ * Set the artifact uri of the plugin from which the task is to be loaded.
+ * @param uri an artifact plugin uri
+ */
+ public void setUri( String uri )
+ {
+ m_uri = uri;
+ }
+
+ /**
+ * Overload the urn to assign to the plugin.
+ * @param urn the urn to use
+ */
+ public void setUrn( String urn )
+ {
+ m_urn = urn;
+ }
+
+ /**
+ * Return the artifact uri of the plugin.
+ * @return the plugin uri
+ */
+ public URI getUri()
+ {
+ try
+ {
+ return new URI( m_uri );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Cound not convert the supplied uri spec ["
+ + m_uri
+ + "] to a formal URI.";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+
+ /**
+ * Load the plugin and handle registration of listeners, tasks, and antlib
+ * declarations based on the nested nested task directives.
+ * @exception BuildException if an error occurs during plugin loading or
deployment
+ */
+ public void execute() throws BuildException
+ {
+ if( null == m_uri )
+ {
+ final String error =
+ "Missing uri attribute.";
+ throw new BuildException( error );
+ }
+
+ final Project project = getProject();
+ final ComponentHelper helper =
+ ComponentHelper.getComponentHelper( project );
+
+ if( !m_flag )
+ {
+ createAntlib();
+ }
+
+ try
+ {
+ URI uri = new URI( m_uri );
+ ClassLoader anchor = getClass().getClassLoader();
+ Strategy strategy = Strategy.load( anchor, null, uri, null );
+ ClassLoader loader = strategy.getClassLoader();
+ Task[] tasks = (Task[]) m_tasks.toArray( new Task[0] );
+ if( tasks.length > 0 )
+ {
+ for( int i=0; i < tasks.length; i++ )
+ {
+ try
+ {
+ Task task = tasks[i];
+ String classname = task.getClassname();
+ String name = task.getName();
+ Class c = loader.loadClass( classname );
+ helper.addTaskDefinition( name, c );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Failed to load a named task ["
+ + tasks[i].getName()
+ + "] from the part ["
+ + uri
+ + "].";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+ }
+
+ Listener[] listeners = (Listener[]) m_listeners.toArray( new
Listener[0] );
+ for( int i=0; i < listeners.length; i++ )
+ {
+ Listener listener = listeners[i];
+ String classname = listener.getClassname();
+ Class c = loader.loadClass( classname );
+ Object object = c.newInstance();
+ if( object instanceof BuildListener )
+ {
+ BuildListener instance = (BuildListener) object;
+ getProject().addBuildListener( instance );
+ log( "registered listener: " +
instance.getClass().getName() );
+ }
+ else
+ {
+ final String error =
+ "The plugin ["
+ + uri
+ + "] establishing the class ["
+ + object.getClass().getName()
+ + "] could not be registered as a project listener
because it does not implement the ["
+ + BuildListener.class.getName()
+ + "] interface.";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+
+ Antlib[] antlibs = (Antlib[]) m_antlibs.toArray( new Antlib[0] );
+ for( int i=0; i < antlibs.length; i++ )
+ {
+ loadAntlib( uri, loader, helper, antlibs[i] );
+ }
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Exception e )
+ {
+ final String error = "Unable to load the plugin ["
+ + m_uri
+ + "]";
+ throw new PartError( error, e );
+ }
+ }
+
+ //private Part getPart( URI uri ) throws IOException
+ //{
+ // Part part = m_parts.get( uri );
+ // if( null == part )
+ // {
+ // part = Part.load( uri );
+ // m_parts.put( uri, part );
+ // }
+ // return part;
+ //}
+
+ /**
+ * Load an antlib.
+ * @param classloader the classloader from which the antlib will be loaded
+ * @param helper the component helper
+ * @param antlib the antlib to load
+ * @exception Exception if it doesn't work out
+ */
+ private void loadAntlib(
+ URI uri, ClassLoader classloader, ComponentHelper helper, Antlib
antlib ) throws Exception
+ {
+ Strategy strategy = Strategy.load( classloader, null, uri, null );
+ String resource = antlib.getPath();
+ if( null == resource )
+ {
+ if( strategy instanceof AntlibStrategy )
+ {
+ AntlibStrategy res = (AntlibStrategy) strategy;
+ resource = res.getPath();
+ }
+ }
+ if( null == resource )
+ {
+ final String error =
+ "Resource path for the antlib is not declared in the part
descriptor "
+ + "or antlib directive ["
+ + uri
+ + "]";
+ throw new BuildException( error, getLocation() );
+ }
+
+ //String urn = getAntLibURN( antlib, part );
+ String urn = getAntLibURN( antlib, strategy );
+ if( null == urn )
+ {
+ final String error =
+ "URN for the antlib is not declared in the plugin descriptor "
+ + "or antlib directive ["
+ + uri
+ + "]";
+ throw new BuildException( error, getLocation() );
+ }
+
+ InputStream input = classloader.getResourceAsStream( resource );
+ if( null == input )
+ {
+ final String error =
+ "Antlib resource ["
+ + resource
+ + "] referenced in ["
+ + uri
+ + "] not found.";
+ throw new BuildException( error, getLocation() );
+ }
+ Element root = ElementHelper.getRootElement( input );
+ Element[] tasks = ElementHelper.getChildren( root, "taskdef" );
+ for( int i=0; i < tasks.length; i++ )
+ {
+ Element task = tasks[i];
+ String name = ElementHelper.getAttribute( task, "name" );
+ String classname = ElementHelper.getAttribute( task, "classname"
);
+ loadTaskDef( classloader, helper, classname, urn + ":" + name );
+ }
+
+ Element[] types = ElementHelper.getChildren( root, "typedef" );
+ for( int i=0; i < types.length; i++ )
+ {
+ Element type = types[i];
+ String name = ElementHelper.getAttribute( type, "name" );
+ String classname = ElementHelper.getAttribute( type, "classname"
);
+ loadTypeDef( classloader, helper, classname, urn + ":" + name );
+ }
+ }
+
+ private String getAntLibURN( Antlib antlib, Strategy strategy )
+ {
+ if( null != m_urn )
+ {
+ return m_urn;
+ }
+ String urn = antlib.getURN();
+ if( null != urn )
+ {
+ return urn;
+ }
+ else
+ {
+ //Strategy strategy = part.getStrategy();
+ if( strategy instanceof AntlibStrategy )
+ {
+ AntlibStrategy res = (AntlibStrategy) strategy;
+ return res.getURN();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Load a single task defintion.
+ * @param loader the classloader from which the task will be loaded
+ * @param helper the component helper
+ * @param classname the task classname
+ * @param name the task name
+ * @exception BuildException if an error occurs while attempting to load
the task
+ */
+ private void loadTaskDef( ClassLoader loader, ComponentHelper helper,
String classname, String name )
+ throws BuildException
+ {
+ if( getProject().getTaskDefinitions().get( name ) != null )
+ {
+ return;
+ }
+
+ try
+ {
+ Class c = loader.loadClass( classname );
+ helper.addTaskDefinition( name, c );
+ log( "installed taskdef: " + name, Project.MSG_VERBOSE );
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to load task ["
+ + name
+ + "] from class ["
+ + classname
+ + "].";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+
+ /**
+ * Load a single type defintion.
+ * @param loader the classloader from which the type will be loaded
+ * @param helper the component helper
+ * @param classname the type classname
+ * @param name the task type
+ * @exception BuildException if an error occurs while attempting to load
the task
+ */
+ private void loadTypeDef( ClassLoader loader, ComponentHelper helper,
String classname, String name )
+ throws BuildException
+ {
+ if( getProject().getDataTypeDefinitions().get( name ) != null )
+ {
+ return;
+ }
+
+ try
+ {
+ Class c = loader.loadClass( classname );
+ helper.addDataTypeDefinition( name, c );
+ log( "installed typedef: " + name, Project.MSG_VERBOSE );
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to load type ["
+ + name + "] from class ["
+ + classname
+ + "].";
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+
+ /**
+ * Nested element with the <plugin> element declaring the name and
class of
+ * a task to be loaded from the classloader established by the transit
plugin descriptor.
+ */
+ public static class Task
+ {
+ /**
+ * The task name.
+ */
+ private String m_name;
+
+ /**
+ * The task classname.
+ */
+ private String m_classname;
+
+ /**
+ * Set the task name.
+ * @param name the name of the task
+ */
+ public void setName( final String name )
+ {
+ m_name = name;
+ }
+
+ /**
+ * Set the task classname.
+ * @param classname the task classname
+ */
+ public void setClass( final String classname )
+ {
+ m_classname = classname;
+ }
+
+ /**
+ * Return the task classname.
+ * @return the classname
+ * @exception BuildException if the class attribute is missing
+ */
+ public String getClassname() throws BuildException
+ {
+ if( null == m_classname )
+ {
+ final String error =
+ "Missing class attribute.";
+ throw new BuildException( error );
+ }
+ return m_classname;
+ }
+
+ /**
+ * Return the task name.
+ * @return the name
+ * @exception BuildException if the name attribute is missing
+ */
+ public String getName() throws BuildException
+ {
+ if( null == m_name )
+ {
+ final String error =
+ "Missing name attribute.";
+ throw new BuildException( error );
+ }
+ return m_name;
+ }
+ }
+
+ /**
+ * Nested element with the <plugin> element declaring the name and
class of
+ * a project listener to be loaded from the classloader established by
the transit plugin descriptor.
+ */
+ public static class Listener
+ {
+ /**
+ * The listener classname.
+ */
+ private String m_classname;
+
+ /**
+ * Set the task classname.
+ * @param classname the task classname
+ */
+ public void setClass( final String classname )
+ {
+ m_classname = classname;
+ }
+
+ /**
+ * Return the task classname.
+ * @return the classname
+ * @exception BuildException if the class attribute is missing
+ */
+ public String getClassname() throws BuildException
+ {
+ if( null == m_classname )
+ {
+ final String error =
+ "Missing class attribute.";
+ throw new BuildException( error );
+ }
+ return m_classname;
+ }
+ }
+
+ /**
+ * Nested element with the <plugin> element declaring a packaged
resource and urn of
+ * an antlib descriptor to be loaded from the classloader established by
the transit plugin
+ * descriptor.
+ */
+ public static class Antlib
+ {
+ /**
+ * The antlib urn.
+ */
+ private String m_urn;
+
+ /**
+ * The antlib descriptor resource path.
+ */
+ private String m_path;
+
+ /**
+ * Set the urn for this antlib.
+ * @param urn the antlib urn
+ */
+ public void setUrn( final String urn )
+ {
+ m_urn = urn;
+ }
+
+ /**
+ * Return the antlib urn.
+ * @return the urn (possibly null in which case the a urn must be
declared
+ * within the plugin descriptor)0
+ */
+ public String getURN()
+ {
+ return m_urn;
+ }
+
+ /**
+ * Set the antlib resource path
+ * @param path the resource path
+ */
+ public void setResource( final String path )
+ {
+ m_path = path;
+ }
+
+ /**
+ * Return the antlib resource path.
+ * @return the path (possibly null in which case the resource
reference
+ * must exist in the plugin descriptor)
+ */
+ public String getPath()
+ {
+ return m_path;
+ }
+ }
+}
Added:
trunk/main/depot/tools/src/main/dpml/tools/transit/TransitComponentHelper.java
===================================================================
---
trunk/main/depot/tools/src/main/net/dpml/tools/transit/TransitComponentHelper.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/main/dpml/tools/transit/TransitComponentHelper.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,577 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import dpml.tools.BuilderError;
+
+import dpml.util.ElementHelper;
+
+import java.io.InputStream;
+import java.util.Vector;
+import java.util.Hashtable;
+import java.net.URI;
+
+import net.dpml.lang.AntlibStrategy;
+import net.dpml.lang.Strategy;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.SubBuildListener;
+import org.apache.tools.ant.BuildEvent;
+
+import org.w3c.dom.Element;
+
+/**
+ * A component helper that handles automatic loading of plugins into the
+ * ant plugin based on namespace declarations in the project file. This is
similar
+ * to the 'antlib:' convention except we use the 'plugin:' convention.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class TransitComponentHelper extends ComponentHelper
+ implements SubBuildListener
+{
+ //------------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------------
+
+ /**
+ * The constant Transit ANTLIB namespace.
+ */
+ public static final String TRANSIT_ANTLIB_URN =
"antlib:dpml.tools.transit";
+
+ /**
+ * The constant Transit ANTLIB init task namespace.
+ */
+ public static final String TRANSIT_INIT_URN = TRANSIT_ANTLIB_URN +
":init";
+
+ /**
+ * The constant Transit ANTLIB plugin task namespace.
+ */
+ public static final String TRANSIT_PLUGIN_URN = TRANSIT_ANTLIB_URN +
":plugin";
+
+ /**
+ * The constant Transit ANTLIB import task namespace.
+ */
+ public static final String TRANSIT_IMPORT_URN = TRANSIT_ANTLIB_URN +
":import";
+
+ /**
+ * The constant Transit ANTLIB get task namespace.
+ */
+ public static final String TRANSIT_GET_URN = TRANSIT_ANTLIB_URN + ":get";
+
+ /**
+ * The constant artifact plugin header.
+ */
+ public static final String PLUGIN_ARTIFACT_HEADER = "artifact:part:";
+
+ /**
+ * Creation of a component helper for the supplied project.
+ *
+ * @param project the project
+ */
+ public static void initialize( Project project )
+ {
+ initialize( project, false );
+ }
+
+ /**
+ * Creation of a component helper for the supplied project.
+ *
+ * @param project the project
+ * @param flag subproject flag
+ */
+ public static void initialize( Project project, boolean flag )
+ {
+ ComponentHelper current =
+ (ComponentHelper) project.getReference( "ant.ComponentHelper" );
+ if( ( null != current ) && ( current instanceof
TransitComponentHelper ) )
+ {
+ return;
+ }
+ TransitComponentHelper helper = new TransitComponentHelper( project,
current );
+ helper.initDefaultDefinitions();
+ if( flag )
+ {
+ project.log(
+ "\nAssigning Transit component helper to sub-project: "
+ + project.getBaseDir() );
+ }
+ else
+ {
+ project.log(
+ "\nAssigning Transit component helper to project: "
+ + project.getBaseDir() );
+ }
+ project.addReference( "ant.ComponentHelper", helper );
+ project.addBuildListener( helper );
+ }
+
+ /**
+ * Vector of plugin uris already loaded.
+ */
+ private static Vector<URI> m_URIS = new Vector<URI>();
+
+ /**
+ * Table of urn to uri mappings.
+ */
+ private static Hashtable<String,URI> m_MAPPINGS = new
Hashtable<String,URI>();
+
+ /**
+ * Register the mapping between a urn and a plugin uri.
+ * @param maps a sequence of urn to uri bindings
+ */
+ public static void register( MapDataType[] maps )
+ {
+ if( null == maps )
+ {
+ throw new NullPointerException( "maps" );
+ }
+
+ for( int i=0; i < maps.length; i++ )
+ {
+ MapDataType map = maps[i];
+ String urn = map.getURN();
+ if( !m_MAPPINGS.contains( urn ) )
+ {
+ URI uri = map.getURI();
+ m_MAPPINGS.put( urn, uri );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------------
+
+ /**
+ * The current project.
+ */
+ private Project m_project;
+
+ /**
+ * The parent component helper.
+ */
+ private ComponentHelper m_parent;
+
+ //------------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------------
+
+ /**
+ * Creation of a new transit component helper.
+ * @param project the current project
+ */
+ public TransitComponentHelper( Project project )
+ {
+ this( project, ComponentHelper.getComponentHelper( project ) );
+ }
+
+ /**
+ * Creation of a new transit component helper.
+ * @param project the current project
+ * @param parent the parent component helper
+ */
+ public TransitComponentHelper( Project project, ComponentHelper parent )
+ {
+ setProject( project );
+ m_parent = parent;
+ if( null != parent )
+ {
+ parent.setNext( this );
+ }
+
+ Hashtable map = getTaskDefinitions();
+ if( null == map.get( TRANSIT_INIT_URN ) )
+ {
+ addTaskDefinition( TRANSIT_INIT_URN, MainTask.class );
+ addTaskDefinition( TRANSIT_PLUGIN_URN, PluginTask.class );
+ addTaskDefinition( TRANSIT_IMPORT_URN, ImportArtifactTask.class
);
+ addTaskDefinition( TRANSIT_GET_URN, GetTask.class );
+ }
+ }
+
+
//------------------------------------------------------------------------
+ // implementation
+
//------------------------------------------------------------------------
+
+ /**
+ * Set the current project.
+ * @param project the current ant project
+ */
+ public void setProject( Project project )
+ {
+ m_project = project;
+ super.setProject( project );
+ }
+
+ /**
+ * Create an object for a component using a supplied name. The name
+ * is the fully qualified component name which allows us to intercept
+ * specific namespace qualifiers - in this case 'plugin:'. In the event
of
+ * a plugin namespace we check to see if the plugin for that name is
already
+ * loaded and it not we proceed with classic transit-based loading of the
+ * plugin and registration of plugin classes with the component helper.
+ *
+ * @param name the name of the component, if the component is in a
namespace, the
+ * name is prefixed with the namespace uri and ":"
+ * @return the class if found or null if not.
+ */
+ public Object createComponent( String name )
+ {
+ Object object = super.createComponent( name );
+ if( null != object )
+ {
+ return object;
+ }
+ else if( null != m_parent )
+ {
+ object = m_parent.createComponent( name );
+ if( null != object )
+ {
+ return object;
+ }
+ }
+
+ if( name.startsWith( "antlib:" ) )
+ {
+ String spec = name.substring( 7 );
+ int n = spec.indexOf( ":" );
+ if( n < 0 )
+ {
+ final String error =
+ "Invalid antlib component name: "
+ + name;
+ throw new BuildException( error );
+ }
+
+ String resource = spec.substring( 0, n );
+ if( spec.length() < ( n + 1 ) )
+ {
+ final String error =
+ "Invalid antlib component name: "
+ + name;
+ throw new BuildException( error );
+ }
+ String theName = spec.substring( n + 1 );
+ String path = resource.replace( '.', '/' ) + "/antlib.xml";
+ ClassLoader classloader = getClass().getClassLoader();
+ InputStream input = classloader.getResourceAsStream( path );
+ if( null == input )
+ {
+ final String error =
+ "Task ["
+ + name
+ + "] could not be loaded because the Antlib resource ["
+ + path
+ + "] does not exist.";
+ throw new BuildException( error );
+ }
+ else
+ {
+ int i = name.lastIndexOf( ":" );
+ if( i < 0 )
+ {
+ final String error =
+ "Invalid antlib component name: "
+ + name;
+ throw new BuildException( error );
+ }
+ else
+ {
+ String urn = name.substring( 0, name.lastIndexOf( ":" )
);
+ installAntlib( classloader, input, urn );
+ return createComponent( name );
+ }
+ }
+ }
+ else
+ {
+ //
+ // from here we need to validate - code has been worked over
more than a
+ // few time ans I would not recommend it for flight control
scenarios
+ // just yet
+ //
+
+ int k = name.lastIndexOf( ":" );
+ if( k > 0 )
+ {
+ String urn = name.substring( 0, k );
+ String task = name.substring( k + 1 );
+ URI uri = convertUrnToURI( urn );
+ if( null != uri )
+ {
+ installPlugin( uri, urn, task );
+ object = super.createComponent( name );
+ if( null != object )
+ {
+ return object;
+ }
+ else
+ {
+ final String error =
+ "Mapped urn returned a null object.";
+ throw new BuildException( error );
+ }
+ }
+ else
+ {
+ return super.createComponent( name );
+ }
+ }
+ else
+ {
+ return super.createComponent( name );
+ }
+ }
+ }
+
+ /**
+ * Convert a urn to a uri taking into account possible urn alias names.
+ *
+ * @param urn the urn to convert to a uri
+ * @return the converted uri
+ */
+ private URI convertUrnToURI( String urn )
+ {
+ URI uri = (URI) m_MAPPINGS.get( urn );
+ if( null != uri )
+ {
+ return uri;
+ }
+ if( urn.startsWith( PLUGIN_ARTIFACT_HEADER ) )
+ {
+ return convertToURI( urn );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * The implementation will retrieve the plugin descriptor. If the
descriptor
+ * declares a classname then the class will be loaded and assigned under
+ * name. If the classname is undefined and resource is defined, the
+ * implementation will attempt to locate an antlib definition at the
resource
+ * location and will attempt to load all taskdef and typedef entries
declared
+ * in the antlib.
+ *
+ * @param uri the plugin uri
+ * @param name the fully qualified component name
+ */
+ private void installPlugin( URI uri, String urn, String name )
+ {
+ final String label = uri + ":" + name;
+ if( null != getTaskDefinitions().get( label ) )
+ {
+ return;
+ }
+
+ try
+ {
+ m_project.log( "installing: " + uri + " as " + urn );
+ Strategy strategy = Strategy.load( null, null, uri, null );
+ ClassLoader classloader = strategy.getClassLoader();
+ ClassLoader current =
Thread.currentThread().getContextClassLoader();
+ if( strategy instanceof AntlibStrategy )
+ {
+ AntlibStrategy res = (AntlibStrategy) strategy;
+ String resource = res.getPath();
+ getProject().log( "installing antlib plugin [" + resource +
"]", Project.MSG_VERBOSE );
+ InputStream input = classloader.getResourceAsStream(
resource );
+ if( null == input )
+ {
+ final String error =
+ "Cannot load resource ["
+ + resource
+ + "] because it does not exist within the cloassloader
defined by the uri ["
+ + uri
+ + "]"
+ + "\n" + classloader.toString();
+ throw new BuildException( error );
+ }
+ installAntlib( classloader, input, urn );
+ }
+ else
+ {
+ final String error =
+ "Strategy class not supported ["
+ + strategy.getClass().getName()
+ + "].";
+ throw new BuildException( error );
+ }
+ m_URIS.add( uri );
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load plugin: " + uri;
+ throw new BuildException( error, e );
+ }
+ }
+
+ private void installAntlib( ClassLoader classloader, InputStream input,
String urn )
+ {
+ try
+ {
+ Element root = ElementHelper.getRootElement( input );
+ Element[] tasks = ElementHelper.getChildren( root, "taskdef" );
+ for( int i=0; i < tasks.length; i++ )
+ {
+ Element task = tasks[i];
+ String key = urn + ":" + ElementHelper.getAttribute( task,
"name" );
+ getProject().log( "installing task [" + key + "]",
Project.MSG_VERBOSE );
+ String classname = ElementHelper.getAttribute( task,
"classname" );
+ Class clazz = classloader.loadClass( classname );
+ super.addTaskDefinition( key, clazz );
+ }
+ Element[] types = ElementHelper.getChildren( root, "typedef" );
+ for( int i=0; i < types.length; i++ )
+ {
+ Element type = types[i];
+ String key = urn + ":" + ElementHelper.getAttribute( type,
"name" );
+ getProject().log( "installing type [" + key + "]",
Project.MSG_VERBOSE );
+ String classname = ElementHelper.getAttribute( type,
"classname" );
+ Class clazz = classloader.loadClass( classname );
+ super.addDataTypeDefinition( key, clazz );
+ }
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Antlib installation error: " + urn;
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * Returns the current project.
+ * @return the project
+ */
+ private Project getProject()
+ {
+ return m_project;
+ }
+
+ /**
+ * Convert a urn to a url wrapping any errors in a build exception.
+ * @param urn the urn
+ * @return the uri
+ * @exception BuildException if a convertion error occurs
+ */
+ private URI convertToURI( String urn ) throws BuildException
+ {
+ try
+ {
+ return new URI( urn );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to convert the urn ["
+ + urn
+ + "] to a uri.";
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * Notification that the build has started.
+ * @param event the build event
+ * @exception BuildException if a build error occurs
+ */
+ public void buildStarted( BuildEvent event )
+ throws BuildException
+ {
+ initialize( event.getProject(), false );
+ }
+
+ /**
+ * Notification that a sub build has started.
+ * @param event the build event
+ */
+ public void subBuildStarted( BuildEvent event )
+ {
+ initialize( event.getProject(), true );
+ }
+
+ /**
+ * Notification that a sub build has finished.
+ * @param event the build event
+ */
+ public void subBuildFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification that the build has finished.
+ * @param event the build event
+ */
+ public void buildFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification that the build target has started.
+ * @param event the build event
+ */
+ public void targetStarted( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification that the build target has finished.
+ * @param event the build event
+ */
+ public void targetFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification that the build task has started.
+ * @param event the build event
+ */
+ public void taskStarted( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification that the build task has finaished.
+ * @param event the build event
+ */
+ public void taskFinished( BuildEvent event )
+ {
+ }
+
+ /**
+ * Notification of a message logged.
+ * @param event the build event
+ */
+ public void messageLogged( BuildEvent event )
+ {
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/TransitTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/TransitTask.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/TransitTask.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2004-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 dpml.tools.transit;
+
+import java.io.File;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import net.dpml.transit.Transit;
+
+import static net.dpml.transit.Transit.VERSION;
+
+/**
+ * Ant task that provides support for the import of build file templates
+ * via an artifact url.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+abstract class TransitTask extends Task
+{
+ private static boolean m_INIT = false;
+
+ /**
+ * Set the project.
+ * @param project the project
+ */
+ public void setProject( Project project )
+ {
+ super.setProject( project );
+ initialize( this );
+ }
+
+ /**
+ * Initialize the supplied task.
+ * @param task the task to initialize
+ * @exception BuildException if an initialization error occurs
+ */
+ public static void initialize( Task task ) throws BuildException
+ {
+ synchronized( TransitTask.class )
+ {
+ Project project = task.getProject();
+ if( !m_INIT )
+ {
+ m_INIT = true;
+ if( null == System.getProperty( "java.protocol.handler.pkgs"
) )
+ {
+ System.setProperty( "java.protocol.handler.pkgs",
"net.dpml.transit" );
+ }
+ try
+ {
+ Transit transit = Transit.getInstance();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while initializing Transit";
+ throw new BuildException( error, e );
+ }
+ }
+ checkProperties( project );
+ }
+ }
+
+ /**
+ * Declares four properties into the current project covering the DPML
home directory,
+ * template directory, doc and main cache directories.
+ * @param project the current project
+ * @exception BuildException if an execution error occurs
+ */
+ private static void checkProperties( Project project ) throws
BuildException
+ {
+ if( null == project )
+ {
+ throw new NullPointerException( "project" );
+ }
+
+ updateProperty( project, "dpml.transit.version", VERSION );
+
+ File home = Transit.HOME;
+ File system = Transit.SYSTEM;
+ File data = Transit.DATA;
+ File prefs = Transit.PREFS;
+
+ File docs = new File( data, "docs" );
+ File dist = new File( data, "dist" );
+ File logs = new File( data, "logs" );
+
+ updateProperty( project, "dpml.home", home.getAbsolutePath() );
+ updateProperty( project, "dpml.system", system.getAbsolutePath() );
+ updateProperty( project, "dpml.data", data.getAbsolutePath() );
+ updateProperty( project, "dpml.docs", docs.getAbsolutePath() );
+ updateProperty( project, "dpml.dist", dist.getAbsolutePath() );
+ updateProperty( project, "dpml.logs", dist.getAbsolutePath() );
+ updateProperty( project, "dpml.prefs", prefs.getAbsolutePath() );
+
+ File cache = Transit.getInstance().getCacheDirectory();
+ if( null == project.getReference( "dpml.cache" ) )
+ {
+ try
+ {
+ project.addReference( "dpml.cache", cache );
+ }
+ catch( Throwable e )
+ {
+ throw new BuildException( e );
+ }
+ }
+
+ try
+ {
+ updateProperty( project, "dpml.cache", cache.getAbsolutePath() );
+ }
+ catch( Throwable e )
+ {
+ throw new BuildException( e );
+ }
+
+ String auth = project.getProperty( "dpml.transit.authority" );
+ if( null != auth )
+ {
+ System.setProperty(
+ "dpml.transit.authority",
+ System.getProperty(
+ "dpml.transit.authority", auth )
+ );
+ }
+ }
+
+ /**
+ * Update a property. If the property is already defined, the
implementation
+ * checks if the current value is the same as the supplied value and if
not the
+ * property value is updated. If not property exists for the given key a
new
+ * property will be created.
+ *
+ * @param project the ant project
+ * @param key the property key
+ * @param value the property value
+ */
+ private static void updateProperty( Project project, String key, String
value )
+ {
+ String v = project.getProperty( key );
+ if( null == v )
+ {
+ project.setProperty( key, value );
+ }
+ else if( !v.equals( value ) )
+ {
+ project.setNewProperty( key, value );
+ }
+ }
+}
+
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/antlib.xml
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/antlib.xml
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/antlib.xml
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<antlib xmlns:current="ant:current">
+ <taskdef name="init" classname="dpml.tools.transit.MainTask"/>
+ <taskdef name="plugin" classname="dpml.tools.transit.PluginTask"/>
+ <taskdef name="import"
classname="dpml.tools.transit.ImportArtifactTask"/>
+ <taskdef name="get" classname="dpml.tools.transit.GetTask"/>
+</antlib>
Added: trunk/main/depot/tools/src/main/dpml/tools/transit/package.html
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/transit/package.html
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/main/dpml/tools/transit/package.html
2007-02-08 23:31:25 UTC (rev 1818)
@@ -0,0 +1,36 @@
+
+<body>
+<p>
+ Ant tasks supporting Transit-based repository access.
+ The init task is used to established a number of transit related ant
+ properties and the plugin task is used to load antlibs, taskdefs,
typedefs
+ and build listeners using classloaders established relative to
resources
+ managed by the transit system.
+</p>
+
+ <p><i>Example build file:</i></p>
+
+<pre>
+<project name="example" xmlns:transit="antlib:net.dpml.transit">
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+</project>
+</pre>
+
+ <p><i>Example of a request to load and register a task
definition.</i></p>
+
+<pre>
+<project name="example" xmlns:transit="antlib:net.dpml.transit">
+
+ <transit:plugin
uri="artifact:plugin:dpml/magic/dpml-magic-doc#3000">
+ <task class="net.dpml.magic.doc.DocTask" name="docs"/>
+ </transit:plugin>
+
+ <docs/>
+
+</project>
+</pre>
+
+</body>
+
Copied: trunk/main/depot/tools/src/test/dpml (from rev 1789,
trunk/main/depot/tools/src/test/net/dpml)
Modified:
trunk/main/depot/tools/src/test/dpml/tools/info/AbstractTestCase.java
===================================================================
--- trunk/main/depot/tools/src/test/net/dpml/tools/info/AbstractTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/depot/tools/src/test/dpml/tools/info/AbstractTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.tools.info;
+package dpml.tools.info;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,7 +29,7 @@
/**
* The ModuleDirective class describes a module data-structure.
*
- * @author <a href="http://www.dpml.net">The Digital Product Meta Library</a>
+ * @author <a href="http://www.dpml.net">The Digital Product Management
Laboratory</a>
*/
abstract class AbstractTestCase extends TestCase
{
Modified:
trunk/main/depot/tools/src/test/dpml/tools/info/ListenerDirectiveTestCase.java
===================================================================
---
trunk/main/depot/tools/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/depot/tools/src/test/dpml/tools/info/ListenerDirectiveTestCase.java
2007-02-08 23:31:25 UTC (rev 1818)
@@ -16,21 +16,21 @@
* limitations under the License.
*/
-package net.dpml.tools.info;
+package dpml.tools.info;
import java.net.URI;
/**
* The ModuleDirective class describes a module data-structure.
*
- * @author <a href="http://www.dpml.net">The Digital Product Meta Library</a>
+ * @author <a href="http://www.dpml.net">The Digital Product Management
Laboratory</a>
*/
public final class ListenerDirectiveTestCase extends AbstractTestCase
{
static final String NAME = "test";
static final int PRIORITY = 0;
static final String SPEC = "local:plugin:acme/widget";
- static final String CLASSNAME = "net.dpml.tools.process.JarProcess";
+ static final String CLASSNAME = "dpml.tools.process.JarProcess";
static final ListenerDirective[] LISTENERS = new ListenerDirective[3];
static
- r1818 - in trunk/main/depot: . build build/etc build/etc/bin build/etc/bootstrap build/src/main build/src/main/dpml build/src/main/dpml/build library library/etc/data library/etc/data/ant library/etc/data/commons-cli library/etc/data/dpml library/etc/data/jgoodies library/etc/data/junit library/etc/data/samples library/etc/data/xstream library/src/main library/src/main/dpml/library library/src/main/dpml/library/impl library/src/main/dpml/library/info library/src/test library/src/test/dpml/library library/src/test/dpml/library/impl library/src/test/dpml/library/info library/src/test/net plugins plugins/checkstyle plugins/checkstyle/etc plugins/checkstyle/src/main plugins/checkstyle/src/main/dpml/tools/checkstyle plugins/checkstyle/src/main/net plugins/convert plugins/convert/etc plugins/convert/src/main plugins/convert/src/main/net tools tools/etc tools/etc/bootstrap tools/etc/prefs/templates tools/etc/prefs/xmls tools/src/main tools/src/main/dpml/tools tools/src/mai! n/dpml/tools/impl tools/src/main/dpml/tools/info tools/src/main/dpml/tools/tasks tools/src/main/dpml/tools/transit tools/src/test tools/src/test/dpml/tools/info, mcconnell at BerliOS, 02/08/2007
Archive powered by MHonArc 2.6.24.