You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by cf...@apache.org on 2004/08/25 00:57:33 UTC
svn commit: rev 36827 - in avalon/trunk/tools/magic/src/main/org/apache/avalon/tools: model tasks
Author: cfieber
Date: Tue Aug 24 15:57:33 2004
New Revision: 36827
Modified:
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
Log:
patch from Stephen McConnell
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java Tue Aug 24 15:57:33 2004
@@ -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 );
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java Tue Aug 24 15:57:33 2004
@@ -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 );
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java Tue Aug 24 15:57:33 2004
@@ -127,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();
@@ -184,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: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org