svn commit: rev 21158 - avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Sat Jun 12 23:42:20 2004
New Revision: 21158

Modified:
   avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/FilterTask.java
   avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
Log:
1. Add support for the generation of platform specific classpaths values.
2. improve the prepare task to enable customization of filter incalues and excludes

Modified: avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/FilterTask.java
==============================================================================
--- avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/FilterTask.java	(original)
+++ avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/FilterTask.java	Sat Jun 12 23:42:20 2004
@@ -35,6 +35,7 @@
 import org.apache.avalon.tools.project.Resource;
 import org.apache.avalon.tools.project.Definition;
 import org.apache.avalon.tools.project.ResourceRef;
+import org.apache.avalon.tools.project.Policy;
 
 /**
  * Build a set of projects taking into account dependencies within the 
@@ -124,6 +125,96 @@
         {
             return resource.getInfo().getURI();
         }
-        return null;        
+        else if( resource instanceof Definition )
+        {
+            Definition def = (Definition) resource;
+            if( m_feature.equals( "system-classpath-for-windows" ) )
+            {
+                return getPath( def, true );
+            }
+            else if( m_feature.equals( "system-classpath-for-unix" ) )
+            {
+                return getPath( def, false );
+            }
+        }
+        return null;
+    }
+
+    private String getPath( Definition def, boolean windows )
+    {
+        StringBuffer buffer = new StringBuffer();
+        String symbol = getPlatformCacheSymbol( windows );
+        ResourceRef[] refs = 
+          def.getResourceRefs( Policy.RUNTIME, ResourceRef.ANY, true );
+        for( int i=0; i<refs.length; i++ )
+        {
+            if( i>0 )
+            {
+                buffer.append( File.pathSeparator );
+            }
+
+            ResourceRef ref = refs[i];
+            Resource resource = getHome().getResource( ref );
+            buffer.append( symbol );
+            if( windows )
+            {
+                buffer.append( "\\" );
+                buffer.append( resource.getInfo().getPath().replace( '/', '\\' ) );
+            }
+            else
+            {
+                buffer.append( "/" );
+                String path = resource.getInfo().getPath();
+            }
+        }
+        return buffer.toString();
+    }
+
+    private String getPlatformCacheSymbol( boolean windows )
+    {
+        if( windows )
+        {
+            return "%SYSTEM_CACHE_DIRECTORY%";
+        }
+        else
+        {
+            return "$SYSTEM_CACHE_DIRECTORY";
+        } 
+    }
+    
+    public static class Attribute
+    {
+        private String m_name;
+        private String m_value;
+       
+        public Attribute()
+        {
+        }
+
+        public Attribute( final String name, final String value )
+        {
+            m_name = name;
+            m_value = value;
+        }
+
+        public void setName( String name )
+        {
+            m_name = name;
+        }
+
+        public void setValue( String value )
+        {
+            m_value = value;
+        }
+
+        public String getName()
+        {
+            return m_name;
+        }
+
+        public String getValue()
+        {
+            return m_value;
+        }
     }
 }

Modified: avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
==============================================================================
--- avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/PrepareTask.java	(original)
+++ avalon/trunk/tools/project/src/main/org/apache/avalon/tools/tasks/PrepareTask.java	Sat Jun 12 23:42:20 2004
@@ -51,7 +51,12 @@
     private static final String ETC_FILTERED_INCLUDES_KEY = 
       "project.prepare.etc.filtered.includes";
     private static final String ETC_FILTERED_INCLUDES_VALUE = 
-      "**/*.java,**/*.x*,**/*.properties";
+      "**/*";
+
+    private static final String ETC_FILTERED_EXCLUDES_KEY = 
+      "project.prepare.etc.filtered.excludes";
+    private static final String ETC_FILTERED_EXCLUDES_VALUE = 
+      "**/*.exe,**/*.jar*,**/*.gif,**/*.jpeg,**/*.jpg";
 
     public void init() throws BuildException 
     {
@@ -63,6 +68,8 @@
               SRC_FILTERED_INCLUDES_KEY, SRC_FILTERED_INCLUDES_VALUE );
             project.setNewProperty(
               ETC_FILTERED_INCLUDES_KEY, ETC_FILTERED_INCLUDES_VALUE );
+            project.setNewProperty(
+              ETC_FILTERED_EXCLUDES_KEY, ETC_FILTERED_EXCLUDES_VALUE );
         }
     }
 
@@ -113,9 +120,10 @@
         if( etc.exists() )
         {
             File buildEtcDir = new File( build, "etc" );
-            String filters = project.getProperty( ETC_FILTERED_INCLUDES_KEY );
-            copy( etc, buildEtcDir, true, filters, "" );
-            copy( etc, buildEtcDir, false, "**/*", filters );
+            String includes = project.getProperty( ETC_FILTERED_INCLUDES_KEY );
+            String excludes = project.getProperty( ETC_FILTERED_EXCLUDES_KEY );
+            copy( etc, buildEtcDir, true, includes, excludes );
+            copy( etc, buildEtcDir, false, excludes, "" );
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.