avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <mcconn...@apache.org>
Subject [patch] magic
Date Tue, 24 Aug 2004 22:42:41 GMT


The following diff (relative to the tools directory) updates the path,
resource and filter classes to handle the optional creation of ant path
structures without forcing path resolution through a repository.  This
is needed to fix the current gump build problem with merlin-cli.

Steve.



Index: magic/src/main/org/apache/avalon/tools/model/Resource.java
===================================================================
--- magic/src/main/org/apache/avalon/tools/model/Resource.java
(revision 36823)
+++ magic/src/main/org/apache/avalon/tools/model/Resource.java  (working
copy)
@@ -140,6 +140,15 @@
     */
     public Path getPath( final Project project, final int mode )
     {
+        return getPath( project, mode, true );
+    }
+
+   /**
+    * Returns a path of artifact filenames relative to the supplied
scope.
+    * The mode may be one of ANY, BUILD, TEST or RUNTIME.
+    */
+    public Path getPath( final Project project, final int mode, boolean
resolve )
+    {
         if( null == project )
         {
             throw new NullPointerException( "project" );
@@ -147,14 +156,14 @@

         final ArrayList visited = new ArrayList();
         final Path path = new Path( project );
-        final ResourceRef[] refs = getResourceRefs( project, mode,
ResourceRef.ANY, true );
+        final ResourceRef[] refs = getResourceRefs( project, mode,
ResourceRef.ANY, resolve );
         for( int i=0; i<refs.length; i++ )
         {
             final ResourceRef ref = refs[i];
             if( !visited.contains( ref ) )
             {
                 final Resource resource = getResource( project, ref );
-                final File file = resource.getArtifact( project );
+                final File file = resource.getArtifact( project,
resolve );
                 path.createPathElement().setLocation( file );
                 visited.add( ref );
             }
Index: magic/src/main/org/apache/avalon/tools/model/MagicPath.java
===================================================================
--- magic/src/main/org/apache/avalon/tools/model/MagicPath.java
(revision 36823)
+++ magic/src/main/org/apache/avalon/tools/model/MagicPath.java (working
copy)
@@ -41,6 +41,7 @@
     private String m_key;
     private int m_mode = Policy.RUNTIME;
     private boolean m_initialized = false;
+    private boolean m_resolve = true;

    /**
     * Creation of a new path relative to a supplied project.
@@ -65,6 +66,18 @@
     }

    /**
+    * Set the policy concerning path resolution.  By default a path
+    * structure will only be returned if it can be fully resolved.
Setting
+    * the resolve flag to false disables repository resolution of path
entries.
+    *
+    * @param flag the resolve flag
+    */
+    public void setResolve( final boolean flag )
+    {
+        m_resolve = flag;
+    }
+
+   /**
     * Set the path creation mode. A mode value may be one of
     * ANY, BUILD, TEST or RUNTIME.
     *
@@ -72,7 +85,6 @@
     */
     public void setMode( final String mode )
     {
-        System.out.println( "#MODE:" + mode );
         if( "ANY".equalsIgnoreCase( mode ) )
         {
             m_mode = Policy.ANY;
@@ -158,7 +170,7 @@

         if( null != m_key && "jar".equals( def.getInfo().getType() ) )
         {
-            final File file = def.getArtifact( getProject() );
+            final File file = def.getArtifact( getProject(), m_resolve
);
             path.createPathElement().setLocation( file );
         }

Index: magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
===================================================================
--- magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
(revision 36823)
+++ magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
(working copy)
@@ -105,6 +105,8 @@
             return;
         }

+        log( "Processing feature: " + m_feature, Project.MSG_VERBOSE );
+
         final String value = getFeature();
         if( null != value )
         {
@@ -125,6 +127,7 @@
     {
         final ResourceRef ref = new ResourceRef( m_key );
         final Resource resource = getHome().getResource( ref );
+
         if( m_feature.equals( "name" ) )
         {
             return resource.getInfo().getName();
@@ -182,6 +185,7 @@
         MagicPath path = new MagicPath( getProject() );
         path.setMode( "RUNTIME" );
         path.setKey( def.getKey() );
+        path.setResolve( false );
         String sequence = path.toString();
         String[] translation = Path.translatePath( getProject(),
sequence );




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


Mime
View raw message