avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 22428 - in avalon/trunk/runtime: composition/impl/src/java/org/apache/avalon/composition/data/builder meta/tools/src/java/org/apache/avalon/meta/info/ant
Date Thu, 01 Jul 2004 15:26:37 GMT
Author: mcconnell
Date: Thu Jul  1 08:26:36 2004
New Revision: 22428

Modified:
   avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
   avalon/trunk/runtime/meta/tools/src/java/org/apache/avalon/meta/info/ant/MetaTask.java
Log:
fix some things in the handling of includes - and update the meta task to read in properties
concerning postfix selection

Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
(original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
Thu Jul  1 08:26:36 2004
@@ -262,7 +262,8 @@
         }
 
         return (Artifact[]) list.toArray( new Artifact[0] );
-    }
+    }
+
 
    /**
     * Convert a configuration fragement with an 'artifact' or 'id' 
@@ -271,42 +272,21 @@
     private Artifact createResourceDirective( Configuration config )
        throws ConfigurationException
     {
-        String spec = config.getAttribute( "artifact", null );
-        if( null != spec )
-        {
-            //
-            // we are dealing with the new artifact protocol
-            // within which the # identifies the version
-            //
- 
-            return Artifact.createArtifact( spec );
-        }
-        else
-        {
-            String id = config.getAttribute( "id", null );
-            if( null == id )
-            {
-                final String error = 
-                  "Missing 'artifact' or 'id' attribute.";
-                throw new ConfigurationException( error );
-            }
-            else
-            {
-                //
-                // check for the depricated version attribute and use
-                // the depricated technical of [group]:[name];[version]
-                //
+        String id = config.getAttribute( "id" );
+
+        //
+        // check for the depricated version attribute and use
+        // the depricated technical of [group]:[name];[version]
+        //
 
-                String version = config.getAttribute( "version", null );
-                if( version == null )
-                {
-                    return Artifact.createArtifact( id );
-                }
-                else
-                {
-                    return Artifact.createArtifact( id + ";" + version );
-                }
-            }
+        final String version = config.getAttribute( "version", null );
+        if( version == null )
+        {
+            return Artifact.createArtifact( id );
+        }
+        else
+        {
+            return Artifact.createArtifact( id + ";" + version );
         }
     }
 
@@ -562,13 +542,20 @@
         //
 
         final String name = getBlockIncludeName( config );
-
-        if( config.getAttribute( "id", null ) != null )
-        {
-            Artifact artifact = createResourceDirective( config );
-            TargetDirective[] targets = createTargetDirectives( config );
-            return new BlockCompositionDirective( name, artifact, targets );
-        }
+        if( null != config.getAttribute( "artifact", null ) ) 
+        {
+            String spec = config.getAttribute( "artifact" );
+            Artifact artifact = Artifact.createArtifact( "artifact:" + spec );
+            TargetDirective[] targets = createTargetDirectives( config );
+            return new BlockCompositionDirective( name, artifact, targets );
+        }
+        else if( null != config.getAttribute( "id", null ) )
+        {
+            System.out.println( "Using deprecated include format (see attrifact attribute).");
+            Artifact artifact = createResourceDirective( config );
+            TargetDirective[] targets = createTargetDirectives( config );
+            return new BlockCompositionDirective( name, artifact, targets );
+        }
         else
         {
             final String path = getBlockIncludePath( config );

Modified: avalon/trunk/runtime/meta/tools/src/java/org/apache/avalon/meta/info/ant/MetaTask.java
==============================================================================
--- avalon/trunk/runtime/meta/tools/src/java/org/apache/avalon/meta/info/ant/MetaTask.java
(original)
+++ avalon/trunk/runtime/meta/tools/src/java/org/apache/avalon/meta/info/ant/MetaTask.java
Thu Jul  1 08:26:36 2004
@@ -92,7 +92,7 @@
     /**
      * The preferred postfix value.
      */
-    private String m_postfix = ".xinfo";
+    private String m_postfix = "xinfo";
 
     /**
      * Variable that indicates whether the output
@@ -140,18 +140,33 @@
      */
     public void setPostfix( String postfix )
     {
-        if( postfix.equalsIgnoreCase( "xtype" )
-          || postfix.equalsIgnoreCase( "xinfo" ) )
-        {
-            m_postfix = "." + postfix;
-        }
-        else
-        {
-            final String error = 
-              "Illegal postfix value: " + postfix + ". "
-              + "Recognized values include 'xinfo' and 'xtype'.";
-            throw new BuildException( error );
-        }
+        m_postfix = validatePostfix( postfix );
+    }
+
+    private String getPostfix()
+    {
+        String postfix = getProject().getProperty( "avalon.meta.postfix" );
+        if( null != postfix )
+        {
+            return validatePostfix( postfix );
+        }
+        return m_postfix;
+    }
+
+    private String validatePostfix( String postfix )
+    {
+        if( postfix.equalsIgnoreCase( "xtype" )
+          || postfix.equalsIgnoreCase( "xinfo" ) )
+        {
+            return postfix.toLowerCase();
+        }
+        else
+        {
+            final String error = 
+              "Illegal postfix value: " + postfix + ". "
+              + "Recognized values include 'xinfo' and 'xtype'.";
+            throw new BuildException( error );
+        }
     }
 
     public void addConfigured( FileSet fileset )
@@ -469,7 +484,7 @@
         }
         else
         {
-            filename += m_postfix;
+            filename += "." + getPostfix();
         }
         return new File( m_destDir, filename ).getCanonicalFile();
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message