notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1677 - in development/main/home: . transit transit/etc transit/etc/deliverables transit/etc/deliverables/modules transit/handler transit/handler/etc/deliverables transit/handler/etc/main transit/plugin transit/tools transit/tools/src transit/tools/src/main transit/tools/src/main/net transit/tools/src/main/net/dpml transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools util util/cli util/criteria util/etc util/exception util/i18n
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1677 - in development/main/home: . transit transit/etc transit/etc/deliverables transit/etc/deliverables/modules transit/handler transit/handler/etc/deliverables transit/handler/etc/main transit/plugin transit/tools transit/tools/src transit/tools/src/main transit/tools/src/main/net transit/tools/src/main/net/dpml transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools util util/cli util/criteria util/etc util/exception util/i18n
- Date: Tue, 01 Feb 2005 09:07:55 +0100
Author: mcconnell
Date: Tue Feb 1 09:07:55 2005
New Revision: 1677
Added:
development/main/home/LICENSE.TXT
development/main/home/NOTICE.TXT
development/main/home/README.TXT
- copied unchanged from r1676, development/main/home/transit/README.TXT
development/main/home/build.properties
development/main/home/standard.xml
development/main/home/transit/etc/
development/main/home/transit/etc/deliverables/
development/main/home/transit/etc/deliverables/modules/
development/main/home/transit/etc/deliverables/modules/project.module
development/main/home/transit/plugin/build.properties
development/main/home/transit/tools/
development/main/home/transit/tools/build.properties
development/main/home/transit/tools/build.xml
development/main/home/transit/tools/src/
development/main/home/transit/tools/src/main/
development/main/home/transit/tools/src/main/net/
development/main/home/transit/tools/src/main/net/dpml/
development/main/home/transit/tools/src/main/net/dpml/transit/
development/main/home/transit/tools/src/main/net/dpml/transit/antlib.xml
development/main/home/transit/tools/src/main/net/dpml/transit/tools/
development/main/home/transit/tools/src/main/net/dpml/transit/tools/AntAdapter.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/MainTask.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/Map.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginManager.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TargetFactory.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
development/main/home/transit/tools/src/main/net/dpml/transit/tools/package.html
development/main/home/util/build.properties
development/main/home/util/cli/build.properties
development/main/home/util/criteria/build.properties
development/main/home/util/etc/
development/main/home/util/exception/build.properties
development/main/home/util/i18n/build.properties
Removed:
development/main/home/transit/README.TXT
development/main/home/transit/handler/bootstrap.properties
development/main/home/transit/handler/bootstrap.xml
development/main/home/transit/handler/etc/deliverables/
development/main/home/transit/handler/etc/main/
development/main/home/transit/index.xml
development/main/home/transit/module.xml
Modified:
development/main/home/transit/handler/build.properties
Log:
shuffling and bumping
Added: development/main/home/LICENSE.TXT
==============================================================================
--- (empty file)
+++ development/main/home/LICENSE.TXT Tue Feb 1 09:07:55 2005
@@ -0,0 +1,175 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
Added: development/main/home/NOTICE.TXT
==============================================================================
--- (empty file)
+++ development/main/home/NOTICE.TXT Tue Feb 1 09:07:55 2005
@@ -0,0 +1,9 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+=========================================================================
+
+This product is developed by the members of the Digial Product Meta
+Library (DPML) http://www.dpml.net. Resources developed by the DPML
+includes products and resources developed by the Apache Software
+Foundation (http://www.apache.org).
\ No newline at end of file
Added: development/main/home/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/build.properties Tue Feb 1 09:07:55 2005
@@ -0,0 +1,7 @@
+
+transit.home = .
+project.name = dpml.transit
+project.group = dpml/transit
+dpml.repository = http://repository.dpml.net/classic
+junit-filename = junit-3.8.1.jar
+
Added: development/main/home/standard.xml
==============================================================================
--- (empty file)
+++ development/main/home/standard.xml Tue Feb 1 09:07:55 2005
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2004 Stephen J McConnell
+ Copyright 2004 Niclas Hedhman
+
+ 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.
+-->
+
+<project name="standard">
+
+ <property environment="ENV"/>
+
+ <property file="bootstrap.properties"/>
+ <property file="build.properties"/>
+ <property file="${transit.home}/build.properties"/>
+
+ <property name="project.name" value="UNKNOWN"/>
+ <property name="project.type" value="jar"/>
+ <property name="project.dir" value="${basedir}/target/test"/>
+
+ <available classname="junit.framework.TestCase"
property="junit.available"/>
+
+ <condition property="dpml.env.declared" value="false">
+ <isset property="ENV.DPML_HOME"/>
+ </condition>
+
+ <condition property="signature.declared" value="false">
+ <isset property="dpml.release.signature"/>
+ </condition>
+
+ <property name="src" value="src"/>
+ <property name="src.main" value="main"/>
+ <property name="src.main.dir" value="${src}/${src.main}"/>
+ <property name="src.test" value="test"/>
+ <property name="src.test.dir" value="${src}/${src.test}"/>
+
+ <property name="etc" value="etc"/>
+ <property name="etc.main" value="${etc}/main"/>
+ <property name="etc.deliverables" value="${etc}/deliverables"/>
+ <property name="etc.test" value="${etc}/test"/>
+
+ <property name="target" value="target"/>
+ <property name="target.dir" value="${target}"/>
+
+ <property name="target.build.dir" value="${target.dir}/build"/>
+ <property name="target.build.test.dir" value="${target.build.dir}/test"/>
+ <property name="target.build.main.dir" value="${target.build.dir}/main"/>
+
+ <property name="target.classes.dir" value="${target.dir}/classes"/>
+ <property name="target.test-classes.dir"
value="${target.dir}/test-classes"/>
+ <property name="target.test-reports.dir"
value="${target.dir}/test-reports"/>
+ <property name="target.test.dir" value="${target.dir}/test"/>
+
+ <property name="target.deliverables.dir"
value="${target.dir}/deliverables"/>
+ <property name="target.deliverables.jars.dir"
value="${target.deliverables.dir}/jars"/>
+
+ <target name="setupReleaseFilename" if="signature.declared">
+ <property name="project.version" value="${dpml.release.signature}"/>
+ </target>
+
+ <target name="init"
depends="check-dpml-home,declare-dpml-home,setupReleaseFilename">
+ <property name="project.version" value="SNAPSHOT"/>
+ <property name="project.filename"
value="${project.name}-${project.version}.${project.type}"/>
+ <property name="dpml-transit-handler.filename"
value="dpml-transit-main-${project.version}.jar"/>
+ <property name="dpml-transit-antlib.filename"
value="dpml-transit-antlib-${project.version}.jar"/>
+ <echo>
+#----------------------------------------------------------------------------------
+# ${project.group}/${project.name}#${project.version}
+#----------------------------------------------------------------------------------
+ </echo>
+ <path id="project.main.path">
+ <pathelement location="${target.classes.dir}"/>
+ </path>
+ <path id="project.test.path">
+ <path refid="project.main.path"/>
+ <pathelement
location="${dpml.home}/cache/junit/jars/${junit-filename}"/>
+ </path>
+ </target>
+
+ <available file="${etc.deliverables}"
property="etc.deliverables.available"/>
+ <target name="prepare-etc-deliverable" depends="init"
if="etc.deliverables.available">
+ <mkdir dir="${target.deliverables.dir}"/>
+ <copy toDir="${target.deliverables.dir}" filtering="on"
failonerror="false">
+ <fileset dir="${etc.deliverables}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <available file="${etc.main}" property="etc.main.available"/>
+ <target name="prepare-etc-main" depends="init" if="etc.main.available">
+ <mkdir dir="${target.build.main.dir}"/>
+ <copy toDir="${target.build.main.dir}" filtering="on"
failonerror="false">
+ <fileset dir="${etc.main}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <available file="${etc.test}" property="etc.test.available"/>
+ <target name="prepare-etc-test" depends="init" if="etc.test.available">
+ <!--
+ Any files in etc/test get copied over to target/test with filtering
+ applied.
+ -->
+ <mkdir dir="${target.test.dir}"/>
+ <copy toDir="${target.test.dir}" filtering="on" failonerror="false">
+ <fileset dir="${etc.test}">
+ <include name="**/*"/>
+ <exclude name="**/*.jar"/>
+ </fileset>
+ </copy>
+ <copy toDir="${target.test.dir}" filtering="off" failonerror="false">
+ <fileset dir="${etc.test}">
+ <include name="**/*.jar"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <available file="${etc}" property="etc.available"/>
+ <target name="prepare-etc" depends="init" if="etc.available">
+ <!--
+ Any files in etc excluding test, main and deliverables get copied over to
+ the target directory.
+ -->
+ <copy toDir="${target.dir}" filtering="on" failonerror="false">
+ <fileset dir="${etc}">
+ <exclude name="${etc.main}/*"/>
+ <exclude name="${etc.test}/*"/>
+ <exclude name="${etc.deliverables}/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <available file="${src.main.dir}" property="src.main.available"/>
+ <target name="prepare-src-main" depends="init" if="src.main.available">
+ <!--
+ Any files in src/main get copied over to target/build/main with filtering
+ applied.
+ -->
+ <mkdir dir="${target.build.main.dir}"/>
+ <copy toDir="${target.build.main.dir}" filtering="on"
failonerror="false">
+ <fileset dir="${src.main.dir}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <available file="${src.test.dir}" property="src.test.available"/>
+ <target name="prepare-src-test" depends="init" if="src.test.available">
+ <!--
+ Any files in src/test get copied over to target/build/test with filtering
+ applied.
+ -->
+ <mkdir dir="${target.build.test.dir}"/>
+ <copy toDir="${target.build.test.dir}" filtering="on"
failonerror="false">
+ <fileset dir="${src.test.dir}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="prepare-build-main" depends="init" if="src.main.available">
+ <!--
+ Create the target/classes directory and copy into it anything from
target/build/main
+ that isn't a java source file.
+ -->
+ <mkdir dir="${target.classes.dir}"/>
+ <copy toDir="${target.classes.dir}" failonerror="false">
+ <fileset dir="${target.build.main.dir}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="prepare-build-test" depends="init" if="src.test.available">
+ <!--
+ Create the target/test-classes directory and copy into it anything from
target/build/test
+ that isn't a java source file.
+ -->
+ <mkdir dir="${target.test-classes.dir}"/>
+ <copy toDir="${target.test-classes.dir}" failonerror="false">
+ <fileset dir="${target.build.test.dir}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="prepare"
depends="init,prepare-etc-deliverable,prepare-etc-main,
+ prepare-etc-test,prepare-etc, prepare-src-main, prepare-src-test,
+ prepare-build-main, prepare-build-test">
+ <tstamp/>
+ </target>
+
+ <target name="build.setup" depends="prepare" if="src.main.available">
+ <available file="${target.build.main.dir}"
property="build.main.available"/>
+ </target>
+
+ <target name="build" depends="build.setup" if="build.main.available">
+ <!--
+ Compile sources in target/build/main with oputput classes under
target/classes.
+ -->
+ <javac srcdir="${target.build.main.dir}" destdir="${target.classes.dir}"
debug="true">
+ <classpath refid="project.main.path"/>
+ </javac>
+ </target>
+
+ <target name="package.setup" depends="prepare" if="src.main.available">
+ <available file="${target.classes.dir}"
property="target.classes.available"/>
+ </target>
+
+ <target name="package" depends="package.setup"
if="target.classes.available">
+ <!--
+ Create the jar file using the contents of target/classes.
+ -->
+ <mkdir dir="${target.deliverables.jars.dir}"/>
+ <jar destfile="${target.deliverables.jars.dir}/${project.filename}"
+ basedir="${target.classes.dir}"
+ includes="**/*.class,**/*.xml,**/*.properties"/>
+ </target>
+
+ <!--
+ Compile the tests using the classes as the classpath and
+ place results into the target/test-classes directory.
+ -->
+ <target name="build-tests" depends="prepare,build,junit-install"
if="src.test.available">
+ <mkdir dir="${target.test-classes.dir}"/>
+ <javac srcdir="${target.build.test.dir}"
+ destdir="${target.test-classes.dir}"
+ debug="true">
+ <classpath refid="project.test.path"/>
+ </javac>
+ </target>
+
+ <!--
+ Execute any unit test.
+ -->
+ <target name="test" depends="build-tests" if="src.test.available">
+ <mkdir dir="${target.test.dir}"/>
+ <mkdir dir="${target.test-reports.dir}"/>
+ <junit printsummary="yes" haltonfailure="yes" showoutput="true"
+ dir="${basedir}" fork="true"
+ failureproperty="junit.failure"
+ haltonerror="no"
+ errorproperty="junit.error">
+ <classpath>
+ <path refid="project.test.path"/>
+ <pathelement location="${target.test-classes.dir}"/>
+ </classpath>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest fork="yes" todir="${target.test-reports.dir}">
+ <fileset dir="${target.build.test.dir}">
+ <include name="**/*TestCase.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <fail message="There were unittest failures." if="junit.failure" />
+ <fail message="There were unittest errors." if="junit.error" />
+ </target>
+
+ <target name="install.setup" depends="prepare">
+ <available file="${target.deliverables.dir}"
property="deliverables.available"/>
+ </target>
+
+ <target name="install" depends="package,test,install.setup"
if="deliverables.available">
+ <!--
+ Install any deliverables under the project cache relative to the project
group path.
+ -->
+ <echo>Installing to: ${dpml.home}/cache/${project.group}</echo>
+ <mkdir dir="${dpml.home}/cache/${project.group}"/>
+ <copy toDir="${dpml.home}/cache/${project.group}" overwrite="true">
+ <fileset dir="${target.deliverables.dir}"/>
+ </copy>
+ </target>
+
+ <target name="clean">
+ <delete dir="${target.dir}"/>
+ </target>
+
+ <target name="declare-dpml-home" if="dpml.env.declared">
+ <property name="dpml.home" value="${ENV.DPML_HOME}"/>
+ </target>
+
+ <target name="check-dpml-home" unless="dpml.env.declared">
+ <property name="dpml.home" value="${user.home}/.dpml"/>
+ </target>
+
+ <target name="junit-install" depends="init" unless="junit.available">
+ <property name="junit.url"
value="${dpml.repository}/junit/jars/${junit.filename}"/>
+ <echo>
+#----------------------------------------------------------------------------------
+# Installing JUnit
+#----------------------------------------------------------------------------------
+ </echo>
+ <mkdir dir="${dpml.home}/cache/junit/jars"/>
+ <get src="${junit.url}" usetimestamp="true"
+ dest="${dpml.home}/cache/junit/jars/${junit.jar}"/>
+ <mkdir dir="${user.home}/.ant/lib"/>
+ <copy toDir="${user.home}/.ant/lib">
+ <fileset dir="${dpml.home}/cache/junit/jars">
+ <include name="${junit.jar}"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
Added: development/main/home/transit/etc/deliverables/modules/project.module
==============================================================================
--- (empty file)
+++ development/main/home/transit/etc/deliverables/modules/project.module
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<module uri="artifact:module:dpml/transit/dpml-transit#@PROJECT-VERSION@">
+
+ <header>
+ <publisher name="The Digital Product Meta Library"/>
+ <packages>
+ <package name="net.dpml.transit"/>
+ <package name="net.dpml.transit.*"/>
+ </packages>
+ <home href="http://www.dpml.net/products/transit"/>
+ <docs href="http://www.dpml.net"/>
+ <legal>
+ <license href="http://www.dpml.net/central/about/legal/license.html"/>
+ <notice href="http://www.dpml.net/central/about/legal/notice.html"/>
+ </legal>
+ <svn href="http://paris.dpml.net/svn/main/transit"/>
+ <repository href="http://www.dpml.net"/>
+ </header>
+
+ <resources>
+
+ <!-- imports -->
+
+ <import uri="artifact:module:dpml/util/dpml-util#@PROJECT-VERSION@"/>
+
+ <!-- module resources -->
+
+ <resource key="dpml-transit-main">
+ <info>
+ <group>dpml/transit</group>
+ <name>dpml-transit-main</name>
+ <version>@PROJECT-VERSION@</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource key="dpml-transit-plugin">
+ <info>
+ <group>dpml/transit</group>
+ <name>dpml-transit-plugin</name>
+ <version>@PROJECT-VERSION@</version>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main"/>
+ <include key="dpml-util-criteria"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-util-cli"/>
+ <include key="commons-cli"/>
+ </dependencies>
+ </resource>
+
+ </resources>
+
+</module>
+
Modified: development/main/home/transit/handler/build.properties
==============================================================================
--- development/main/home/transit/handler/build.properties (original)
+++ development/main/home/transit/handler/build.properties Tue Feb 1
09:07:55 2005
@@ -4,4 +4,3 @@
project.jar.main.class=net.dpml.transit.Installer
project.group = dpml/transit
project.name = dpml-transit-main
-junit-filename = junit-3.8.1.jar
Added: development/main/home/transit/plugin/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/transit/plugin/build.properties Tue Feb 1
09:07:55 2005
@@ -0,0 +1,5 @@
+
+transit.home = ../..
+project.test.fork = true
+project.group = dpml/transit
+project.name = dpml-transit-plugin
Added: development/main/home/transit/tools/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/transit/tools/build.properties Tue Feb 1
09:07:55 2005
@@ -0,0 +1,6 @@
+
+transit.home = ../..
+project.group = dpml/transit
+project.name = dpml-transit-tools
+project.antlib = ${project.name}.jar
+
Added: development/main/home/transit/tools/build.xml
==============================================================================
--- (empty file)
+++ development/main/home/transit/tools/build.xml Tue Feb 1 09:07:55
2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2004-2005 Stephen J McConnell
+ Copyright 2004 Niclas Hedhman
+
+ 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.
+-->
+
+<project name="dpml-transit-tools" default="install" basedir=".">
+
+ <property file="build.properties"/>
+ <import file="${transit.home}/standard.xml"/>
+
+ <target name="init" depends="standard.init">
+ <path id="project.main.path">
+ <pathelement
location="${dpml.home}/cache/dpml/transit/jars/${dpml-transit-handler.filename}"/>
+ <pathelement location="${target.classes.dir}"/>
+ </path>
+ </target>
+
+</project>
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/antlib.xml
==============================================================================
--- (empty file)
+++ development/main/home/transit/tools/src/main/net/dpml/transit/antlib.xml
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<antlib xmlns:current="ant:current">
+ <taskdef name="init" classname="net.dpml.transit.tools.MainTask"/>
+ <taskdef name="plugin" classname="net.dpml.transit.tools.PluginTask"/>
+ <taskdef name="import"
classname="net.dpml.transit.tools.ImportArtifactTask"/>
+</antlib>
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/AntAdapter.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/AntAdapter.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,139 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.net.URL;
+
+import net.dpml.transit.adapter.Adapter;
+import net.dpml.transit.adapter.ExceptionHelper;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Project;
+
+/**
+ * A ant montor for download messages.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AntMonitor.java 183 2004-10-23 16:53:31Z niclas $
+ */
+class AntAdapter implements Adapter
+{
+ /**
+ * 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 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 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 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 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 );
+ }
+ }
+
+ /**
+ * Hnadle download notification.
+ * @param resource the resource under attention
+ * @param total the estimated download size
+ * @param count the progress towards expected
+ */
+ public void notify( URL resource, int total, int count )
+ {
+ }
+}
+
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,66 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.ImportTask;
+
+import net.dpml.transit.artifact.Handler;
+
+/**
+ * Ant task that provides support for the import of build file templates
+ * via an artifact url.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ImportArtifactTask extends ImportTask
+{
+
+ //
------------------------------------------------------------------------
+ // Task
+ //
------------------------------------------------------------------------
+
+ /**
+ * 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( String uri ) throws BuildException
+ {
+ try
+ {
+ URL url = new URL( null, uri, new Handler() );
+ File local = (File) url.getContent( new Class[]{File.class} );
+ super.setFile( local.getAbsolutePath() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not import the resource from the uri ["
+ + uri
+ + "]";
+ throw new BuildException( error, e );
+ }
+ }
+}
+
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/MainTask.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/MainTask.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,199 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.io.File;
+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;
+import org.apache.tools.ant.Task;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.TransitException;
+import net.dpml.transit.adapter.Adapter;
+import net.dpml.transit.adapter.RepositoryMonitorAdapter;
+import net.dpml.transit.adapter.CacheMonitorAdapter;
+import net.dpml.transit.adapter.NetworkMonitorAdapter;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+
+/**
+ * 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:net.dpml.magic">
+ <TRANSIT:init/>
+ <echo message="Home: ${dpml.home}"/>
+ <echo message="Cache: ${dpml.cache}"/>
+ <echo message="Templates: ${dpml.templates}"/>
+ <echo message="Docs: ${dpml.docs}"/>
+ </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
+ * </pre>
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class MainTask extends Task
+{
+ //
------------------------------------------------------------------------
+ // static
+ //
------------------------------------------------------------------------
+
+ /**
+ * The one-time initialized state of the transit system.
+ */
+ private static boolean init = false;
+
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * List of plugin declarations.
+ */
+ private List m_mappings = new ArrayList();
+
+ //
------------------------------------------------------------------------
+ // Task
+ //
------------------------------------------------------------------------
+
+ /**
+ * Task initialization.
+ */
+ public void init()
+ {
+ setTaskName( "transit" );
+ }
+
+ /**
+ * Create and return a new plugin definition.
+ * @return the plugin definition
+ */
+ public Map createMap()
+ {
+ Map map = new Map();
+ m_mappings.add( map );
+ return map;
+ }
+
+ /**
+ * 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();
+ checkProperties( project );
+ if( !init )
+ {
+ setupMonitors();
+ File home = Transit.DPML_HOME;
+ log( "home: " + home.getAbsolutePath() );
+ TransitComponentHelper helper = new TransitComponentHelper(
project );
+ project.addBuildListener( helper );
+ TransitComponentHelper.initialize( project );
+ init = true;
+ }
+
+ Map[] maps = (Map[]) m_mappings.toArray( new Map[0] );
+ TransitComponentHelper.register( maps );
+ }
+
+
+ /**
+ * 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 void checkProperties( Project project ) throws BuildException
+ {
+ File home = Transit.DPML_HOME;
+ File templates = new File( home, "templates" );
+ File docs = new File( home, "docs" );
+ File cache = new File( home, "cache" );
+ updateProperty( project, "dpml.home", home.getAbsolutePath() );
+ updateProperty( project, "dpml.templates",
templates.getAbsolutePath() );
+ updateProperty( project, "dpml.docs", docs.getAbsolutePath() );
+ updateProperty( project, "dpml.cache", cache.getAbsolutePath() );
+ }
+
+
+ /**
+ * Setup the monitors.
+ */
+ private void setupMonitors()
+ {
+ try
+ {
+ Transit instance = Transit.getInstance();
+ Adapter adapter = new AntAdapter( this );
+ instance.getRepositoryMonitorRouter().addMonitor(
+ new RepositoryMonitorAdapter( adapter ) );
+ instance.getCacheMonitorRouter().addMonitor(
+ new CacheMonitorAdapter( adapter ) );
+ instance.getNetworkMonitorRouter().addMonitor(
+ new NetworkMonitorAdapter( adapter ) );
+ }
+ catch( TransitException e )
+ {
+ final String error =
+ "Failed to initialize Transit.";
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * 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 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:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/Map.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/Map.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,53 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.net.URI;
+
+/**
+ * Utility class that declares a map beterrn a urn and a plugin uri.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class Map
+{
+ private String m_urn;
+ private URI m_uri;
+
+ public void setUrn( String urn )
+ {
+ m_urn = urn;
+ }
+
+ public String getURN()
+ {
+ return m_urn;
+ }
+
+ public void setUri( URI uri )
+ {
+ m_uri = uri;
+ }
+
+ public URI getURI()
+ {
+ return m_uri;
+ }
+}
+
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginManager.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginManager.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2004 Niclas Hedhman.
+ *
+ * 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.transit.tools;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.SubBuildListener;
+import org.apache.tools.ant.Target;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Properties;
+
+public class PluginManager
+ implements SubBuildListener
+{
+ private File m_MagicDir;
+
+ public PluginManager()
+ {
+ m_MagicDir = new File( Transit.DPML_HOME, "processes" );
+ }
+
+ public void buildStarted( BuildEvent event )
+ throws BuildException
+ {
+ processStart( event );
+
+ }
+
+ public void subBuildStarted( BuildEvent event )
+ {
+ processStart( event );
+ }
+
+ public void subBuildFinished( BuildEvent event )
+ {
+ }
+
+ public void buildFinished( BuildEvent event )
+ {
+ }
+
+ public void targetStarted( BuildEvent event )
+ {
+ }
+
+ public void targetFinished( BuildEvent event )
+ {
+ }
+
+ public void taskStarted( BuildEvent event )
+ {
+ }
+
+ public void taskFinished( BuildEvent event )
+ {
+ }
+
+ public void messageLogged( BuildEvent event )
+ {
+ }
+
+ private void processStart( BuildEvent event )
+ {
+ Project project = event.getProject();
+
+ //
+ // handle target addition
+ //
+
+ String type = readProjectType( project );
+ if( type == null )
+ return; // this is not a Magic project.
+
+ ArrayList pluginNames = readPluginNames( project, type );
+ if( pluginNames == null )
+ return; // build process file is not readable.
+
+ project.log( "Magic Extension enabled." );
+ for( int i = 0; i < pluginNames.size(); i++ )
+ {
+ String pluginName = (String) pluginNames.get( i );
+ try
+ {
+ Artifact artifact = Artifact.createArtifact( pluginName );
+ URI uri = artifact.toURI();
+ Repository repo = new StandardLoader();
+
+ //TODO: is it correct to use this class' classloader
+ ClassLoader cl = getClass().getClassLoader();
+ TargetFactory factory = (TargetFactory) repo.getPlugin( cl,
uri, new Object[] { project, uri } );
+ Target[] plugins = factory.createTargets();
+ for( int j = 0; j < plugins.length; j++ )
+ {
+ Target target = plugins[ j ];
+ project.addTarget( target );
+ }
+ } catch( Exception e )
+ {
+ project.log( "Warning!! Ant target in plugin '" + pluginName
+ "' could not be loaded: " + e );
+ }
+ }
+ }
+
+ private ArrayList readPluginNames( Project project, String type )
+ {
+ File pluginFile = new File( m_MagicDir, type + ".type" );
+ FileInputStream in = null;
+ try
+ {
+ ArrayList result = new ArrayList();
+ in = new FileInputStream( pluginFile );
+ InputStreamReader isr = new InputStreamReader( in );
+ BufferedReader reader = new BufferedReader( isr );
+ String line = reader.readLine();
+ while( line != null )
+ {
+ line = line.trim();
+ if( ! "".equals( line ) && ! line.startsWith( "#" ) )
+ result.add( line.trim() );
+ line = reader.readLine();
+ }
+ return result;
+ } catch( IOException e )
+ {
+ project.log( "Warning!! No plugins found in " + pluginFile );
+ return null;
+ } finally
+ {
+ if( in != null )
+ {
+ try
+ {
+ in.close();
+ } catch( IOException e )
+ {} // ignore.
+ }
+ }
+ }
+
+ private String readProjectType( Project project )
+ {
+ FileInputStream in = null;
+ try
+ {
+ File basedir = project.getBaseDir();
+ File f = new File( basedir, "build.properties" );
+ in = new FileInputStream( f );
+ Properties p = new Properties();
+ p.load( in );
+ String value = p.getProperty( "dpml.magic.build.process" );
+ if( value != null )
+ value = value.trim();
+ return value;
+ } catch( IOException e )
+ {
+ return null;
+ } finally
+ {
+ if( in != null )
+ {
+ try
+ {
+ in.close();
+ } catch( IOException e )
+ {}
+ }
+ }
+ }
+
+}
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,565 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.io.InputStream;
+
+import java.net.URI;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import net.dpml.lang.NullArgumentException;
+
+import net.dpml.transit.TransitException;
+
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+import net.dpml.transit.repository.Plugin;
+
+import net.dpml.transit.util.ElementHelper;
+
+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="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PluginTask extends org.apache.tools.ant.Task
+{
+ private static final Repository REPOSITORY;
+
+ /**
+ * The uri of the plugin to load.
+ */
+ private String m_uri;
+
+ /**
+ * A list of tasks declared by the plugin declaration.
+ */
+ private List m_tasks = new ArrayList();
+
+ /**
+ * List of listeners declared by the plugin task declaration.
+ */
+ private List m_listeners = new ArrayList();
+
+ /**
+ * List of antlibs declared by the plugin task declaration.
+ */
+ private List m_antlibs = new ArrayList();
+
+ /**
+ * 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;
+
+ /** Static initialization sets up the Repository. */
+ static
+ {
+ REPOSITORY = setupRepository();
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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 );
+ }
+ }
+
+ /**
+ * 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();
+ ClassLoader classloader = this.getClass().getClassLoader();
+ final ComponentHelper helper =
+ ComponentHelper.getComponentHelper( project );
+
+ if( !m_flag )
+ {
+ createAntlib();
+ }
+
+ try
+ {
+ URI uri = new URI( m_uri );
+ ClassLoader loader =
+ getRepository().getPluginClassLoader( classloader, uri );
+
+ 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 plugin ["
+ + uri
+ + "].";
+ throw new BuildException( error, e );
+ }
+ }
+ }
+
+ 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 );
+ }
+ }
+
+ 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( Throwable e )
+ {
+ final String error = "Unable to load the plugin ["
+ + m_uri
+ + "] due to "
+ + e.toString();
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * 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
+ {
+ Plugin descriptor = getRepository().getPluginDescriptor( uri );
+ String resource = antlib.getPath();
+ if( null == resource )
+ {
+ resource = descriptor.getResource();
+ }
+ if( null == resource )
+ {
+ final String error =
+ "Resource path for the antlib is not declared in the plugin
descriptor "
+ + "or antlib directive ["
+ + uri
+ + "]";
+ throw new BuildException( error );
+ }
+
+ String urn = antlib.getURN();
+ if( null == urn )
+ {
+ urn = descriptor.getURN();
+ }
+ 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 );
+ }
+
+ InputStream input = classloader.getResourceAsStream( resource );
+ 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 );
+ }
+ }
+
+ /**
+ * 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( Throwable e )
+ {
+ final String error =
+ "Unable to load task [" + name + "] from class [" + classname
+ + "] due to the following error: "
+ + e.toString();
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * 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( Throwable e )
+ {
+ final String error =
+ "Unable to load type [" + name + "] from class [" + classname
+ + "] due to the following error: "
+ + e.toString();
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * 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)
+ */
+ public String getURN() throws BuildException
+ {
+ 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 polugin descriptor)
+ */
+ public String getPath() throws BuildException
+ {
+ return m_path;
+ }
+ }
+
+ private static Repository getRepository()
+ {
+ return REPOSITORY;
+ }
+
+ private static Repository setupRepository()
+ {
+ try
+ {
+ return new StandardLoader();
+ }
+ catch( TransitException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TargetFactory.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TargetFactory.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004 Niclas Hedhman.
+ * 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.transit.tools;
+
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.BuildException;
+
+/** The factory interface for creation of Ant targets to be used in Magic.
+ * <p>
+ * Additional semantic contract is that the TargetFactory takes two
+ * arguments in its constructor, the first being of type
org.apache.tools.ant.Project
+ * and the second of type java.net.URI of the artifact URI.
+ * </p>
+ */
+public interface TargetFactory
+{
+ /**
+ * Creation of new targets.
+ * @return an array of target instances that this factory can build.
+ * @exception BuildException if the Factory is unable to build the
requested target.
+ */
+ Target[] createTargets() throws BuildException;
+}
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,431 @@
+/*
+ * 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 net.dpml.transit.tools;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Vector;
+import java.util.Hashtable;
+import java.net.URI;
+
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.repository.Plugin;
+import net.dpml.transit.repository.StandardLoader;
+
+import org.apache.tools.ant.Main;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.helper.ProjectHelper2;
+import org.apache.tools.ant.BuildLogger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.input.DefaultInputHandler;
+import org.apache.tools.ant.ComponentHelper;
+import org.apache.tools.ant.AntTypeDefinition;
+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:' coonvention except we use the 'plugin:' convention.
+ *
+ * @author <a href="mailto:dev@dpmlnet">Stephen J. McConnell</a>
+ * @version $Id: Metro.java 916 2004-11-25 12:15:17Z niclas AT apache.org $
+ */
+public class TransitComponentHelper extends ComponentHelper
+ implements SubBuildListener
+{
+ //------------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------------
+
+ public static final String MAGIC_URI = "antlib:net.dpml.magic";
+ public static final String MAGIC_INIT_URI = MAGIC_URI + ":init";
+ public static final String MAGIC_PLUGIN_URI = MAGIC_URI + ":plugin";
+ public static final String MAGIC_IMPORT_URI = MAGIC_URI + ":import";
+
+ public static final String PLUGIN_ARTIFACT_HEADER = "artifact:plugin:";
+
+ /**
+ * Creation of a component helper for the supplied project.
+ *
+ * @param project the project
+ * @return the project component for a specific project
+ */
+ public static void initialize( Project project )
+ {
+ initialize( project, false );
+ }
+
+ /**
+ * Creation of a component helper for the supplied project.
+ *
+ * @param project the project
+ * @return the project component for a specific project
+ */
+ 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" );
+ }
+ project.addReference( "ant.ComponentHelper", helper );
+ project.addBuildListener( helper );
+
+ }
+
+ /**
+ * Vector of plugin uris already loaded.
+ */
+ private static Vector m_uris = new Vector();
+
+ /**
+ * Table of urn to uri mappings.
+ */
+ private static Hashtable m_mappings = new Hashtable();
+
+ /**
+ * Register the mapping between a urn and a plugin uri.
+ * @param maps a sequence of urn to uri bindings
+ */
+ public static void register( Map[] maps )
+ {
+ for( int i=0; i<maps.length; i++ )
+ {
+ Map 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
+ //------------------------------------------------------------------------
+
+ public TransitComponentHelper( Project project )
+ {
+ this( project, ComponentHelper.getComponentHelper( project ) );
+ }
+
+ public TransitComponentHelper( Project project, ComponentHelper parent )
+ {
+ setProject( project );
+ m_parent = parent;
+ if( null != parent )
+ {
+ parent.setNext( this );
+ }
+
+ addTaskDefinition( MAGIC_INIT_URI, MainTask.class );
+ addTaskDefinition( MAGIC_PLUGIN_URI, PluginTask.class );
+ addTaskDefinition( MAGIC_IMPORT_URI, ImportArtifactTask.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;
+ }
+
+ if( null != m_parent )
+ {
+ object = m_parent.createComponent( name );
+ if( null != object )
+ {
+ return object;
+ }
+ }
+
+ //
+ // 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 );
+ return super.createComponent( name );
+ }
+ }
+
+ return super.createComponent( name );
+ }
+
+ /**
+ * Convert a urn to a uri taking into account possible urn alias names.
+ * TODO: turn this inot a parameteizable namespace to artifact map.
+ *
+ * @param urn the urn to convert to a 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 )
+ {
+ if( m_uris.contains( uri ) )
+ {
+ return;
+ }
+
+ try
+ {
+ m_project.log( "installing plugin: " + urn );
+
+ StandardLoader loader = new StandardLoader();
+ Plugin descriptor = loader.getPluginDescriptor( uri );
+ ClassLoader current = getClass().getClassLoader();
+ ClassLoader classloader = loader.getPluginClassLoader( current,
uri );
+ if( null != descriptor.getClassname() )
+ {
+ Class clazz = classloader.loadClass(
descriptor.getClassname() );
+ final String key = uri + ":" + name;
+ getProject().log( "installing single task [" + key + "]",
Project.MSG_VERBOSE );
+ super.addTaskDefinition( key, clazz );
+ }
+ else
+ {
+ String resource = descriptor.getResource();
+ InputStream input = classloader.getResourceAsStream(
resource );
+ 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 );
+ }
+ }
+
+ m_uris.add( uri );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load plugin: " + uri;
+ throw new BuildException( error, e );
+ }
+ }
+
+ /**
+ * Returns the current project.
+ * @return the project
+ */
+ private Project getProject()
+ {
+ return m_project;
+ }
+
+ /**
+ * Return the plugin uri by resolving the string form the beggining of
the name
+ * to the last occurance of ":". The content following the ":" is used by
ant for
+ * the actual task name. We use the string preceeding the name to hold the
+ * artifact uri.
+ *
+ * @param name the fully qualified task name
+ * @return the plugin uri
+ * @exception BuildException if a convertion error occurs
+ */
+ private URI getURI( String name ) throws BuildException
+ {
+ String urn = name.substring( 0, name.lastIndexOf( ":" ) );
+ if( name.startsWith( "artifact:plugin:" ) )
+ {
+ return convertToURI( urn );
+ }
+ else
+ {
+ String spec = "artifact:plugin:" + urn.substring( 7 );
+ return convertToURI( spec );
+ }
+ }
+
+ /**
+ * 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 );
+ }
+ }
+
+ public void buildStarted( BuildEvent event )
+ throws BuildException
+ {
+ initialize( event.getProject(), false );
+ }
+
+ public void subBuildStarted( BuildEvent event )
+ {
+ initialize( event.getProject(), true );
+ }
+
+ public void subBuildFinished( BuildEvent event )
+ {
+ }
+
+ public void buildFinished( BuildEvent event )
+ {
+ }
+
+ public void targetStarted( BuildEvent event )
+ {
+ }
+
+ public void targetFinished( BuildEvent event )
+ {
+ }
+
+ public void taskStarted( BuildEvent event )
+ {
+ }
+
+ public void taskFinished( BuildEvent event )
+ {
+ }
+
+ public void messageLogged( BuildEvent event )
+ {
+ }
+
+}
+
Added:
development/main/home/transit/tools/src/main/net/dpml/transit/tools/package.html
==============================================================================
--- (empty file)
+++
development/main/home/transit/tools/src/main/net/dpml/transit/tools/package.html
Tue Feb 1 09:07:55 2005
@@ -0,0 +1,37 @@
+
+<body>
+<p>
+ Transit provides two ant tasks that provide the entry point to
transit
+ based repository access. These include the init task and the plugin
task.
+ 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:magic="antlib:net.dpml.magic">
+
+ <magic:import uri="artifact:template:dpml/magic/reactor"/>
+
+</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">
+
+ <magic:plugin
uri="artifact:plugin:dpml/magic/dpml-magic-doc#SNAPSHOT">
+ <task class="net.dpml.magic.doc.DocTask" name="docs"/>
+ </magic:plugin>
+
+ <docs/>
+
+</project>
+</pre>
+
+</body>
+
Added: development/main/home/util/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/util/build.properties Tue Feb 1 09:07:55 2005
@@ -0,0 +1,5 @@
+
+transit.home = ..
+project.test.fork = true
+project.group = dpml/util
+project.name = dpml-util
Added: development/main/home/util/cli/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/util/cli/build.properties Tue Feb 1 09:07:55
2005
@@ -0,0 +1,7 @@
+
+transit.home = ../..
+project.test.fork = true
+project.group = dpml/util
+project.name = dpml-util-cli
+
+commons-cli.filename = commons-cli-1.0.jar
Added: development/main/home/util/criteria/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/util/criteria/build.properties Tue Feb 1
09:07:55 2005
@@ -0,0 +1,6 @@
+
+transit.home = ../..
+project.test.fork = true
+project.group = dpml/util
+project.name = dpml-util-criteria
+junit-filename = junit-3.8.1.jar
Added: development/main/home/util/exception/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/util/exception/build.properties Tue Feb 1
09:07:55 2005
@@ -0,0 +1,6 @@
+
+transit.home = ../..
+project.test.fork = true
+project.group = dpml/util
+project.name = dpml-util-exception
+junit-filename = junit-3.8.1.jar
Added: development/main/home/util/i18n/build.properties
==============================================================================
--- (empty file)
+++ development/main/home/util/i18n/build.properties Tue Feb 1 09:07:55
2005
@@ -0,0 +1,6 @@
+
+transit.home = ../..
+project.test.fork = true
+project.group = dpml/util
+project.name = dpml-util-i18n
+junit-filename = junit-3.8.1.jar
- svn commit: r1677 - in development/main/home: . transit transit/etc transit/etc/deliverables transit/etc/deliverables/modules transit/handler transit/handler/etc/deliverables transit/handler/etc/main transit/plugin transit/tools transit/tools/src transit/tools/src/main transit/tools/src/main/net transit/tools/src/main/net/dpml transit/tools/src/main/net/dpml/transit transit/tools/src/main/net/dpml/transit/tools util util/cli util/criteria util/etc util/exception util/i18n, mcconnell, 02/01/2005
Archive powered by MHonArc 2.6.24.