git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270831 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -200,7 +200,7 @@ public class Expand extends MatchingTask | |||
| for( int v = 0; v < patternsets.size(); v++ ) | |||
| { | |||
| PatternSet p = (PatternSet)patternsets.get( v ); | |||
| String[] incls = p.getIncludePatterns( null ); | |||
| String[] incls = p.getIncludePatterns( getContext() ); | |||
| if( incls != null ) | |||
| { | |||
| for( int w = 0; w < incls.length; w++ ) | |||
| @@ -213,7 +213,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| } | |||
| String[] excls = p.getExcludePatterns( null ); | |||
| String[] excls = p.getExcludePatterns( getContext() ); | |||
| if( excls != null ) | |||
| { | |||
| for( int w = 0; w < excls.length; w++ ) | |||
| @@ -9,10 +9,10 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| @@ -93,7 +93,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createExclude(); | |||
| @@ -104,7 +104,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createExcludesFile(); | |||
| @@ -115,7 +115,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createInclude(); | |||
| @@ -126,7 +126,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createIncludesFile(); | |||
| @@ -9,8 +9,8 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| /** | |||
| * Export packages from the Visual Age for Java workspace. The packages are | |||
| @@ -144,7 +144,7 @@ public class VAJExport extends VAJTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return patternSet.createExclude(); | |||
| } | |||
| @@ -154,7 +154,7 @@ public class VAJExport extends VAJTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return patternSet.createInclude(); | |||
| } | |||
| @@ -175,8 +175,8 @@ public class VAJExport extends VAJTask | |||
| // delegate the export to the VAJUtil object. | |||
| getUtil().exportPackages( destDir, | |||
| patternSet.getIncludePatterns( null ), | |||
| patternSet.getExcludePatterns( null ), | |||
| patternSet.getIncludePatterns( getContext() ), | |||
| patternSet.getExcludePatterns( getContext() ), | |||
| exportClasses, exportDebugInfo, | |||
| exportResources, exportSources, | |||
| useDefaultExcludes, overwrite ); | |||
| @@ -11,11 +11,11 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| @@ -119,7 +119,7 @@ public class Chmod | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| throws TaskException | |||
| { | |||
| m_defaultSetDefined = true; | |||
| @@ -131,7 +131,7 @@ public class Chmod | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| throws TaskException | |||
| { | |||
| m_defaultSetDefined = true; | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| /** | |||
| @@ -34,10 +35,6 @@ public class FileSet | |||
| private boolean m_isCaseSensitive = true; | |||
| private File m_dir; | |||
| public FileSet() | |||
| { | |||
| } | |||
| /** | |||
| * Sets case sensitivity of the file system | |||
| */ | |||
| @@ -76,9 +73,9 @@ public class FileSet | |||
| * | |||
| * @param excl The file to fetch the exclude patterns from. | |||
| */ | |||
| public void setExcludesfile( final File excl ) | |||
| public void setExcludesfile( final File excludesfile ) | |||
| { | |||
| m_defaultPatterns.setExcludesfile( excl ); | |||
| m_defaultPatterns.setExcludesfile( excludesfile ); | |||
| } | |||
| /** | |||
| @@ -87,7 +84,7 @@ public class FileSet | |||
| * | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes( String includes ) | |||
| public void setIncludes( final String includes ) | |||
| { | |||
| m_defaultPatterns.setIncludes( includes ); | |||
| } | |||
| @@ -97,9 +94,9 @@ public class FileSet | |||
| * | |||
| * @param incl The file to fetch the include patterns from. | |||
| */ | |||
| public void setIncludesfile( File incl ) | |||
| public void setIncludesfile( final File includesfile ) | |||
| { | |||
| m_defaultPatterns.setIncludesfile( incl ); | |||
| m_defaultPatterns.setIncludesfile( includesfile ); | |||
| } | |||
| public void setupDirectoryScanner( final FileScanner ds ) | |||
| @@ -124,8 +121,8 @@ public class FileSet | |||
| m_dir + " with " + m_defaultPatterns; | |||
| getLogger().debug( message ); | |||
| ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) ); | |||
| ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) ); | |||
| ds.setIncludes( m_defaultPatterns.getIncludePatterns( getContext() ) ); | |||
| ds.setExcludes( m_defaultPatterns.getExcludePatterns( getContext() ) ); | |||
| if( m_useDefaultExcludes ) | |||
| { | |||
| ds.addDefaultExcludes(); | |||
| @@ -167,7 +164,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the exclude list | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return m_defaultPatterns.createExclude(); | |||
| } | |||
| @@ -175,7 +172,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| { | |||
| return m_defaultPatterns.createExcludesFile(); | |||
| } | |||
| @@ -183,7 +180,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return m_defaultPatterns.createInclude(); | |||
| } | |||
| @@ -191,7 +188,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| { | |||
| return m_defaultPatterns.createIncludesFile(); | |||
| } | |||
| @@ -1,89 +0,0 @@ | |||
| /* | |||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||
| * | |||
| * This software is published under the terms of the Apache Software License | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE.txt file. | |||
| */ | |||
| package org.apache.tools.ant.types; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * inner class to hold a name on list. "If" and "Unless" attributes may be | |||
| * used to invalidate the entry based on the existence of a property | |||
| * (typically set thru the use of the Available task). | |||
| */ | |||
| public class NameEntry | |||
| { | |||
| private String m_if; | |||
| private String m_name; | |||
| private String m_unless; | |||
| private PatternSet m_set; | |||
| public NameEntry( final PatternSet set ) | |||
| { | |||
| m_set = set; | |||
| } | |||
| public void setIf( final String ifCondition ) | |||
| { | |||
| m_if = ifCondition; | |||
| } | |||
| public void setName( final String name ) | |||
| { | |||
| m_name = name; | |||
| } | |||
| public void setUnless( final String unlessCondition ) | |||
| { | |||
| m_unless = unlessCondition; | |||
| } | |||
| public String evalName( Project p ) | |||
| { | |||
| return valid( p ) ? m_name : null; | |||
| } | |||
| public String toString() | |||
| { | |||
| StringBuffer buf = new StringBuffer( m_name ); | |||
| if( ( m_if != null ) || ( m_unless != null ) ) | |||
| { | |||
| buf.append( ":" ); | |||
| String connector = ""; | |||
| if( m_if != null ) | |||
| { | |||
| buf.append( "if->" ); | |||
| buf.append( m_if ); | |||
| connector = ";"; | |||
| } | |||
| if( m_unless != null ) | |||
| { | |||
| buf.append( connector ); | |||
| buf.append( "unless->" ); | |||
| buf.append( m_unless ); | |||
| } | |||
| } | |||
| return buf.toString(); | |||
| } | |||
| private boolean valid( Project p ) | |||
| { | |||
| if( m_if != null && p.getProperty( m_if ) == null ) | |||
| { | |||
| return false; | |||
| } | |||
| else if( m_unless != null && p.getProperty( m_unless ) != null ) | |||
| { | |||
| return false; | |||
| } | |||
| else | |||
| { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| @@ -14,7 +14,9 @@ import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| @@ -93,36 +95,27 @@ public class PatternSet | |||
| /** | |||
| * Sets the name of the file containing the includes patterns. | |||
| * | |||
| * @param includesFile The file to fetch the include patterns from. | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| public void setIncludesfile( File includesFile ) | |||
| { | |||
| createIncludesFile().setName( includesFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| * Returns the filtered include patterns. | |||
| */ | |||
| public String[] getExcludePatterns( Project p ) | |||
| public String[] getExcludePatterns( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| readFiles( p ); | |||
| return makeArray( m_excludeList ); | |||
| readFiles( context ); | |||
| return makeArray( m_excludeList, context ); | |||
| } | |||
| /** | |||
| * Returns the filtered include patterns. | |||
| * | |||
| * @param p Description of Parameter | |||
| * @return The IncludePatterns value | |||
| */ | |||
| public String[] getIncludePatterns( Project p ) | |||
| public String[] getIncludePatterns( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| readFiles( p ); | |||
| return makeArray( m_includeList ); | |||
| readFiles( context ); | |||
| return makeArray( m_includeList, context ); | |||
| } | |||
| /** | |||
| @@ -131,7 +124,7 @@ public class PatternSet | |||
| protected void append( PatternSet other ) | |||
| throws TaskException | |||
| { | |||
| String[] incl = other.getIncludePatterns( null ); | |||
| String[] incl = other.getIncludePatterns( (TaskContext)null ); | |||
| if( incl != null ) | |||
| { | |||
| for( int i = 0; i < incl.length; i++ ) | |||
| @@ -140,7 +133,7 @@ public class PatternSet | |||
| } | |||
| } | |||
| String[] excl = other.getExcludePatterns( null ); | |||
| String[] excl = other.getExcludePatterns( (TaskContext)null ); | |||
| if( excl != null ) | |||
| { | |||
| for( int i = 0; i < excl.length; i++ ) | |||
| @@ -155,7 +148,7 @@ public class PatternSet | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return addPatternToList( m_excludeList ); | |||
| } | |||
| @@ -165,7 +158,7 @@ public class PatternSet | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| { | |||
| return addPatternToList( m_excludesFileList ); | |||
| } | |||
| @@ -173,7 +166,7 @@ public class PatternSet | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return addPatternToList( m_includeList ); | |||
| } | |||
| @@ -181,7 +174,7 @@ public class PatternSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| { | |||
| return addPatternToList( m_includesFileList ); | |||
| } | |||
| @@ -204,17 +197,17 @@ public class PatternSet | |||
| /** | |||
| * add a name entry to the given list | |||
| */ | |||
| private NameEntry addPatternToList( final ArrayList list ) | |||
| private Pattern addPatternToList( final ArrayList list ) | |||
| { | |||
| final NameEntry result = new NameEntry( this ); | |||
| final Pattern result = new Pattern(); | |||
| list.add( result ); | |||
| return result; | |||
| } | |||
| /** | |||
| * Convert a vector of NameEntry elements into an array of Strings. | |||
| * Convert a vector of Pattern elements into an array of Strings. | |||
| */ | |||
| private String[] makeArray( final ArrayList list ) | |||
| private String[] makeArray( final ArrayList list, final TaskContext context ) | |||
| { | |||
| if( list.size() == 0 ) | |||
| { | |||
| @@ -224,8 +217,8 @@ public class PatternSet | |||
| final ArrayList tmpNames = new ArrayList(); | |||
| for( Iterator e = list.iterator(); e.hasNext(); ) | |||
| { | |||
| final NameEntry ne = (NameEntry)e.next(); | |||
| final String pattern = ne.evalName( null ); | |||
| final Pattern ne = (Pattern)e.next(); | |||
| final String pattern = ne.evaluateName( context ); | |||
| if( pattern != null && pattern.length() > 0 ) | |||
| { | |||
| tmpNames.add( pattern ); | |||
| @@ -239,7 +232,7 @@ public class PatternSet | |||
| /** | |||
| * Read includesfile ot excludesfile if not already done so. | |||
| */ | |||
| private void readFiles( Project p ) | |||
| private void readFiles( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| if( m_includesFileList.size() > 0 ) | |||
| @@ -247,17 +240,18 @@ public class PatternSet | |||
| Iterator e = m_includesFileList.iterator(); | |||
| while( e.hasNext() ) | |||
| { | |||
| NameEntry ne = (NameEntry)e.next(); | |||
| String fileName = ne.evalName( p ); | |||
| Pattern ne = (Pattern)e.next(); | |||
| String fileName = ne.evaluateName( (TaskContext)null ); | |||
| if( fileName != null ) | |||
| { | |||
| File inclFile = resolveFile( fileName ); | |||
| if( !inclFile.exists() ) { | |||
| if( !inclFile.exists() ) | |||
| { | |||
| throw new TaskException( "Includesfile " | |||
| + inclFile.getAbsolutePath() | |||
| + " not found." ); | |||
| } | |||
| readPatterns( inclFile, m_includeList, p ); | |||
| readPatterns( inclFile, m_includeList, null ); | |||
| } | |||
| } | |||
| m_includesFileList.clear(); | |||
| @@ -268,17 +262,18 @@ public class PatternSet | |||
| Iterator e = m_excludesFileList.iterator(); | |||
| while( e.hasNext() ) | |||
| { | |||
| NameEntry ne = (NameEntry)e.next(); | |||
| String fileName = ne.evalName( p ); | |||
| Pattern ne = (Pattern)e.next(); | |||
| String fileName = ne.evaluateName( null ); | |||
| if( fileName != null ) | |||
| { | |||
| File exclFile = resolveFile( fileName ); | |||
| if( !exclFile.exists() ) { | |||
| if( !exclFile.exists() ) | |||
| { | |||
| throw new TaskException( "Excludesfile " | |||
| + exclFile.getAbsolutePath() | |||
| + " not found." ); | |||
| } | |||
| readPatterns( exclFile, m_excludeList, p ); | |||
| readPatterns( exclFile, m_excludeList, null ); | |||
| } | |||
| } | |||
| m_excludesFileList.clear(); | |||
| @@ -305,7 +300,7 @@ public class PatternSet | |||
| patternReader = | |||
| new BufferedReader( new FileReader( patternfile ) ); | |||
| // Create one NameEntry in the appropriate pattern list for each | |||
| // Create one Pattern in the appropriate pattern list for each | |||
| // line in the file. | |||
| String line = patternReader.readLine(); | |||
| while( line != null ) | |||
| @@ -200,7 +200,7 @@ public class Expand extends MatchingTask | |||
| for( int v = 0; v < patternsets.size(); v++ ) | |||
| { | |||
| PatternSet p = (PatternSet)patternsets.get( v ); | |||
| String[] incls = p.getIncludePatterns( null ); | |||
| String[] incls = p.getIncludePatterns( getContext() ); | |||
| if( incls != null ) | |||
| { | |||
| for( int w = 0; w < incls.length; w++ ) | |||
| @@ -213,7 +213,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| } | |||
| String[] excls = p.getExcludePatterns( null ); | |||
| String[] excls = p.getExcludePatterns( getContext() ); | |||
| if( excls != null ) | |||
| { | |||
| for( int w = 0; w < excls.length; w++ ) | |||
| @@ -9,10 +9,10 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| @@ -93,7 +93,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createExclude(); | |||
| @@ -104,7 +104,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createExcludesFile(); | |||
| @@ -115,7 +115,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createInclude(); | |||
| @@ -126,7 +126,7 @@ public abstract class MatchingTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| throws TaskException | |||
| { | |||
| return m_fileset.createIncludesFile(); | |||
| @@ -9,8 +9,8 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| /** | |||
| * Export packages from the Visual Age for Java workspace. The packages are | |||
| @@ -144,7 +144,7 @@ public class VAJExport extends VAJTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return patternSet.createExclude(); | |||
| } | |||
| @@ -154,7 +154,7 @@ public class VAJExport extends VAJTask | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return patternSet.createInclude(); | |||
| } | |||
| @@ -175,8 +175,8 @@ public class VAJExport extends VAJTask | |||
| // delegate the export to the VAJUtil object. | |||
| getUtil().exportPackages( destDir, | |||
| patternSet.getIncludePatterns( null ), | |||
| patternSet.getExcludePatterns( null ), | |||
| patternSet.getIncludePatterns( getContext() ), | |||
| patternSet.getExcludePatterns( getContext() ), | |||
| exportClasses, exportDebugInfo, | |||
| exportResources, exportSources, | |||
| useDefaultExcludes, overwrite ); | |||
| @@ -11,11 +11,11 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| @@ -119,7 +119,7 @@ public class Chmod | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| throws TaskException | |||
| { | |||
| m_defaultSetDefined = true; | |||
| @@ -131,7 +131,7 @@ public class Chmod | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| throws TaskException | |||
| { | |||
| m_defaultSetDefined = true; | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| /** | |||
| @@ -34,10 +35,6 @@ public class FileSet | |||
| private boolean m_isCaseSensitive = true; | |||
| private File m_dir; | |||
| public FileSet() | |||
| { | |||
| } | |||
| /** | |||
| * Sets case sensitivity of the file system | |||
| */ | |||
| @@ -76,9 +73,9 @@ public class FileSet | |||
| * | |||
| * @param excl The file to fetch the exclude patterns from. | |||
| */ | |||
| public void setExcludesfile( final File excl ) | |||
| public void setExcludesfile( final File excludesfile ) | |||
| { | |||
| m_defaultPatterns.setExcludesfile( excl ); | |||
| m_defaultPatterns.setExcludesfile( excludesfile ); | |||
| } | |||
| /** | |||
| @@ -87,7 +84,7 @@ public class FileSet | |||
| * | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes( String includes ) | |||
| public void setIncludes( final String includes ) | |||
| { | |||
| m_defaultPatterns.setIncludes( includes ); | |||
| } | |||
| @@ -97,9 +94,9 @@ public class FileSet | |||
| * | |||
| * @param incl The file to fetch the include patterns from. | |||
| */ | |||
| public void setIncludesfile( File incl ) | |||
| public void setIncludesfile( final File includesfile ) | |||
| { | |||
| m_defaultPatterns.setIncludesfile( incl ); | |||
| m_defaultPatterns.setIncludesfile( includesfile ); | |||
| } | |||
| public void setupDirectoryScanner( final FileScanner ds ) | |||
| @@ -124,8 +121,8 @@ public class FileSet | |||
| m_dir + " with " + m_defaultPatterns; | |||
| getLogger().debug( message ); | |||
| ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) ); | |||
| ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) ); | |||
| ds.setIncludes( m_defaultPatterns.getIncludePatterns( getContext() ) ); | |||
| ds.setExcludes( m_defaultPatterns.getExcludePatterns( getContext() ) ); | |||
| if( m_useDefaultExcludes ) | |||
| { | |||
| ds.addDefaultExcludes(); | |||
| @@ -167,7 +164,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the exclude list | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return m_defaultPatterns.createExclude(); | |||
| } | |||
| @@ -175,7 +172,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| { | |||
| return m_defaultPatterns.createExcludesFile(); | |||
| } | |||
| @@ -183,7 +180,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return m_defaultPatterns.createInclude(); | |||
| } | |||
| @@ -191,7 +188,7 @@ public class FileSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| { | |||
| return m_defaultPatterns.createIncludesFile(); | |||
| } | |||
| @@ -1,89 +0,0 @@ | |||
| /* | |||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||
| * | |||
| * This software is published under the terms of the Apache Software License | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE.txt file. | |||
| */ | |||
| package org.apache.tools.ant.types; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * inner class to hold a name on list. "If" and "Unless" attributes may be | |||
| * used to invalidate the entry based on the existence of a property | |||
| * (typically set thru the use of the Available task). | |||
| */ | |||
| public class NameEntry | |||
| { | |||
| private String m_if; | |||
| private String m_name; | |||
| private String m_unless; | |||
| private PatternSet m_set; | |||
| public NameEntry( final PatternSet set ) | |||
| { | |||
| m_set = set; | |||
| } | |||
| public void setIf( final String ifCondition ) | |||
| { | |||
| m_if = ifCondition; | |||
| } | |||
| public void setName( final String name ) | |||
| { | |||
| m_name = name; | |||
| } | |||
| public void setUnless( final String unlessCondition ) | |||
| { | |||
| m_unless = unlessCondition; | |||
| } | |||
| public String evalName( Project p ) | |||
| { | |||
| return valid( p ) ? m_name : null; | |||
| } | |||
| public String toString() | |||
| { | |||
| StringBuffer buf = new StringBuffer( m_name ); | |||
| if( ( m_if != null ) || ( m_unless != null ) ) | |||
| { | |||
| buf.append( ":" ); | |||
| String connector = ""; | |||
| if( m_if != null ) | |||
| { | |||
| buf.append( "if->" ); | |||
| buf.append( m_if ); | |||
| connector = ";"; | |||
| } | |||
| if( m_unless != null ) | |||
| { | |||
| buf.append( connector ); | |||
| buf.append( "unless->" ); | |||
| buf.append( m_unless ); | |||
| } | |||
| } | |||
| return buf.toString(); | |||
| } | |||
| private boolean valid( Project p ) | |||
| { | |||
| if( m_if != null && p.getProperty( m_if ) == null ) | |||
| { | |||
| return false; | |||
| } | |||
| else if( m_unless != null && p.getProperty( m_unless ) != null ) | |||
| { | |||
| return false; | |||
| } | |||
| else | |||
| { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| @@ -14,7 +14,9 @@ import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| @@ -93,36 +95,27 @@ public class PatternSet | |||
| /** | |||
| * Sets the name of the file containing the includes patterns. | |||
| * | |||
| * @param includesFile The file to fetch the include patterns from. | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| public void setIncludesfile( File includesFile ) | |||
| { | |||
| createIncludesFile().setName( includesFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| * Returns the filtered include patterns. | |||
| */ | |||
| public String[] getExcludePatterns( Project p ) | |||
| public String[] getExcludePatterns( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| readFiles( p ); | |||
| return makeArray( m_excludeList ); | |||
| readFiles( context ); | |||
| return makeArray( m_excludeList, context ); | |||
| } | |||
| /** | |||
| * Returns the filtered include patterns. | |||
| * | |||
| * @param p Description of Parameter | |||
| * @return The IncludePatterns value | |||
| */ | |||
| public String[] getIncludePatterns( Project p ) | |||
| public String[] getIncludePatterns( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| readFiles( p ); | |||
| return makeArray( m_includeList ); | |||
| readFiles( context ); | |||
| return makeArray( m_includeList, context ); | |||
| } | |||
| /** | |||
| @@ -131,7 +124,7 @@ public class PatternSet | |||
| protected void append( PatternSet other ) | |||
| throws TaskException | |||
| { | |||
| String[] incl = other.getIncludePatterns( null ); | |||
| String[] incl = other.getIncludePatterns( (TaskContext)null ); | |||
| if( incl != null ) | |||
| { | |||
| for( int i = 0; i < incl.length; i++ ) | |||
| @@ -140,7 +133,7 @@ public class PatternSet | |||
| } | |||
| } | |||
| String[] excl = other.getExcludePatterns( null ); | |||
| String[] excl = other.getExcludePatterns( (TaskContext)null ); | |||
| if( excl != null ) | |||
| { | |||
| for( int i = 0; i < excl.length; i++ ) | |||
| @@ -155,7 +148,7 @@ public class PatternSet | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExclude() | |||
| public Pattern createExclude() | |||
| { | |||
| return addPatternToList( m_excludeList ); | |||
| } | |||
| @@ -165,7 +158,7 @@ public class PatternSet | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| public NameEntry createExcludesFile() | |||
| public Pattern createExcludesFile() | |||
| { | |||
| return addPatternToList( m_excludesFileList ); | |||
| } | |||
| @@ -173,7 +166,7 @@ public class PatternSet | |||
| /** | |||
| * add a name entry on the include list | |||
| */ | |||
| public NameEntry createInclude() | |||
| public Pattern createInclude() | |||
| { | |||
| return addPatternToList( m_includeList ); | |||
| } | |||
| @@ -181,7 +174,7 @@ public class PatternSet | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public NameEntry createIncludesFile() | |||
| public Pattern createIncludesFile() | |||
| { | |||
| return addPatternToList( m_includesFileList ); | |||
| } | |||
| @@ -204,17 +197,17 @@ public class PatternSet | |||
| /** | |||
| * add a name entry to the given list | |||
| */ | |||
| private NameEntry addPatternToList( final ArrayList list ) | |||
| private Pattern addPatternToList( final ArrayList list ) | |||
| { | |||
| final NameEntry result = new NameEntry( this ); | |||
| final Pattern result = new Pattern(); | |||
| list.add( result ); | |||
| return result; | |||
| } | |||
| /** | |||
| * Convert a vector of NameEntry elements into an array of Strings. | |||
| * Convert a vector of Pattern elements into an array of Strings. | |||
| */ | |||
| private String[] makeArray( final ArrayList list ) | |||
| private String[] makeArray( final ArrayList list, final TaskContext context ) | |||
| { | |||
| if( list.size() == 0 ) | |||
| { | |||
| @@ -224,8 +217,8 @@ public class PatternSet | |||
| final ArrayList tmpNames = new ArrayList(); | |||
| for( Iterator e = list.iterator(); e.hasNext(); ) | |||
| { | |||
| final NameEntry ne = (NameEntry)e.next(); | |||
| final String pattern = ne.evalName( null ); | |||
| final Pattern ne = (Pattern)e.next(); | |||
| final String pattern = ne.evaluateName( context ); | |||
| if( pattern != null && pattern.length() > 0 ) | |||
| { | |||
| tmpNames.add( pattern ); | |||
| @@ -239,7 +232,7 @@ public class PatternSet | |||
| /** | |||
| * Read includesfile ot excludesfile if not already done so. | |||
| */ | |||
| private void readFiles( Project p ) | |||
| private void readFiles( final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| if( m_includesFileList.size() > 0 ) | |||
| @@ -247,17 +240,18 @@ public class PatternSet | |||
| Iterator e = m_includesFileList.iterator(); | |||
| while( e.hasNext() ) | |||
| { | |||
| NameEntry ne = (NameEntry)e.next(); | |||
| String fileName = ne.evalName( p ); | |||
| Pattern ne = (Pattern)e.next(); | |||
| String fileName = ne.evaluateName( (TaskContext)null ); | |||
| if( fileName != null ) | |||
| { | |||
| File inclFile = resolveFile( fileName ); | |||
| if( !inclFile.exists() ) { | |||
| if( !inclFile.exists() ) | |||
| { | |||
| throw new TaskException( "Includesfile " | |||
| + inclFile.getAbsolutePath() | |||
| + " not found." ); | |||
| } | |||
| readPatterns( inclFile, m_includeList, p ); | |||
| readPatterns( inclFile, m_includeList, null ); | |||
| } | |||
| } | |||
| m_includesFileList.clear(); | |||
| @@ -268,17 +262,18 @@ public class PatternSet | |||
| Iterator e = m_excludesFileList.iterator(); | |||
| while( e.hasNext() ) | |||
| { | |||
| NameEntry ne = (NameEntry)e.next(); | |||
| String fileName = ne.evalName( p ); | |||
| Pattern ne = (Pattern)e.next(); | |||
| String fileName = ne.evaluateName( null ); | |||
| if( fileName != null ) | |||
| { | |||
| File exclFile = resolveFile( fileName ); | |||
| if( !exclFile.exists() ) { | |||
| if( !exclFile.exists() ) | |||
| { | |||
| throw new TaskException( "Excludesfile " | |||
| + exclFile.getAbsolutePath() | |||
| + " not found." ); | |||
| } | |||
| readPatterns( exclFile, m_excludeList, p ); | |||
| readPatterns( exclFile, m_excludeList, null ); | |||
| } | |||
| } | |||
| m_excludesFileList.clear(); | |||
| @@ -305,7 +300,7 @@ public class PatternSet | |||
| patternReader = | |||
| new BufferedReader( new FileReader( patternfile ) ); | |||
| // Create one NameEntry in the appropriate pattern list for each | |||
| // Create one Pattern in the appropriate pattern list for each | |||
| // line in the file. | |||
| String line = patternReader.readLine(); | |||
| while( line != null ) | |||