Skip to Content.
Sympa Menu

notify-dpml - r1571 - in trunk/main/depot: library/src/main/net/dpml/library tools/builder/src/main/net/dpml/tools/tasks

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1571 - in trunk/main/depot: library/src/main/net/dpml/library tools/builder/src/main/net/dpml/tools/tasks
  • Date: Sun, 16 Jul 2006 18:28:46 +0200

Author: mcconnell
Date: 2006-07-16 18:28:45 +0200 (Sun, 16 Jul 2006)
New Revision: 1571

Added:

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ResourceTask.java
Modified:
trunk/main/depot/library/src/main/net/dpml/library/Feature.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavadocTask.java
Log:
add abstract task for customization of the resource name to be used as the
target resource for task execution

Modified: trunk/main/depot/library/src/main/net/dpml/library/Feature.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/Feature.java
2006-07-16 12:51:26 UTC (rev 1570)
+++ trunk/main/depot/library/src/main/net/dpml/library/Feature.java
2006-07-16 16:28:45 UTC (rev 1571)
@@ -71,10 +71,15 @@
public static final Feature FILENAME = new Feature( "filename" );

/**
+ * Project basedir.
+ */
+ public static final Feature BASEDIR = new Feature( "basedir" );
+
+ /**
* Array of scope enumeration values.
*/
private static final Feature[] ENUM_VALUES =
- new Feature[]{NAME, GROUP, VERSION, URI, SPEC, PATH, FILENAME};
+ new Feature[]{NAME, GROUP, VERSION, URI, SPEC, PATH, FILENAME,
BASEDIR};

/**
* Returns an array of activation enum values.
@@ -140,6 +145,10 @@
{
return FILENAME;
}
+ else if( value.equalsIgnoreCase( "basedir" ) )
+ {
+ return BASEDIR;
+ }
else
{
final String error =
@@ -267,6 +276,27 @@
String id = type.getID();
return resource.getLayoutPath( id );
}
+ else if( feature.equals( Feature.BASEDIR ) )
+ {
+ File base = resource.getBaseDir();
+ if( null == base )
+ {
+ throw new IllegalArgumentException( "basedir" );
+ }
+ else
+ {
+ try
+ {
+ return base.getCanonicalPath();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while resolving project basedir [" +
base + "].";
+ throw new FeatureRuntimeException( error, e );
+ }
+ }
+ }
else
{
final String error =

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavadocTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavadocTask.java
2006-07-16 12:51:26 UTC (rev 1570)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavadocTask.java
2006-07-16 16:28:45 UTC (rev 1571)
@@ -38,7 +38,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class JavadocTask extends GenericTask
+public class JavadocTask extends ResourceTask
{
//-----------------------------------------------------------------------
// static

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ResourceTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ResourceTask.java
2006-07-16 12:51:26 UTC (rev 1570)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ResourceTask.java
2006-07-16 16:28:45 UTC (rev 1571)
@@ -0,0 +1,105 @@
+/*
+ * 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 net.dpml.library.ResourceNotFoundException;
+import net.dpml.library.Resource;
+import net.dpml.library.Feature;
+import net.dpml.library.Type;
+
+import net.dpml.tools.Context;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Locate a named feature of the a project or resource.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public abstract class ResourceTask extends GenericTask
+{
+ private String m_key;
+ private String m_ref;
+
+ /**
+ * Set the key of the target project or resource description from which
features will be
+ * resolved from. If not declared the key defaults to the current
defintion.
+ *
+ * @param key the resource key
+ */
+ public void setKey( final String key )
+ {
+ m_key = key;
+ }
+
+ /**
+ * Set the ref of the target project or resource description from which
features will be
+ * resolved from.
+ *
+ * @param ref the resource reference
+ */
+ public void setRef( final String ref )
+ {
+ m_ref = ref;
+ }
+
+ /**
+ * Get the project definition.
+ * @return the resource
+ */
+ protected Resource getResource()
+ {
+ if( null != m_ref )
+ {
+ return getResource( m_ref );
+ }
+ else if( null != m_key )
+ {
+ Context context = getContext();
+ Resource resource = context.getResource();
+ Resource parent = resource.getParent();
+ String ref = parent.getResourcePath() + "/" + m_key;
+ return getResource( ref );
+ }
+ else
+ {
+ return getContext().getResource();
+ }
+ }
+
+ private Resource getResource( String ref )
+ {
+ try
+ {
+ return getContext().getLibrary().getResource( ref );
+ }
+ catch( ResourceNotFoundException e )
+ {
+ final String error =
+ "Feature reference ["
+ + ref
+ + "] in the project ["
+ + getResource()
+ + "] is unknown.";
+ throw new BuildException( error, e );
+ }
+ }
+}




  • r1571 - in trunk/main/depot: library/src/main/net/dpml/library tools/builder/src/main/net/dpml/tools/tasks, mcconnell at BerliOS, 07/16/2006

Archive powered by MHonArc 2.6.24.

Top of Page