diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/BUnzip2.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/BUnzip2.java deleted file mode 100644 index b3de6b3eb..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/BUnzip2.java +++ /dev/null @@ -1,45 +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.antlib.archive; - -import java.io.IOException; -import java.io.InputStream; -import org.apache.myrmidon.api.TaskException; -import org.apache.excalibur.bzip2.CBZip2InputStream; - -/** - * Expands a file that has been compressed with the BZIP2 algorithm. Normally - * used to compress non-compressed archives such as TAR files. - * - * @author Magesh Umasankar - * @ant.task name="bunzip2" - */ -public class BUnzip2 - extends Unpack -{ - private static final String DEFAULT_EXTENSION = ".bz2"; - - protected String getDefaultExtension() - { - return DEFAULT_EXTENSION; - } - - protected InputStream getUnpackingStream( final InputStream input ) - throws TaskException, IOException - { - final int b1 = input.read(); - final int b2 = input.read(); - if( b1 != 'B' || b2 != 'Z' ) - { - final String message = "Invalid bz2 file."; - throw new TaskException( message ); - } - - return new CBZip2InputStream( input ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/BZip2.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/BZip2.java deleted file mode 100644 index a4ec4d241..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/BZip2.java +++ /dev/null @@ -1,34 +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.antlib.archive; - -import java.io.IOException; -import java.io.OutputStream; -import org.apache.excalibur.bzip2.CBZip2OutputStream; -import org.apache.myrmidon.api.TaskException; - -/** - * Compresses a file with the BZip2 algorithm. Normally used to compress - * non-compressed archives such as TAR files. - * - * @author Magesh Umasankar - * @author Peter Donald - * @ant.task name="bzip2" - */ -public class BZip2 - extends Pack -{ - private static final byte[] HEADER = new byte[]{(byte)'B', (byte)'Z'}; - - protected OutputStream getPackingStream( OutputStream output ) - throws TaskException, IOException - { - output.write( HEADER ); - return new CBZip2OutputStream( output ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/GUnzip.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/GUnzip.java deleted file mode 100644 index e77b37e4e..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/GUnzip.java +++ /dev/null @@ -1,38 +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.antlib.archive; - -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.GZIPInputStream; -import org.apache.myrmidon.api.TaskException; - -/** - * Expands a file that has been compressed with the GZIP algorithm. Normally - * used to compress non-compressed archives such as TAR files. - * - * @author Stefan Bodewig - * @author Magesh Umasankar - * @ant.task name="gunzip" - */ -public class GUnzip - extends Unpack -{ - private static final String DEFAULT_EXTENSION = ".gz"; - - protected String getDefaultExtension() - { - return DEFAULT_EXTENSION; - } - - protected InputStream getUnpackingStream( InputStream input ) - throws TaskException, IOException - { - return new GZIPInputStream( input ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/GZip.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/GZip.java deleted file mode 100644 index 055098f0e..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/GZip.java +++ /dev/null @@ -1,33 +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.antlib.archive; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.GZIPOutputStream; -import org.apache.myrmidon.api.TaskException; - -/** - * Compresses a file with the GZIP algorithm. Normally used to compress - * non-compressed archives such as TAR files. - * - * @author James Davidson duncan@x180.com - * @author Jon S. Stevens jon@clearink.com - * @author Magesh Umasankar - * @author Peter Donald - * @ant.task name="gzip" - */ -public class GZip - extends Pack -{ - protected OutputStream getPackingStream( final OutputStream output ) - throws TaskException, IOException - { - return new GZIPOutputStream( output ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/Pack.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/Pack.java deleted file mode 100644 index dc753687b..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/Pack.java +++ /dev/null @@ -1,121 +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.antlib.archive; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import org.apache.avalon.excalibur.io.IOUtil; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; - -/** - * Abstract Base class for pack tasks. - * - * @author Magesh Umasankar - * @author Peter Donald - */ -public abstract class Pack - extends AbstractTask -{ - private File m_src; - private File m_zipFile; - - public void setSrc( final File src ) - { - m_src = src; - } - - public void setZipfile( final File zipFile ) - { - m_zipFile = zipFile; - } - - public void execute() - throws TaskException - { - validate(); - final String message = "Building: " + m_zipFile.getAbsolutePath(); - getContext().verbose( message ); - pack(); - } - - private void pack() - throws TaskException - { - OutputStream output = null; - try - { - final FileOutputStream fileOutput = new FileOutputStream( getZipFile() ); - output = getPackingStream( fileOutput ); - copy( getSrc(), output ); - } - catch( final IOException ioe ) - { - final String message = "Problem creating " + getContext().getName() + - ":" + ioe.getMessage(); - throw new TaskException( message, ioe ); - } - finally - { - IOUtil.shutdownStream( output ); - } - } - - protected abstract OutputStream getPackingStream( OutputStream output ) - throws TaskException, IOException; - - protected final void copy( final File file, final OutputStream output ) - throws IOException - { - final FileInputStream input = new FileInputStream( file ); - try - { - IOUtil.copy( input, output ); - } - finally - { - IOUtil.shutdownStream( input ); - } - } - - private void validate() - throws TaskException - { - if( null == m_zipFile ) - { - final String message = "zipfile attribute is required"; - throw new TaskException( message ); - } - - if( null == m_src ) - { - final String message = "src attribute is required"; - throw new TaskException( message ); - } - - if( m_src.isDirectory() ) - { - final String message = "Src attribute must not " + - "represent a directory!"; - throw new TaskException( message ); - } - } - - protected final File getSrc() - { - return m_src; - } - - protected final File getZipFile() - { - return m_zipFile; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/archive/Unpack.java b/proposal/myrmidon/src/java/org/apache/antlib/archive/Unpack.java deleted file mode 100644 index 96b4f670d..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/archive/Unpack.java +++ /dev/null @@ -1,154 +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.antlib.archive; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.apache.avalon.excalibur.io.IOUtil; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; - -/** - * Abstract Base class for unpack tasks. - * - * @author Magesh Umasankar - * @author Peter Donald - * @author Stefan Bodewig - */ -public abstract class Unpack - extends AbstractTask -{ - private File m_dest; - private File m_src; - - public void setDest( final File dest ) - { - m_dest = dest; - } - - public void setSrc( final File src ) - { - m_src = src; - } - - public void execute() - throws TaskException - { - validate(); - - final File src = getSrc(); - final File dest = getDest(); - - if( src.lastModified() > dest.lastModified() ) - { - final String message = "Expanding " + src.getAbsolutePath() + - " to " + dest.getAbsolutePath(); - getContext().verbose( message ); - - extract(); - } - } - - protected abstract String getDefaultExtension(); - - protected abstract InputStream getUnpackingStream( InputStream input ) - throws TaskException, IOException; - - private void extract() - throws TaskException - { - OutputStream output = null; - InputStream input = null; - InputStream fileInput = null; - try - { - output = new FileOutputStream( getDest() ); - fileInput = new FileInputStream( getSrc() ); - input = getUnpackingStream( fileInput ); - IOUtil.copy( input, output ); - } - catch( final IOException ioe ) - { - final String message = "Problem expanding " + getSrc() + - ":" + ioe.getMessage(); - throw new TaskException( message, ioe ); - } - finally - { - IOUtil.shutdownStream( fileInput ); - IOUtil.shutdownStream( output ); - IOUtil.shutdownStream( input ); - } - } - - private File createDestFile() - { - final String extension = getDefaultExtension(); - final String sourceName = m_src.getName(); - final int length = sourceName.length(); - final int index = length - extension.length(); - - if( null != extension && - length > extension.length() && - extension.equalsIgnoreCase( sourceName.substring( index ) ) ) - { - final String child = sourceName.substring( 0, index ); - return new File( m_dest, child ); - } - else - { - return new File( m_dest, sourceName ); - } - } - - private void validate() - throws TaskException - { - if( null == m_src ) - { - final String message = "No Src for " + getContext().getName() + " specified"; - throw new TaskException( message ); - } - - if( !m_src.exists() ) - { - final String message = "Src doesn't exist"; - throw new TaskException( message ); - } - - if( m_src.isDirectory() ) - { - final String message = "Cannot expand a directory"; - throw new TaskException( message ); - } - - if( null == m_dest ) - { - m_dest = new File( m_src.getParent() ); - } - - if( m_dest.isDirectory() ) - { - m_dest = createDestFile(); - } - } - - protected final File getDest() - { - return m_dest; - } - - protected final File getSrc() - { - return m_src; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/BuildNumber.java b/proposal/myrmidon/src/java/org/apache/antlib/build/BuildNumber.java deleted file mode 100644 index 023a90568..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/BuildNumber.java +++ /dev/null @@ -1,200 +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.antlib.build; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.excalibur.io.IOUtil; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; - -/** - * This is a basic task that can be used to track build numbers. - * - * It will first attempt to read a build number from a file, then - * set the property "build.number" to the value that was read in - * (or 0 if no such value). Then it will increment the build number - * by one and write it back out into the file. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant.task name="build-number" - */ -public class BuildNumber - extends AbstractTask -{ - private static final Resources REZ = - ResourceManager.getPackageResources( BuildNumber.class ); - - /** - * The name of the property in which the build number is stored. - */ - private static final String DEFAULT_PROPERTY_NAME = "build.number"; - - /** - * The default filename to use if no file specified. - */ - private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; - - /** - * The File in which the build number is stored. - */ - private File m_file; - - /** - * Specify the file in which the build numberis stored. - * Defaults to "build.number" if not specified. - * - * @param file the file in which build number is stored. - */ - public void setFile( final File file ) - { - m_file = file; - } - - /** - * Run task. - * - * @exception TaskException if an error occurs - */ - public void execute() - throws TaskException - { - validate(); - - final Properties properties = loadProperties(); - final int buildNumber = getBuildNumber( properties ); - - properties.put( DEFAULT_PROPERTY_NAME, - String.valueOf( buildNumber + 1 ) ); - - // Write the properties file back out - FileOutputStream output = null; - try - { - final String header = REZ.getString( "buildnumber.header.info" ); - - output = new FileOutputStream( m_file ); - properties.store( output, header ); - } - catch( final IOException ioe ) - { - final String message = - REZ.getString( "buildnumber.badwrite.error", m_file ); - throw new TaskException( message, ioe ); - } - finally - { - IOUtil.shutdownStream( output ); - } - - //Finally set the property - getContext().setProperty( DEFAULT_PROPERTY_NAME, - String.valueOf( buildNumber ) ); - } - - /** - * Utility method to retrieve build number from properties object. - * - * @param properties the properties to retrieve build number from - * @return the build number or if no number in properties object - * @throws TaskException if build.number property is not an integer - */ - private int getBuildNumber( final Properties properties ) - throws TaskException - { - final String buildNumber = - properties.getProperty( DEFAULT_PROPERTY_NAME, "0" ).trim(); - - // Try parsing the line into an integer. - try - { - return Integer.parseInt( buildNumber ); - } - catch( final NumberFormatException nfe ) - { - final String message = - REZ.getString( "buildnumber.noparse.error", m_file, buildNumber ); - throw new TaskException( message, nfe ); - } - } - - /** - * Utility method to load properties from file. - * - * @return the loaded properties - * @throws TaskException - */ - private Properties loadProperties() - throws TaskException - { - FileInputStream input = null; - try - { - final Properties properties = new Properties(); - input = new FileInputStream( m_file ); - properties.load( input ); - return properties; - } - catch( final IOException ioe ) - { - throw new TaskException( ioe.getMessage(), ioe ); - } - finally - { - IOUtil.shutdownStream( input ); - } - } - - /** - * Validate that the task parameters are valid. - * - * @throws TaskException if parameters are invalid - */ - private void validate() - throws TaskException - { - if( null == m_file ) - { - m_file = getContext().resolveFile( DEFAULT_FILENAME ); - } - - if( !m_file.exists() ) - { - try - { - m_file.createNewFile(); - } - catch( final IOException ioe ) - { - final String message = - REZ.getString( "buildnumber.nocreate.error", m_file ); - throw new TaskException( message, ioe ); - } - } - - if( !m_file.canRead() ) - { - final String message = - REZ.getString( "buildnumber.noread.error", m_file ); - throw new TaskException( message ); - } - - if( !m_file.canWrite() ) - { - final String message = - REZ.getString( "buildnumber.nowrite.error", m_file ); - throw new TaskException( message ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/Checksum.java b/proposal/myrmidon/src/java/org/apache/antlib/build/Checksum.java deleted file mode 100644 index f7ebfebe0..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/Checksum.java +++ /dev/null @@ -1,437 +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.antlib.build; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Hashtable; -import org.apache.avalon.excalibur.io.IOUtil; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.AbstractMatchingTask; -import org.apache.myrmidon.framework.FileSet; -import org.apache.tools.todo.types.DirectoryScanner; -import org.apache.tools.todo.types.ScannerUtil; - -/** - * This task can be used to create checksums for files. It can also be used to - * verify checksums. - * - * @ant.task name="checksum" - * @author Magesh Umasankar - * @version $Revision$ $Date$ - */ -public class Checksum - extends AbstractMatchingTask -{ - /** - * File for which checksum is to be calculated. - */ - private File m_file; - - /** - * MessageDigest algorithm to be used. - */ - private String m_algorithm = "MD5"; - - /** - * MessageDigest Algorithm provider - */ - private String m_provider; - - /** - * ArrayList to hold source file sets. - */ - private ArrayList m_filesets = new ArrayList(); - - /** - * Stores SourceFile, DestFile pairs and SourceFile, Property String pairs. - */ - private Hashtable m_includeFileMap = new Hashtable(); - - /** - * File Extension that is be to used to create or identify destination file - */ - private String m_fileext; - - /** - * Create new destination file? Defaults to false. - */ - private boolean m_forceOverwrite; - - /** - * Message Digest instance - */ - private MessageDigest m_messageDigest; - - /** - * Holds generated checksum and gets set as a Project Property. - */ - private String m_property; - - /** - * Contains the result of a checksum verification. ("true" or "false") - */ - private String m_verifyProperty; - - /** - * Sets the MessageDigest algorithm to be used to calculate the checksum. - */ - public void setAlgorithm( final String algorithm ) - { - m_algorithm = algorithm; - } - - /** - * Sets the file for which the checksum is to be calculated. - */ - public void setFile( final File file ) - { - m_file = file; - } - - /** - * Sets the File Extension that is be to used to create or identify - * destination file - */ - public void setFileext( final String fileext ) - { - m_fileext = fileext; - } - - /** - * Overwrite existing file irrespective of whether it is newer than the - * source file? Defaults to false. - */ - public void setForceOverwrite( boolean forceOverwrite ) - { - this.m_forceOverwrite = forceOverwrite; - } - - /** - * Sets the property to hold the generated checksum - */ - public void setProperty( String property ) - { - this.m_property = property; - } - - /** - * Sets the MessageDigest algorithm provider to be used to calculate the - * checksum. - * - * @param provider The new Provider value - */ - public void setProvider( final String provider ) - { - m_provider = provider; - } - - /** - * Sets verify property. This project property holds the result of a - * checksum verification - "true" or "false" - */ - public void setVerifyproperty( final String verifyProperty ) - { - m_verifyProperty = verifyProperty; - } - - /** - * Adds a set of files (nested fileset attribute). - */ - public void addFileset( final FileSet set ) - { - m_filesets.add( set ); - } - - /** - * Calculate the checksum(s). - */ - public void execute() - throws TaskException - { - final boolean value = validateAndExecute(); - if( m_verifyProperty != null ) - { - getContext().setProperty( m_verifyProperty, "" + value ); - } - } - - /** - * Add key-value pair to the hashtable upon which to later operate upon. - * - * @param file The feature to be added to the ToIncludeFileMap attribute - * @exception TaskException Description of Exception - */ - private void addToIncludeFileMap( final File file ) - throws TaskException - { - if( file != null ) - { - if( file.exists() ) - { - if( m_property == null ) - { - final File dest = new File( file.getParent(), file.getName() + m_fileext ); - if( m_forceOverwrite || - ( file.lastModified() > dest.lastModified() ) ) - { - m_includeFileMap.put( file, dest ); - } - else - { - final String message = file + " omitted as " + dest + - " is up to date."; - getContext().debug( message ); - } - } - else - { - m_includeFileMap.put( file, m_property ); - } - } - else - { - final String message = "Could not find file " + file.getAbsolutePath() + - " to generate checksum for."; - throw new TaskException( message ); - } - } - } - - /** - * Generate checksum(s) using the message digest created earlier. - */ - private boolean generateChecksums() - throws TaskException - { - boolean checksumMatches = true; - final Enumeration includes = m_includeFileMap.keys(); - while( includes.hasMoreElements() ) - { - final File src = (File)includes.nextElement(); - final String message = "Calculating " + m_algorithm + " checksum for " + src; - getContext().verbose( message ); - - checksumMatches = z( src, checksumMatches ); - } - - return checksumMatches; - } - - private boolean z( final File src, final boolean checksumMatches ) - throws TaskException - { - boolean match = checksumMatches; - FileInputStream fis = null; - FileOutputStream fos = null; - try - { - fis = new FileInputStream( src ); - final byte[] fileDigest = buildDigest( fis ); - IOUtil.shutdownStream( fis ); - - final StringBuffer sb = new StringBuffer(); - for( int i = 0; i < fileDigest.length; i++ ) - { - final String hexStr = Integer.toHexString( 0x00ff & fileDigest[ i ] ); - if( hexStr.length() < 2 ) - { - sb.append( '0' ); - } - sb.append( hexStr ); - } - - final String checksum = sb.toString(); - - //can either be a property name string or a file - final Object destination = m_includeFileMap.get( src ); - if( destination instanceof String ) - { - final String prop = (String)destination; - match = checksum.equals( m_property ); - getContext().setProperty( prop, checksum ); - } - else if( destination instanceof File ) - { - final File file = (File)destination; - fos = new FileOutputStream( file ); - fos.write( checksum.getBytes() ); - fos.close(); - fos = null; - } - } - catch( final Exception e ) - { - throw new TaskException( e.getMessage(), e ); - } - finally - { - IOUtil.shutdownStream( fis ); - IOUtil.shutdownStream( fos ); - } - return match; - } - - private byte[] buildDigest( final InputStream input ) - throws IOException - { - m_messageDigest.reset(); - - final DigestInputStream digester = - new DigestInputStream( input, m_messageDigest ); - - while( digester.read() != -1 ) - { - } - - digester.close(); - return m_messageDigest.digest(); - } - - /** - * Validate attributes and get down to business. - */ - private boolean validateAndExecute() - throws TaskException - { - if( null == m_file && 0 == m_filesets.size() ) - { - final String message = "Specify at least one source - a file or a fileset."; - throw new TaskException( message ); - } - - if( null != m_file && m_file.exists() && m_file.isDirectory() ) - { - final String message = "Checksum cannot be generated for directories"; - throw new TaskException( message ); - } - - if( null != m_property && null != m_fileext ) - { - final String message = "Property and FileExt cannot co-exist."; - throw new TaskException( message ); - } - - if( m_property != null ) - { - if( m_forceOverwrite ) - { - final String message = - "ForceOverwrite cannot be used when Property is specified"; - throw new TaskException( message ); - } - - if( m_file != null ) - { - if( m_filesets.size() > 0 ) - { - final String message = - "Multiple files cannot be used when Property is specified"; - throw new TaskException( message ); - } - } - else - { - if( m_filesets.size() > 1 ) - { - final String message = - "Multiple files cannot be used when Property is specified"; - throw new TaskException( message ); - } - } - } - - if( m_verifyProperty != null && m_forceOverwrite ) - { - final String message = "VerifyProperty and ForceOverwrite cannot co-exist."; - throw new TaskException( message ); - } - - if( m_fileext == null ) - { - m_fileext = "." + m_algorithm; - } - else if( m_fileext.trim().length() == 0 ) - { - final String message = "File extension when specified must not be an empty string"; - throw new TaskException( message ); - } - - setupMessageDigest(); - - if( m_messageDigest == null ) - { - final String message = "Unable to create Message Digest"; - throw new TaskException( message ); - } - - addIncludes(); - - return generateChecksums(); - } - - private void setupMessageDigest() - throws TaskException - { - m_messageDigest = null; - if( m_provider != null ) - { - try - { - m_messageDigest = MessageDigest.getInstance( m_algorithm, m_provider ); - } - catch( final NoSuchAlgorithmException nsae ) - { - throw new TaskException( nsae.toString(), nsae ); - } - catch( final NoSuchProviderException nspe ) - { - throw new TaskException( nspe.toString(), nspe ); - } - } - else - { - try - { - m_messageDigest = MessageDigest.getInstance( m_algorithm ); - } - catch( final NoSuchAlgorithmException nsae ) - { - throw new TaskException( nsae.toString(), nsae ); - } - } - } - - private void addIncludes() - throws TaskException - { - addToIncludeFileMap( m_file ); - - final int size = m_filesets.size(); - for( int i = 0; i < size; i++ ) - { - final FileSet fileSet = (FileSet)m_filesets.get( i ); - final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet ); - final String[] srcFiles = scanner.getIncludedFiles(); - for( int j = 0; j < srcFiles.length; j++ ) - { - final File src = new File( fileSet.getDir(), srcFiles[ j ] ); - addToIncludeFileMap( src ); - } - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/Patch.java b/proposal/myrmidon/src/java/org/apache/antlib/build/Patch.java deleted file mode 100644 index f0cff6585..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/Patch.java +++ /dev/null @@ -1,171 +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.antlib.build; - -import java.io.File; -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.nativelib.Execute; - -/** - * Task as a layer on top of patch. Patch applies a diff file to an original. - * - * @ant.task name="patchx" - * @author Stefan Bodewig - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class Patch - extends AbstractTask -{ - private static final Resources REZ = - ResourceManager.getPackageResources( Patch.class ); - - private File m_originalFile; - private File m_patchFile; - private boolean m_backups; - private boolean m_ignorewhitespace; - private boolean m_reverse; - private boolean m_quiet; - private Integer m_strip; - - /** - * Shall patch write backups. - * - * @param backups The new Backups value - */ - public void setBackups( final boolean backups ) - { - m_backups = backups; - } - - /** - * Ignore whitespace differences. - */ - public void setIgnorewhitespace( final boolean ignorewhitespace ) - { - m_ignorewhitespace = ignorewhitespace; - } - - /** - * The file to patch. - */ - public void setOriginalfile( final File originalFile ) - { - m_originalFile = originalFile; - } - - /** - * The file containing the diff output. - */ - public void setPatchfile( final File patchFile ) - { - m_patchFile = patchFile; - } - - /** - * Work silently unless an error occurs. - */ - public void setQuiet( final boolean quiet ) - { - m_quiet = quiet; - } - - /** - * Assume patch was created with old and new files swapped. - */ - public void setReverse( final boolean reverse ) - { - m_reverse = reverse; - } - - /** - * Strip the smallest prefix containing num leading slashes from - * filenames.
- * - * patch's -p option. - * - * @param strip The new Strip value - */ - public void setStrip( final Integer strip ) - { - m_strip = strip; - } - - public void execute() - throws TaskException - { - validate(); - - final Execute exe = buildCommand(); - exe.execute( getContext() ); - } - - private void validate() - throws TaskException - { - if( null == m_patchFile ) - { - final String message = REZ.getString( "patch.missing-file.error" ); - throw new TaskException( message ); - } - - if( !m_patchFile.exists() ) - { - final String message = REZ.getString( "patch.file-noexist.error", m_patchFile ); - throw new TaskException( message ); - } - - if( null != m_strip && m_strip.intValue() < 0 ) - { - final String message = REZ.getString( "patch.neg-strip.error" ); - throw new TaskException( message ); - } - } - - private Execute buildCommand( ) - { - final Execute cmd = new Execute(); - cmd.setExecutable( "patch" ); - if( m_backups ) - { - cmd.addArgument( "-b" ); - } - - if( null != m_strip ) - { - cmd.addArgument( "-p" + m_strip.intValue() ); - } - - if( m_quiet ) - { - cmd.addArgument( "-s" ); - } - - if( m_reverse ) - { - cmd.addArgument( "-R" ); - } - - cmd.addArgument( "-i" ); - cmd.addArgument( m_patchFile ); - - if( m_ignorewhitespace ) - { - cmd.addArgument( "-l" ); - } - - if( null != m_originalFile ) - { - cmd.addArgument( m_originalFile ); - } - return cmd; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties deleted file mode 100644 index aa33bcc21..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties +++ /dev/null @@ -1,13 +0,0 @@ -sleep.duration.notice=Sleeping for {0} milliseconds. -sleep.neg-time.error=Negative sleep periods are not supported. - -patch.missing-file.error=Patchfile argument is required. -patch.file-noexist.error=Patchfile "{0}" doesn\'t exist. -patch.neg-strip.error=Strip has to be >= 0 - -buildnumber.nocreate.error={0} doesn't exist and new file can't be created. -buildnumber.noread.error=Unable to read from {0}. -buildnumber.nowrite.error=Unable to write to {0}. -buildnumber.noparse.error={0} contains a non integer build number: {1} -buildnumber.badwrite.error=Error while writing {0}. -buildnumber.header.info=Build Number for ANT. Do not edit! \ No newline at end of file diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java b/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java deleted file mode 100644 index 84df99859..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java +++ /dev/null @@ -1,124 +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.antlib.build; - -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; - -/** - * A task to sleep for a period of time - * - * @ant.task name="sleep" - * @author steve_l@iseran.com steve loughran - * @version $Revision$ $Date$ - */ -public class SleepTask - extends AbstractTask -{ - private static final Resources REZ = - ResourceManager.getPackageResources( SleepTask.class ); - - private int m_seconds; - private int m_hours; - private int m_minutes; - private int m_milliseconds; - - /** - * Sets the Hours attribute of the Sleep object - */ - public void setHours( final int hours ) - { - m_hours = hours; - } - - /** - * Sets the Milliseconds attribute of the Sleep object - */ - public void setMilliseconds( final int milliseconds ) - { - m_milliseconds = milliseconds; - } - - /** - * Sets the Minutes attribute of the Sleep object - */ - public void setMinutes( final int minutes ) - { - m_minutes = minutes; - } - - /** - * Sets the Seconds attribute of the Sleep object - */ - public void setSeconds( final int seconds ) - { - m_seconds = seconds; - } - - /** - * sleep for a period of time - * - * @param millis time to sleep - */ - private void doSleep( final long millis ) - { - try - { - Thread.sleep( millis ); - } - catch( InterruptedException ie ) - { - } - } - - /** - * Executes this build task. throws org.apache.tools.ant.TaskException if - * there is an error during task execution. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - validate(); - final long sleepTime = getSleepTime(); - - final String message = REZ.getString( "sleep.duration.notice", new Long( sleepTime ) ); - getContext().debug( message ); - - doSleep( sleepTime ); - } - - /** - * verify parameters - * - * @throws TaskException if something is invalid - */ - private void validate() - throws TaskException - { - if( getSleepTime() < 0 ) - { - final String message = REZ.getString( "sleep.neg-time.error" ); - throw new TaskException( message ); - } - } - - /** - * return time to sleep - * - * @return sleep time. if below 0 then there is an error - */ - private long getSleepTime() - { - return ( ( ( (long)m_hours * 60 ) + m_minutes ) * 60 + m_seconds ) * 1000 + m_milliseconds; - } -} - diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java deleted file mode 100644 index 3c7b40f85..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java +++ /dev/null @@ -1,130 +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.antlib.build; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.FileNameMapper; -import org.apache.myrmidon.framework.FileSet; -import org.apache.myrmidon.framework.conditions.Condition; -import org.apache.tools.todo.types.DirectoryScanner; -import org.apache.tools.todo.types.ScannerUtil; -import org.apache.tools.todo.types.SourceFileScanner; -import org.apache.tools.todo.util.mappers.MergingMapper; - -/** - * A condition which evaluates to true when the specified target has a - * timestamp greater than all of the source files. - * - * @author William Ferguson - * williamf@mincom.com - * @author Hiroaki Nakamura - * hnakamur@mc.neweb.ne.jp - * @author Stefan Bodewig - * - * @ant.type type="condition" name="uptodate" - */ -public class UpToDateCondition - implements Condition -{ - private final ArrayList m_fileSets = new ArrayList(); - private FileNameMapper m_mapper; - private File m_targetFile; - - /** - * The file which must be more up to date than each of the source files if - * the property is to be set. - * - * @param file the file which we are checking against. - */ - public void setTargetFile( final File file ) - { - m_targetFile = file; - } - - /** - * Nested <srcfiles> element. - * - * @param fs The feature to be added to the Srcfiles attribute - */ - public void addSrcfiles( final FileSet fs ) - { - m_fileSets.add( fs ); - } - - /** - * Defines the FileNameMapper to use (nested mapper element). - */ - public void add( final FileNameMapper mapper ) - throws TaskException - { - if( m_mapper != null ) - { - throw new TaskException( "Cannot define more than one mapper" ); - } - m_mapper = mapper; - } - - /** - * Evaluates this condition. - * - * @param context - * The context to evaluate the condition in. - */ - public boolean evaluate( TaskContext context ) - throws TaskException - { - if( m_targetFile == null && m_mapper == null ) - { - throw new TaskException( "The targetfile attribute or a nested mapper element must be set" ); - } - - // if not there then it can't be up to date - if( m_targetFile != null && !m_targetFile.exists() ) - { - return false; - } - - final Iterator enum = m_fileSets.iterator(); - while( enum.hasNext() ) - { - final FileSet fs = (FileSet)enum.next(); - final DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs ); - if ( !scanDir( fs.getDir(), ds.getIncludedFiles(), context ) ) - { - return false; - } - } - return true; - } - - private boolean scanDir( final File srcDir, - final String files[], - final TaskContext context ) - throws TaskException - { - final SourceFileScanner scanner = new SourceFileScanner(); - FileNameMapper mapper = null; - File dir = srcDir; - if( m_mapper == null ) - { - final MergingMapper mm = new MergingMapper(); - mm.setTo( m_targetFile.getAbsolutePath() ); - mapper = mm; - dir = null; - } - else - { - mapper = m_mapper; - } - return scanner.restrict( files, srcDir, dir, mapper, context ).length == 0; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAntTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAntTask.java deleted file mode 100644 index f97c15cdb..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAntTask.java +++ /dev/null @@ -1,161 +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.antlib.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.interfaces.embeddor.Embeddor; -import org.apache.myrmidon.interfaces.model.Project; -import org.apache.myrmidon.interfaces.workspace.Workspace; - -/** - * Abstract base class for Tasks which execute targets. - * - * @author Peter Donald - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public abstract class AbstractAntTask - extends AbstractTask -{ - /** - * If true, inherit all properties from parent Project - * If false, inherit only userProperties and those defined - * inside the ant call itself - */ - private boolean m_inheritAll; - - /** - * The target to process in build file. If not specified - * will use default in specified build file. - */ - private String m_target; - - /** - * The parameters/properties which will be passed to the workspace - * for the target execution. - */ - private final ArrayList m_parameters = new ArrayList(); - - /** - * Specify whether should inherit properties in sub-build. - * - * @param inheritAll true to inherit else false - */ - public void setInheritAll( final boolean inheritAll ) - { - m_inheritAll = inheritAll; - } - - /** - * set the target to process. If none is defined it will - * execute the default target of the build file - */ - public void setTarget( final String target ) - { - m_target = target; - } - - /** - * Add a parameter to processing of build file. - * - * @param param the parameter - */ - public void addParam( final AntParam param ) - { - m_parameters.add( param ); - } - - /** - * Execute the specified build, with specified parameters. - * - * @throws TaskException if an error occurs. - */ - public void execute() - throws TaskException - { - try - { - Project project = getProject(); - - Embeddor embeddor = getEmbeddor(); - - final Workspace workspace = - embeddor.createWorkspace( buildParameters() ); - - // TODO - inherit listeners, and services (TypeManager specifically) - workspace.addProjectListener( embeddor.createListener("default")); - - if( null == m_target ) - { - m_target = project.getDefaultTargetName(); - } - - workspace.executeProject( project, m_target ); - } - catch( final Exception e ) - { - throw new TaskException( e.toString(), e ); - } - } - - /** - * A convenience method for obtaining the Embeddor from the - * TaskContext. - * @return The Embeddor contained in the TaskContext - * @throws TaskException if the Embeddor could not be obtained. - */ - protected Embeddor getEmbeddor() throws TaskException - { - final Embeddor embeddor = - (Embeddor)getContext().getService( Embeddor.class ); - return embeddor; - } - - /** - * Get/create/build the project containing the target to be executed. - * Subclasses will override this method to provide different means - * of obtaining a project to execute. - * @return The project containing the target to execute. - * @throws Exception If a problem occurred building the project. - */ - protected abstract Project getProject() throws Exception; - - /** - * Build the parameters to pass to sub-project. - * These include the current tasks properties - * (if inheritall=true) and any supplied by the user. - * - * @return the created parameters - */ - private Map buildParameters() - throws TaskException - { - final Map parameters = new HashMap(); - - if( m_inheritAll ) - { - parameters.putAll( getContext().getProperties() ); - } - - final int size = m_parameters.size(); - for( int i = 0; i < size; i++ ) - { - final AntParam param = (AntParam)m_parameters.get( i ); - param.validate(); - final String name = param.getName(); - final Object value = param.getValue(); - parameters.put( name, value ); - } - - return parameters; - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java deleted file mode 100644 index 92ed1c851..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java +++ /dev/null @@ -1,51 +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.antlib.core; - -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.conditions.Condition; -import org.apache.myrmidon.framework.file.Path; -import org.apache.myrmidon.framework.file.FileListUtil; - -/** - * An abstract condition which checks for the availability of a particular - * resource in a classpath. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public abstract class AbstractAvailableCondition - implements Condition -{ - private Path m_classpath = new Path(); - - /** - * Adds a classpath element. - */ - public void setClasspath( final Path classpath ) - { - m_classpath.add( classpath ); - } - - /** - * Adds a classpath element. - */ - public void addClasspath( final Path classpath ) - { - m_classpath.add( classpath ); - } - - /** - * Builds the ClassLoader to use to check resources. - */ - protected ClassLoader buildClassLoader( final TaskContext context ) throws TaskException - { - return FileListUtil.createClassLoader( m_classpath, context ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AntCallTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AntCallTask.java deleted file mode 100644 index 1bbe78ef4..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/AntCallTask.java +++ /dev/null @@ -1,69 +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.antlib.core; - -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.interfaces.model.Project; - -/** - * A task which executes a target in the current project, - * or a referenced project. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - * @ant.task name="ant-call" - */ -public class AntCallTask - extends AbstractAntTask -{ - private static final Resources REZ = - ResourceManager.getPackageResources( AntCallTask.class ); - - private String m_project; - - /** - * Specifies the project to execute. If not specified, the current - * project is used. - * @param project the name of the Project to execute. - */ - public void setProject( String project ) - { - m_project = project; - } - - /** - * Get/create/build the project which will be executed. - * Subclasses will override this method to provide different means - * of obtaining a project to execute. - * @return The project containing the target to execute. - * @throws Exception If a problem occurred building the project. - */ - protected Project getProject() throws Exception - { - Project currentProject = - (Project)getContext().getService( Project.class ); - - // By default, use the current project. - Project referencedProject = currentProject; - - if( m_project != null ) - { - referencedProject = currentProject.getProject( m_project ); - if( referencedProject == null ) - { - final String message = - REZ.getString( "antcall.invalid-project.error" ); - throw new TaskException( message ); - } - } - - return referencedProject; - } -} \ No newline at end of file diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AntParam.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AntParam.java deleted file mode 100644 index 54736fcde..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/AntParam.java +++ /dev/null @@ -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.antlib.core; - -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.api.TaskException; - -/** - * Simple holder for parameters. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @todo Refactor this and all the other parameter, sysproperty, - * property etc into a single class in framework - */ -public class AntParam -{ - private static final Resources REZ = - ResourceManager.getPackageResources( AntParam.class ); - - private String m_name; - private Object m_value; - - /** - * Set the name of the parameter. - * - * @param name the name of parameter - */ - public void setName( final String name ) - { - m_name = name; - } - - /** - * Set the value of the parameter. - * - * @param value the parameter value - */ - public void setValue( final Object value ) - { - m_value = value; - } - - /** - * Retrieve name of parameter. - * - * @return the name of parameter. - */ - public String getName() - { - return m_name; - } - - /** - * Retrieve the value of parameter. - * - * @return the value of parameter. - */ - public Object getValue() - { - return m_value; - } - - /** - * Make sure that neither the name or the value - * is null. - */ - public void validate() - throws TaskException - { - if( null == m_name ) - { - final String message = REZ.getString( "param.noname.error" ); - throw new TaskException( message ); - } - else if( null == m_value ) - { - final String message = - REZ.getString( "param.novalue.error", m_name ); - throw new TaskException( message ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AntTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AntTask.java deleted file mode 100644 index ad9b9a426..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/AntTask.java +++ /dev/null @@ -1,79 +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.antlib.core; - -import java.io.File; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.myrmidon.interfaces.model.Project; - -/** - * Executes a target in a named build file. - * - * @author Peter Donald - * @ant.task name="ant" - */ -public class AntTask - - extends AbstractAntTask -{ - /** - * Default build file. - */ - private static final String DEFAULT_BUILD_FILE = "build.ant"; - - /** - * The build file which to execute. If not set defaults to - * using "build.ant" in the basedir of current project. - */ - private File m_file; - - /** - * The "type" of the build file. By default this is null which - * means the type will be determined by the build file extension. - */ - private String m_type; - - /** - * set the build file to process. - * - * @param file the build file - */ - public void setFile( final File file ) - { - m_file = file; - } - - /** - * set the type of build file. - * - * @param type the type of build file - */ - public void setType( final String type ) - { - m_type = type; - } - - /** - * @return The project containing the target to execute. - * @throws Exception If a problem occurred building the project. - */ - protected Project getProject() throws Exception - { - if( null == m_file ) - { - m_file = getContext().resolveFile( DEFAULT_BUILD_FILE ); - } - - final Project project = - getEmbeddor().createProject( m_file.toString(), - m_type, - new Parameters() ); - return project; - } - -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java deleted file mode 100644 index e3e21de2e..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java +++ /dev/null @@ -1,64 +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.antlib.core; - -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.conditions.Condition; - -/** - * A condition that evaluates to true if the requested class is available - * at runtime. - * - * @author Stefano Mazzocchi - * stefano@apache.org - * @author Magesh Umasankar - * - * @ant.type type="condition" name="class-available" - */ -public class ClassAvailableCondition - extends AbstractAvailableCondition - implements Condition -{ - private String m_classname; - - /** - * Sets the name of the class to search for. - */ - public void setClassname( final String classname ) - { - m_classname = classname; - } - - /** - * Evaluates the condition. - */ - public boolean evaluate( final TaskContext context ) - throws TaskException - { - if( m_classname == null ) - { - throw new TaskException( "Classname not specified." ); - } - - // Build the classloader to use to check resources - final ClassLoader classLoader = buildClassLoader( context ); - - // Do the check - try - { - classLoader.loadClass( m_classname ); - return true; - } - catch( final Exception e ) - { - return false; - } - } - -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ConditionTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ConditionTask.java deleted file mode 100644 index 4d6aac283..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/ConditionTask.java +++ /dev/null @@ -1,80 +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.antlib.core; - -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.conditions.AndCondition; -import org.apache.myrmidon.framework.conditions.Condition; - -/** - * <condition> task as a generalization of <available> and - * <uptodate>
- * - * This task supports boolean logic as well as pluggable conditions to decide, - * whether a property should be set.
- * - * This task does not extend Task to take advantage of ConditionBase.
- * - * @author Stefan Bodewig - * @version $Revision$ - * - * @ant.task name="condition" - */ -public class ConditionTask - extends AbstractTask -{ - private AndCondition m_condition = new AndCondition(); - private String m_property; - private String m_value = "true"; - - /** - * Adds a condition. - */ - public void add( final Condition condition ) - { - m_condition.add( condition ); - } - - /** - * The name of the property to set. Required. - * - * @param p The new Property value - */ - public void setProperty( final String p ) - { - m_property = p; - } - - /** - * The value for the property to set. Defaults to "true". - * - * @param v The new Value value - */ - public void setValue( final String v ) - { - m_value = v; - } - - /** - * See whether our nested condition holds and set the property. - */ - public void execute() - throws TaskException - { - if( m_property == null ) - { - throw new TaskException( "No property was specified" ); - } - - if( m_condition.evaluate( getContext() ) ) - { - getContext().setProperty( m_property, m_value ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java b/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java deleted file mode 100644 index 819ae1c46..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.apache.antlib.core; - -/* - * 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. - */ - -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.framework.conditions.Condition; - -/** - * Simple String comparison condition. - * - * @author Stefan Bodewig - * @version $Revision$ - * - * @ant.type type="condition" name="equals" - */ -public class Equals implements Condition -{ - - private String arg1, arg2; - - public void setArg1( String a1 ) - { - arg1 = a1; - } - - public void setArg2( String a2 ) - { - arg2 = a2; - } - - /** - * Evaluates this condition. - * - * @param context - * The context to evaluate the condition in. - */ - public boolean evaluate( final TaskContext context ) - throws TaskException - { - if( arg1 == null || arg2 == null ) - { - throw new TaskException( "both arg1 and arg2 are required in equals" ); - } - return arg1.equals( arg2 ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ExtFileNameMapper.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ExtFileNameMapper.java deleted file mode 100644 index 51092c289..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/ExtFileNameMapper.java +++ /dev/null @@ -1,43 +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.antlib.core; - -import org.apache.avalon.excalibur.io.FileUtil; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.FileNameMapper; - -/** - * Maps file extensions. - * - * @ant.type type="mapper" name="map-extension" - */ -public class ExtFileNameMapper - implements FileNameMapper -{ - private String m_extension; - - public void setExtension( final String extension ) - { - m_extension = extension; - } - - public String[] mapFileName( final String filename, TaskContext context ) - throws TaskException - { - final String name = FileUtil.removeExtension( filename ); - if( m_extension != null ) - { - return new String[]{ name + '.' + m_extension }; - } - else - { - return new String[]{ name }; - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Fail.java b/proposal/myrmidon/src/java/org/apache/antlib/core/Fail.java deleted file mode 100644 index 407a7834e..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/Fail.java +++ /dev/null @@ -1,59 +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.antlib.core; - -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; - -/** - * This is a task used to throw a TaskException. - * Useful for forcing a build to fail on a certain condition. - * - * @author Peter Donald - * @ant.task name="fail" - */ -public class Fail - extends AbstractTask -{ - private String m_message; - - public void setMessage( final String message ) - { - checkNullMessage(); - m_message = message; - } - - public void addContent( final String message ) - { - checkNullMessage(); - m_message = message; - } - - public void execute() - throws TaskException - { - if( null != m_message ) - { - throw new TaskException( m_message ); - } - else - { - throw new TaskException(); - } - } - - private void checkNullMessage() - { - if( null != m_message ) - { - final String message = "Message can only be set once by " + - "either nested content or the message attribute"; - throw new IllegalStateException( message ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/FileTokenSet.java b/proposal/myrmidon/src/java/org/apache/antlib/core/FileTokenSet.java deleted file mode 100644 index c48a2921e..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/FileTokenSet.java +++ /dev/null @@ -1,81 +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.antlib.core; - -import java.io.File; -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.excalibur.io.IOUtil; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.filters.TokenSet; - -/** - * A set of tokens that are read from a file. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - * - * @ant.type type="token-set" name="tokens-file" - */ -public class FileTokenSet - implements TokenSet -{ - private static final Resources REZ - = ResourceManager.getPackageResources( FileTokenSet.class ); - - private Map m_tokens = new HashMap(); - - /** - * set the file containing the tokens for this tokenset. - */ - public void setFile( final File file ) - throws TaskException - { - // TODO - defer loading the tokens - if( !file.isFile() ) - { - final String message = REZ.getString( "filetokenset.not-a-file.error", file ); - throw new TaskException( message ); - } - - try - { - FileInputStream instr = new FileInputStream( file ); - - try - { - Properties props = new Properties(); - props.load( instr ); - m_tokens.putAll( props ); - } - finally - { - IOUtil.shutdownStream( instr ); - } - } - catch( final Exception e ) - { - final String message = REZ.getString( "filetokenset.read-tokens.error", file ); - throw new TaskException( message, e ); - } - } - - /** - * Evaluates the value for a token. - */ - public String getValue( String token, TaskContext context ) - throws TaskException - { - return (String)m_tokens.get( token ); - } -} diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/FlatFileNameMapper.java b/proposal/myrmidon/src/java/org/apache/antlib/core/FlatFileNameMapper.java deleted file mode 100644 index 6ce758615..000000000 --- a/proposal/myrmidon/src/java/org/apache/antlib/core/FlatFileNameMapper.java +++ /dev/null @@ -1,41 +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.antlib.core; - -import org.apache.avalon.excalibur.io.FileUtil; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.FileNameMapper; - -/** - * Implementation of FileNameMapper that always returns the source file name - * without any leading directory information.
- *
- * @author Stefan Bodewig
- *
- * @ant.type type="mapper" name="flatten"
- */
-public class FlatFileNameMapper
- extends PrefixFileNameMapper
- implements FileNameMapper
-{
-
- /**
- * Returns an one-element array containing the source file name without any
- * leading directory information.
- *
- * @param sourceFileName Description of Parameter
- * @return Description of the Returned Value
- */
- public String[] mapFileName( final String sourceFileName, TaskContext context )
- throws TaskException
- {
- final String baseName = FileUtil.removePath( sourceFileName, '/' );
- return super.mapFileName( baseName, context );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
deleted file mode 100644
index b3467c387..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
+++ /dev/null
@@ -1,123 +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.antlib.core;
-
-import java.util.ArrayList;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.AbstractContainerTask;
-import org.apache.myrmidon.framework.conditions.AndCondition;
-import org.apache.myrmidon.framework.conditions.Condition;
-import org.apache.myrmidon.framework.conditions.IsTrueCondition;
-import org.apache.myrmidon.framework.conditions.NotCondition;
-
-/**
- * A simple task to test a supplied condition. If the condition is true
- * then it will execute the inner tasks, else it won't.
- *
- * @author Peter Donald
- * @version $Revision$ $Date$
- * @ant.task name="if"
- */
-public class IfTask
- extends AbstractContainerTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( IfTask.class );
-
- private Condition m_condition;
- private ArrayList m_tasks = new ArrayList();
-
- /**
- * Set if clause on pattern.
- *
- * @param condition the condition
- * @exception TaskException if an error occurs
- */
- public void setTest( final String condition )
- throws TaskException
- {
- verifyConditionNull();
- m_condition = new IsTrueCondition( condition );
- }
-
- /**
- * Set unless clause of pattern.
- *
- * @param condition the unless clause
- * @exception TaskException if an error occurs
- */
- public void setNotTest( final String condition )
- throws TaskException
- {
- verifyConditionNull();
- m_condition = new NotCondition( new IsTrueCondition( condition ) );
- }
-
- /**
- * Add a nested "condition" element, which provides an AndCondition
- * container for any type of condition.
- * @param andCondition The configured Condition
- * @throws TaskException If a condition has already been set.
- */
- public void addCondition( final AndCondition andCondition )
- throws TaskException
- {
- verifyConditionNull();
- m_condition = andCondition;
- }
-
- public void add( final Configuration task )
- {
- m_tasks.add( task );
- }
-
- public void execute()
- throws TaskException
- {
- if( null == m_condition )
- {
- final String message = REZ.getString( "if.no-condition.error" );
- throw new TaskException( message );
- }
-
- // Evaluate the condition
- if( !m_condition.evaluate( getContext() ) )
- {
- return;
- }
-
- final Configuration[] tasks =
- (Configuration[])m_tasks.toArray( new Configuration[ m_tasks.size() ] );
-
- executeTasks( tasks );
- }
-
- public String toString()
- {
- return "If['" + m_condition + "]";
- }
-
- /**
- * Utility method to make sure condition unset.
- * Made so that it is not possible for both if and unless to be set.
- *
- * @exception TaskException if an error occurs
- */
- private void verifyConditionNull()
- throws TaskException
- {
- if( null != m_condition )
- {
- final String message = REZ.getString( "if.ifelse-duplicate.error" );
- throw new TaskException( message );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/LoadProperties.java b/proposal/myrmidon/src/java/org/apache/antlib/core/LoadProperties.java
deleted file mode 100644
index dcbd2b4ba..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/LoadProperties.java
+++ /dev/null
@@ -1,126 +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.antlib.core;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.excalibur.io.IOUtil;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * This task loads properties from a property file and places them in the context.
- *
- * @author Peter Donald
- * @ant.task name="load-properties"
- */
-public class LoadProperties
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( LoadProperties.class );
-
- private String m_prefix;
- private File m_file;
-
- /**
- * Specify the prefix to be placed before all properties (if any).
- */
- public void setPrefix( final String prefix )
- {
- m_prefix = prefix;
- }
-
- public void setFile( final File file )
- {
- m_file = file;
- }
-
- public void execute()
- throws TaskException
- {
- if( null == m_file )
- {
- final String message = REZ.getString( "loadprop.no-file.error" );
- throw new TaskException( message );
- }
-
- //Make sure prefix ends with a '.' if specified
- if( null == m_prefix )
- {
- m_prefix = "";
- }
- else if( !m_prefix.endsWith( "." ) )
- {
- m_prefix += ".";
- }
-
- loadFile( m_file );
- }
-
- /**
- * Utility method to load properties file.
- */
- private void loadFile( final File file )
- throws TaskException
- {
- if( getContext().isDebugEnabled() )
- {
- final String message =
- REZ.getString( "loadprop.file.notice", file.getAbsolutePath() );
- getContext().debug( message );
- }
-
- if( !file.exists() )
- {
- final String message =
- REZ.getString( "loadprop.missing-file.notice", file.getAbsolutePath() );
- getContext().debug( message );
- }
- else
- {
- FileInputStream input = null;
-
- try
- {
- input = new FileInputStream( file );
- final Properties properties = new PropertyLoader( this );
- properties.load( input );
- }
- catch( final IOException ioe )
- {
- throw new TaskException( ioe.getMessage(), ioe );
- }
-
- IOUtil.shutdownStream( input );
- }
- }
-
- /**
- * Utility method that will resolve and add specified proeprty.
- * Used by external PropertyLoader class as a call back method.
- */
- protected final void addUnresolvedValue( final String name, final String value )
- {
- try
- {
- final Object objectValue = getContext().resolveValue( value.toString() );
- final String name1 = m_prefix + name;
- getContext().setProperty( name1, objectValue );
- }
- catch( final TaskException te )
- {
- final String message = REZ.getString( "loadprop.bad-resolve.error", name, value );
- getContext().info( message, te );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Log.java b/proposal/myrmidon/src/java/org/apache/antlib/core/Log.java
deleted file mode 100644
index 08acd5cc4..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/Log.java
+++ /dev/null
@@ -1,82 +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.antlib.core;
-
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.LogLevel;
-
-/**
- * This is a task used to log messages in the build file.
- *
- * @author Peter Donald
- * @ant.task name="log"
- */
-public class Log
- extends AbstractTask
-{
- /**
- * The message to printout when logging
- */
- private String m_message;
-
- /**
- * The level at which to print out messages.
- */
- private LogLevel m_level = LogLevel.INFO;
-
- /**
- * Set the level at which the message will be logged.
- *
- * @param level the level at which message will be logged
- */
- public void setLevel( final LogLevel level )
- {
- m_level = level;
- }
-
- /**
- * Set the message to print out when logging message
- */
- public void setMessage( final String message )
- {
- checkNullMessage();
- m_message = message;
- }
-
- /**
- * Set the message to print out when logging message
- */
- public void addContent( final String message )
- {
- checkNullMessage();
- m_message = message;
- }
-
- /**
- * Log message at specified level.
- */
- public void execute()
- throws TaskException
- {
- LogLevel.log( getContext(), m_level, m_message );
- }
-
- /**
- * Utility message to verify that the message has not already been set.
- */
- private void checkNullMessage()
- {
- if( null != m_message )
- {
- final String message = "Message can only be set once by " +
- "either nested content or the message attribute";
- throw new IllegalStateException( message );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/PrefixFileNameMapper.java b/proposal/myrmidon/src/java/org/apache/antlib/core/PrefixFileNameMapper.java
deleted file mode 100644
index 6a0ba701c..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/PrefixFileNameMapper.java
+++ /dev/null
@@ -1,56 +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.antlib.core;
-
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.FileNameMapper;
-
-/**
- * A filename mapper that applies a prefix to each file.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="mapper" name="prefix"
- */
-public class PrefixFileNameMapper
- implements FileNameMapper
-{
- private String m_prefix;
-
- /**
- * Sets the prefix.
- */
- public void setPrefix( final String prefix )
- {
- m_prefix = prefix;
- if( ! m_prefix.endsWith( "/" ) )
- {
- m_prefix = m_prefix + '/';
- }
- }
-
- /**
- * Returns an array containing the target filename(s) for the given source
- * file.
- */
- public String[] mapFileName( final String sourceFileName,
- final TaskContext context )
- throws TaskException
- {
- if( m_prefix == null )
- {
- return new String[]{ sourceFileName };
- }
- else
- {
- return new String[] { m_prefix + sourceFileName };
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Property.java b/proposal/myrmidon/src/java/org/apache/antlib/core/Property.java
deleted file mode 100644
index 0bfb56e63..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/Property.java
+++ /dev/null
@@ -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.antlib.core;
-
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.DataType;
-
-/**
- * This is the property "task" to declare a binding of a datatype to a name.
- *
- * TODO: Determine final format of property task.
- *
- * @author Peter Donald
- * @version $Revision$ $Date$
- * @ant.task name="property"
- */
-public class Property
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( Property.class );
-
- private String m_name;
- private Object m_value;
-
- public void setName( final String name )
- {
- m_name = name;
- }
-
- /**
- * Sets the property value from a nested element.
- */
- public void add( final DataType value )
- throws TaskException
- {
- setValue( value );
- }
-
- /**
- * Sets the property value from text content.
- */
- public void addContent( final String value )
- throws TaskException
- {
- setValue( value );
- }
-
- /**
- * Sets the property value from an attribute.
- */
- public void setValue( final Object value )
- throws TaskException
- {
- if( null != m_value )
- {
- final String message = REZ.getString( "property.multi-set.error" );
- throw new TaskException( message );
- }
-
- m_value = value;
- }
-
- public void execute()
- throws TaskException
- {
- if( null == m_name )
- {
- final String message = REZ.getString( "property.no-name.error" );
- throw new TaskException( message );
- }
-
- if( null == m_value )
- {
- final String message = REZ.getString( "property.no-value.error" );
- throw new TaskException( message );
- }
-
- getContext().setProperty( m_name, m_value );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyDump.java b/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyDump.java
deleted file mode 100644
index dbca9073f..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyDump.java
+++ /dev/null
@@ -1,68 +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.antlib.core;
-
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * This is a simple task used to dump out all the proeprtys in the
- * runtime. Useful for debugging behaviour in ant build directives.
- *
- * @author Peter Donald
- * @author Jim Cook
- * @version $Revision$ $Date$
- * @ant.task name="property-dump"
- * @todo Consider moving to new antlib
- */
-public class PropertyDump
- extends AbstractTask
-{
- /**
- * The prefix which the keys must start with if they are
- * to be dumped.
- */
- private String m_prefix;
-
- /**
- * Set the prefix which the keys must start with if they are
- * to be dumped. If not specified then all keys are dumped.
- *
- * @param prefix the prefix
- */
- public void setPrefix( final String prefix )
- {
- m_prefix = prefix;
- }
-
- /**
- * Printout all the properties in ant runtime.
- */
- public void execute()
- throws TaskException
- {
- final Map properties = getContext().getProperties();
- final Iterator iterator = properties.keySet().iterator();
- while( iterator.hasNext() )
- {
- final String key = (String)iterator.next();
- final Object value = properties.get( key );
-
- //Check to see if property starts with specified prefix
- //and if it doesn't then skip property
- if( null != m_prefix && !key.startsWith( m_prefix ) )
- {
- continue;
- }
-
- getContext().info( key + "=" + value );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyLoader.java b/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyLoader.java
deleted file mode 100644
index ebb742c13..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyLoader.java
+++ /dev/null
@@ -1,34 +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.antlib.core;
-
-import java.util.Properties;
-
-/**
- * This class is an UGLY HACK utility class to enable us to reuse
- * the property parsing and loading code from Properties object.
- */
-class PropertyLoader
- extends Properties
-{
- private LoadProperties m_loadProperties;
-
- public PropertyLoader( LoadProperties loadProperties )
- {
- m_loadProperties = loadProperties;
- }
-
- /**
- * Overidden put to add unresolved values.
- */
- public synchronized Object put( Object key, Object value )
- {
- m_loadProperties.addUnresolvedValue( key.toString(), value.toString() );
- return null;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyTokenSet.java b/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyTokenSet.java
deleted file mode 100644
index 03d902941..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/PropertyTokenSet.java
+++ /dev/null
@@ -1,38 +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.antlib.core;
-
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.filters.TokenSet;
-
-/**
- * A token set that uses the project's properties as tokens.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="token-set" name="properties"
- */
-public class PropertyTokenSet
- implements TokenSet
-{
- /**
- * Evaluates the value for a token.
- */
- public String getValue( String token, TaskContext context )
- throws TaskException
- {
- final Object propValue = context.getProperty( token );
- if( propValue == null )
- {
- return null;
- }
- return propValue.toString();
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
deleted file mode 100644
index c5931afca..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
+++ /dev/null
@@ -1,61 +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.antlib.core;
-
-import java.io.InputStream;
-import org.apache.avalon.excalibur.io.IOUtil;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.conditions.Condition;
-
-/**
- * A condition that evaluates to true if the requested resource is available
- * at runtime.
- *
- * @author Stefano Mazzocchi
- * stefano@apache.org
- * @author Magesh Umasankar
- *
- * @ant.type type="condition" name="resource-available"
- */
-public class ResourceAvailableCondition
- extends AbstractAvailableCondition
- implements Condition
-{
- private String m_resource;
-
- /**
- * Sets the name of the resource to look for.
- */
- public void setResource( final String resource )
- {
- m_resource = resource;
- }
-
- /**
- * Evaluates the condition.
- */
- public boolean evaluate( final TaskContext context )
- throws TaskException
- {
- if( m_resource == null )
- {
- throw new TaskException( "Resource was not specified." );
- }
-
- // Check whether the resource is available
- final ClassLoader classLoader = buildClassLoader( context );
- final InputStream instr = classLoader.getResourceAsStream( m_resource );
- if( instr != null )
- {
- IOUtil.shutdownStream( instr );
- return true;
- }
- return false;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
deleted file mode 100644
index 2f0c47a3c..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-property.no-set.error=Unable to set datatype.
-property.multi-set.error=Value can not be set multiple times.
-property.no-name.error=Name must be specified.
-property.no-value.error=Value must be specified.
-
-loadprop.no-file.error=No file specified to load properties from.
-loadprop.file.notice=Loading proeprties from {0}.
-loadprop.missing-file.notice=Unable to find property file: {0}.
-loadprop.bad-resolve.error=Unable to resolve and set property named "{0}" to value "{1}".
-
-convert.bad-boolean.error=Error converting object ({0}) to Boolean.
-convert.bad-byte.error=Error converting object ({0}) to Byte.
-convert.bad-class.error=Error converting object ({0}) to Class.
-convert.bad-double.error=Error converting object ({0}) to Double.
-convert.bad-file.error=Error converting object ({0}) to File.
-
-getByName.error=Failed to retrieve enum by calling getByName on "{0}". (Reason: {1}).
-enum.missing.getByName.error=Enum class "{0}" is missing a public static method named "getByName" that accepts a single string parameter.
-enum.missing.getNames.error=Enum class "{0}" is missing a public static method named "getNames" that returns a String array of all enum names.
-invalid.enum.error=Invalid value "{0}" for enum, expected one of {1}.
-
-if.ifelse-duplicate.error=Can only set one condition for If task type. Conditions may be 'test' or 'not-test' attributes, or nested 'condition' elements.
-if.no-condition.error=No condition was specified for If task.
-
-trycatch.multiple-trys.error=Multiple
- * - * All parameters are optional: <csc/> should suffice to produce a debug - * build of all *.cs files. References to external files do require explicit - * enumeration, so are one of the first attributes to consider adding.
- * - * The task is a directory based task, so attributes like includes="*.cs" - * and excludes="broken.cs" can be used to control the files pulled in. - * By default, all *.cs files from the project folder down are included in the - * command. When this happens the output file -if not specified- is taken as the - * first file in the list, which may be somewhat hard to control. Specifying the - * output file with 'outfile' seems prudent.
- * - *
- * - * TODO - *
- * - * History - *
- * 0.3 - * | - * - *- * Beta 1 edition - * | - * - *- * To avoid having to remember which assemblies to include, the task - * automatically refers to the main dotnet libraries in Beta1. - * |
- * 0.2 - * | - * - *- * Slightly different - * | - * - *- * Split command execution to a separate class; - * |
- * 0.1 - * | - * - *- * "I can't believe it's so rudimentary" - * | - * - *- * First pass; minimal builds only support; - * |
- * - *
- * - * All parameters are optional: <il/> should suffice to produce a debug - * build of all *.il files. The option set is roughly compatible with the CSharp - * class; even though the command line options are only vaguely equivalent. [The - * low level commands take things like /OUT=file, csc wants /out:file ... - * /verbose is used some places; /quiet here in ildasm... etc.] It would be nice - * if someone made all the command line tools consistent (and not as brittle as - * the java cmdline tools)
- *
- * The task is a directory based task, so attributes like includes="*.il"
- * and excludes="broken.il" can be used to control the files pulled in.
- * Each file is built on its own, producing an appropriately named output file
- * unless manually specified with outfile
- *
- * @author Steve Loughran steve_l@iseran.com
- * @version 0.2
- */
-public class Ilasm
- extends MatchingTask
-{
- /**
- * name of the executable. the .exe suffix is deliberately not included in
- * anticipation of the unix version
- */
- private static final String EXE_NAME = "ilasm";
-
- /**
- * what is the file extension we search on?
- */
- private static final String FILE_EXT = "il";
-
- /**
- * and now derive the search pattern from the extension
- */
- private static final String FILE_PATTERN = "**/*." + FILE_EXT;
-
- /**
- * debug flag. Controls generation of debug information.
- */
- private boolean m_debug;
-
- /**
- * any extra command options?
- */
- private String m_extraOptions;
-
- /**
- * listing flag
- */
- private boolean m_listing;
-
- /**
- * output file. If not supplied this is derived from the source file
- */
- private File m_outputFile;
-
- /**
- * resource file (.res format) to include in the app.
- */
- private File m_resourceFile;
-
- /**
- * type of target. Should be one of exe|library|module|winexe|(null) default
- * is exe; the actual value (if not null) is fed to the command line.
- * See /target
- */
- private String m_targetType;
-
- /**
- * verbose flag
- */
- private boolean m_verbose;
-
- /**
- * file containing private key
- */
- private File m_keyfile;
-
- /**
- * source directory upon which the search pattern is applied
- */
- private File m_srcDir;
-
- /**
- * constructor inits everything and set up the search pattern
- */
- public Ilasm()
- throws TaskException
- {
- setIncludes( FILE_PATTERN );
- m_debug = true;
- }
-
- /**
- * set the debug flag on or off
- *
- * @param debug on/off flag
- */
- public void setDebug( final boolean debug )
- {
- m_debug = debug;
- }
-
- /**
- * Sets the ExtraOptions attribute
- *
- * @param extraOptions The new ExtraOptions value
- */
- public void setExtraOptions( final String extraOptions )
- {
- m_extraOptions = extraOptions;
- }
-
- public void setKeyfile( final File keyfile )
- {
- m_keyfile = keyfile;
- }
-
- /**
- * enable/disable listing
- *
- * @param listing flag set to true for listing on
- */
- public void setListing( final boolean listing )
- {
- m_listing = listing;
- }
-
- /**
- * Set the definitions
- */
- public void setOutputFile( final File outputFile )
- {
- m_outputFile = outputFile;
- }
-
- /**
- * Set the resource file
- *
- * @param resourceFile path to the file. Can be relative, absolute, whatever.
- */
- public void setResourceFile( final File resourceFile )
- {
- m_resourceFile = resourceFile;
- }
-
- /**
- * Set the source dir to find the files to be compiled
- */
- public void setSrcDir( final File srcDir )
- {
- m_srcDir = srcDir;
- }
-
- /**
- * define the target
- *
- * @param targetType one of exe|library|
- * @exception TaskException if target is not one of
- * exe|library|module|winexe
- */
-
- public void setTargetType( final String targetType )
- throws TaskException
- {
- final String type = targetType.toLowerCase();
- if( type.equals( "exe" ) || type.equals( "library" ) )
- {
- m_targetType = type;
- }
- else
- {
- final String message = "targetType " + targetType + " is not a valid type";
- throw new TaskException( message );
- }
- }
-
- /**
- * enable/disable verbose ILASM output
- *
- * @param verbose flag set to true for verbose on
- */
- public void setVerbose( final boolean verbose )
- {
- m_verbose = verbose;
- }
-
- /**
- * This is the execution entry point. Build a list of files and call ilasm
- * on each of them.
- *
- * @throws TaskException if the assembly failed
- */
- public void execute()
- throws TaskException
- {
- if( null == m_srcDir )
- {
- m_srcDir = getBaseDirectory();
- }
-
- //get dependencies list.
- final DirectoryScanner scanner = super.getDirectoryScanner( m_srcDir );
- final String[] dependencies = scanner.getIncludedFiles();
- final String baseDir = scanner.getBasedir().toString();
-
- final String message = "assembling " + dependencies.length + " file" +
- ( ( dependencies.length == 1 ) ? "" : "s" );
- getContext().info( message );
-
- //add to the command
- for( int i = 0; i < dependencies.length; i++ )
- {
- final String targetFile = baseDir + File.separator + dependencies[ i ];
- executeOneFile( targetFile );
- }
- }
-
- /**
- * do the work for one file by building the command line then calling it
- *
- * @param targetFile name of the the file to assemble
- * @throws TaskException if the assembly failed and FailOnError is true
- */
- public void executeOneFile( final String targetFile )
- throws TaskException
- {
- final Execute exe = new Execute();
- exe.setExecutable( EXE_NAME );
- addArgument( exe, getDebugParameter() );
- addArgument( exe, getTargetTypeParameter() );
- addArgument( exe, getListingParameter() );
- addArgument( exe, getOutputFileParameter() );
- addArgument( exe, getResourceFileParameter() );
- addArgument( exe, getVerboseParameter() );
- addArgument( exe, getKeyfileParameter() );
- addArgument( exe, getExtraOptionsParameter() );
- addArgument( exe, targetFile );
- exe.execute( getContext() );
- }
-
- private void addArgument( final ArgumentList cmd, final String argument )
- {
- if( null != argument && 0 != argument.length() )
- {
- cmd.addArgument( argument );
- }
- }
-
- /**
- * get the argument or null for no argument needed
- *
- * @return The DebugParameter value
- */
- private String getDebugParameter()
- {
- return m_debug ? "/debug" : null;
- }
-
- /**
- * get any extra options or null for no argument needed
- *
- * @return The ExtraOptions Parameter to CSC
- */
- private String getExtraOptionsParameter()
- {
- if( m_extraOptions != null && m_extraOptions.length() != 0 )
- {
- return m_extraOptions;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * get the argument or null for no argument needed
- */
- private String getKeyfileParameter()
- {
- if( m_keyfile != null )
- {
- return "/keyfile:" + m_keyfile.toString();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * turn the listing flag into a parameter for ILASM
- *
- * @return the appropriate string from the state of the listing flag
- */
- private String getListingParameter()
- {
- return m_listing ? "/listing" : "/nolisting";
- }
-
- /**
- * get the output file
- *
- * @return the argument string or null for no argument
- */
- private String getOutputFileParameter()
- {
- if( null == m_outputFile || 0 == m_outputFile.length() )
- {
- return null;
- }
- return "/output=" + m_outputFile.toString();
- }
-
- private String getResourceFileParameter()
- {
- if( null != m_resourceFile )
- {
- return "/resource=" + m_resourceFile.toString();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * g get the target type or null for no argument needed
- *
- * @return The TargetTypeParameter value
- */
-
- private String getTargetTypeParameter()
- {
- if( !notEmpty( m_targetType ) )
- {
- return null;
- }
- if( m_targetType.equals( "exe" ) )
- {
- return "/exe";
- }
- else if( m_targetType.equals( "library" ) )
- {
- return "/dll";
- }
- else
- {
- return null;
- }
- }
-
- /**
- * turn the verbose flag into a parameter for ILASM
- *
- * @return null or the appropriate command line string
- */
- private String getVerboseParameter()
- {
- return m_verbose ? null : "/quiet";
- }
-
- /**
- * test for a string containing something useful
- *
- * @returns true if the argument is not null or empty
- */
- private boolean notEmpty( final String string )
- {
- return string != null && string.length() != 0;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/CopyTask.java b/proposal/myrmidon/src/java/org/apache/antlib/file/CopyTask.java
deleted file mode 100644
index ae8ae12bd..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/CopyTask.java
+++ /dev/null
@@ -1,450 +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.antlib.file;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.excalibur.io.FileUtil;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.FileNameMapper;
-import org.apache.myrmidon.framework.FileSet;
-import org.apache.tools.todo.types.DirectoryScanner;
-import org.apache.tools.todo.types.ScannerUtil;
-import org.apache.tools.todo.types.SourceFileScanner;
-import org.apache.tools.todo.util.mappers.IdentityMapper;
-
-/**
- * This is a task used to copy files.
- *
- * @ant.task name="copy"
- * @author Peter Donald
- * @author Glenn McAllister
- * @author Stefan Bodewig
- * @author Michael McCallum
- * @author Magesh Umasankar
- * @version $Revision$ $Date$
- */
-public class CopyTask
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( CopyTask.class );
-
- private File m_file;
- private ArrayList m_filesets = new ArrayList();
- private File m_destFile;
- private File m_destDir;
- private boolean m_preserveLastModified;
- private boolean m_overwrite;
- private boolean m_includeEmpty = true;
- private FileNameMapper m_mapper;
-
- private HashMap m_fileMap = new HashMap();
- private HashMap m_dirMap = new HashMap();
-
- /**
- * Sets a single source file to copy.
- */
- public void setFile( final File file )
- {
- m_file = file;
- }
-
- public void addFileset( final FileSet set )
- {
- m_filesets.add( set );
- }
-
- public void setDestFile( final File destFile )
- {
- m_destFile = destFile;
- }
-
- public void setDestDir( final File destDir )
- {
- m_destDir = destDir;
- }
-
- public void setPreserveLastModified( boolean preserveLastModified )
- {
- m_preserveLastModified = preserveLastModified;
- }
-
- /**
- * Overwrite any existing destination file(s).
- */
- public void setOverwrite( boolean overwrite )
- {
- m_overwrite = overwrite;
- }
-
- /**
- * Defines the FileNameMapper to use (nested mapper element).
- */
- public void addMapper( final FileNameMapper mapper )
- throws TaskException
- {
- if( null != m_mapper )
- {
- final String message = "Cannot define more than one mapper";
- throw new TaskException( message );
- }
- m_mapper = mapper;
- }
-
- protected final boolean isPreserveLastModified()
- {
- return m_preserveLastModified;
- }
-
- public void execute()
- throws TaskException
- {
- validate();
-
- // deal with the single file
- if( m_file != null )
- {
- if( null == m_destFile )
- {
- m_destFile = new File( m_destDir, m_file.getName() );
- }
-
- if( m_overwrite ||
- ( m_file.lastModified() > m_destFile.lastModified() ) )
- {
- m_fileMap.put( m_file.getAbsolutePath(), m_destFile.getAbsolutePath() );
- }
- else
- {
- final String message =
- REZ.getString( "copy.omit-uptodate.notice", m_file, m_destFile );
- getContext().debug( message );
- }
- }
-
- // deal with the filesets
- final int size = m_filesets.size();
- for( int i = 0; i < size; i++ )
- {
- final FileSet fileSet = (FileSet)m_filesets.get( i );
- final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
- final File fromDir = fileSet.getDir();
-
- final String[] srcFiles = scanner.getIncludedFiles();
- final String[] srcDirs = scanner.getIncludedDirectories();
-
- scan( fromDir, m_destDir, srcFiles, srcDirs );
- }
-
- // do all the copy operations now...
- doFileOperations( m_fileMap, m_dirMap );
- }
-
- protected void validate()
- throws TaskException
- {
- final int fileSetSize = m_filesets.size();
-
- if( null == m_file && 0 == fileSetSize )
- {
- final String message = REZ.getString( "copy.missing-src.error" );
- throw new TaskException( message );
- }
-
- if( null != m_destFile && null != m_destDir )
- {
- final String message = REZ.getString( "copy.one-dest-only.error" );
- throw new TaskException( message );
- }
-
- if( null != m_file && m_file.exists() && m_file.isDirectory() )
- {
- final String message = REZ.getString( "copy.fileset-for-dirs.error" );
- throw new TaskException( message );
- }
-
- if( null != m_destFile && fileSetSize > 0 )
- {
- if( fileSetSize > 1 )
- {
- final String message = REZ.getString( "copy.need-destdir.error" );
- throw new TaskException( message );
- }
- else
- {
- final FileSet fileSet = (FileSet)m_filesets.get( 0 );
- final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
- final String[] srcFiles = scanner.getIncludedFiles();
-
- if( srcFiles.length > 0 )
- {
- if( m_file == null )
- {
- m_file = new File( srcFiles[ 0 ] );
- m_filesets.remove( 0 );
- }
- else
- {
- final String message = REZ.getString( "copy.bad-mapping.error" );
- throw new TaskException( message );
- }
- }
- else
- {
- final String message = REZ.getString( "copy.bad-operation.error" );
- throw new TaskException( message );
- }
- }
- }
-
- if( null != m_file && !m_file.exists() )
- {
- final String message =
- REZ.getString( "copy.missing-file.error", m_file.getAbsolutePath() );
- throw new TaskException( message );
- }
-
- if( null != m_destFile )
- {
- m_destDir = m_destFile.getParentFile();
- }
- }
-
- /**
- * Compares source files to destination files to see if they should be
- * copied.
- */
- private void scan( final File sourceDir,
- final File destDir,
- final String[] files,
- final String[] dirs )
- throws TaskException
- {
- final FileNameMapper mapper = getFilenameMapper();
-
- buildMap( sourceDir, destDir, files, mapper, m_fileMap );
-
- if( m_includeEmpty )
- {
- buildMap( sourceDir, destDir, dirs, mapper, m_dirMap );
- }
- }
-
- private void buildMap( final File sourceDir,
- final File destDir,
- final String[] files,
- final FileNameMapper mapper,
- final Map map )
- throws TaskException
- {
- final String[] toCopy = buildFilenameList( files, mapper, sourceDir, destDir );
- for( int i = 0; i < toCopy.length; i++ )
- {
- final String destFilename = mapper.mapFileName( toCopy[ i ], getContext() )[ 0 ];
- final File source = new File( sourceDir, toCopy[ i ] );
- final File destination = new File( destDir, destFilename );
- map.put( source.getAbsolutePath(), destination.getAbsolutePath() );
- }
- }
-
- /**
- * Utility method to build up a list of files needed between both
- * but only getting the files that need updating (unless overwrite is true).
- */
- private String[] buildFilenameList( final String[] names,
- final FileNameMapper mapper,
- final File fromDir,
- final File toDir )
- throws TaskException
- {
- if( m_overwrite )
- {
- final ArrayList list = new ArrayList( names.length );
- for( int i = 0; i < names.length; i++ )
- {
- final String name = names[ i ];
- if( null != mapper.mapFileName( name, getContext() ) )
- {
- list.add( name );
- }
- }
-
- return (String[])list.toArray( new String[ list.size() ] );
- }
- else
- {
- final SourceFileScanner scanner = new SourceFileScanner();
- return scanner.restrict( names, fromDir, toDir, mapper, getContext() );
- }
- }
-
- /**
- * Perform the oepration on all the files (and possibly empty directorys).
- */
- private void doFileOperations( final Map fileCopyMap, final Map dirCopyMap )
- throws TaskException
- {
- final int fileCount = fileCopyMap.size();
- if( fileCount > 0 )
- {
- doOperationOnFiles( fileCopyMap );
- }
-
- if( m_includeEmpty )
- {
- doOperationOnDirs( dirCopyMap );
- }
- }
-
- /**
- * perform operation on files.
- */
- private void doOperationOnFiles( final Map fileMap )
- throws TaskException
- {
- final int fileCount = fileMap.size();
- displayFilecountNotice( fileCount );
-
- final Iterator names = fileMap.keySet().iterator();
- while( names.hasNext() )
- {
- final String source = (String)names.next();
- final String destination = (String)fileMap.get( source );
-
- if( source.equals( destination ) )
- {
- final String message =
- REZ.getString( "copy.selfcopy-ignored.notice", source );
- getContext().verbose( message );
- continue;
- }
-
- try
- {
- final String message =
- REZ.getString( "copy.filecopy.notice", source, destination );
- getContext().verbose( message );
-
- doOperation( source, destination );
- }
- catch( final IOException ioe )
- {
- final String message =
- REZ.getString( "copy.filecopy.error", source, destination, ioe );
- throw new TaskException( message, ioe );
- }
- }
- }
-
- /**
- * perform operation on directories.
- */
- private void doOperationOnDirs( final Map dirMap )
- {
- final Iterator dirs = dirMap.values().iterator();
- int count = 0;
- while( dirs.hasNext() )
- {
- final String pathname = (String)dirs.next();
- final File dir = new File( pathname );
- if( !dir.exists() )
- {
- if( !dir.mkdirs() )
- {
- final String message =
- REZ.getString( "copy.dircopy.error", dir.getAbsolutePath() );
- getContext().error( message );
- }
- else
- {
- count++;
- }
- }
- }
-
- if( count > 0 )
- {
- displayDirCopyNotice( count );
- }
- }
-
- /**
- * Utility method to determine and retrieve FilenameMapper.
- */
- private FileNameMapper getFilenameMapper()
- throws TaskException
- {
- if( null != m_mapper )
- {
- return m_mapper;
- }
- else
- {
- return new IdentityMapper();
- }
- }
-
- /**
- * Utility method to perform operation to transform a single source file
- * to a destination.
- */
- protected void doOperation( final String sourceFilename,
- final String destinationFilename )
- throws IOException
- {
- final File source = new File( sourceFilename );
- final File destination = new File( destinationFilename );
-
- if( m_overwrite )
- {
- FileUtil.forceDelete( destination );
- }
-
- FileUtil.copyFile( source, destination );
-
- if( m_preserveLastModified )
- {
- destination.setLastModified( source.lastModified() );
- }
- }
-
- /**
- * Utility method to display notice about how many dirs copied.
- */
- private void displayDirCopyNotice( final int count )
- {
- final String message =
- REZ.getString( "copy.dir-count.notice",
- new Integer( count ),
- m_destDir.getAbsolutePath() );
- getContext().info( message );
- }
-
- /**
- * Utility method to display notice about how many files copied.
- */
- private void displayFilecountNotice( final int count )
- {
- if( getContext().isInfoEnabled() )
- {
- final String message =
- REZ.getString( "copy.file-count.notice",
- new Integer( count ),
- m_destDir.getAbsolutePath() );
- getContext().info( message );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/Delete.java b/proposal/myrmidon/src/java/org/apache/antlib/file/Delete.java
deleted file mode 100644
index 178c64f52..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/Delete.java
+++ /dev/null
@@ -1,240 +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.antlib.file;
-
-import java.io.File;
-import java.util.ArrayList;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.FileSet;
-import org.apache.tools.todo.types.DirectoryScanner;
-import org.apache.tools.todo.types.ScannerUtil;
-
-/**
- * Deletes a file or directory, or set of files defined by a fileset.
- *
- * @ant.task name="delete"
- * @author Peter Donald
- * @author Stefano Mazzocchi
- * @author Tom Dimock
- * @author Glenn McAllister
- * @author Jon S. Stevens
- * @version $Revision$ $Date$
- */
-public class Delete
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( Delete.class );
-
- private final ArrayList filesets = new ArrayList();
- private File m_dir;
- private File m_file;
- private boolean m_includeEmpty;// by default, remove matching empty dirs
-
- /**
- * Set the directory from which files are to be deleted
- *
- * @param dir the directory path.
- */
- public void setDir( final File dir )
- {
- m_dir = dir;
- }
-
- /**
- * Set the name of a single file to be removed.
- *
- * @param file the file to be deleted
- */
- public void setFile( final File file )
- {
- m_file = file;
- }
-
- /**
- * Adds a set of files (nested fileset attribute).
- */
- public void addFileset( FileSet set )
- {
- filesets.add( set );
- }
-
- /**
- * Delete the file(s).
- */
- public void execute()
- throws TaskException
- {
- validate();
-
- // delete the single file
- if( null != m_file && m_file.exists() )
- {
- deleteFile( m_file );
- }
-
- // delete the directory
- if( m_dir != null && m_dir.exists() && m_dir.isDirectory() )
- {
- final String message =
- REZ.getString( "delete.delete-dir.notice", m_dir.getAbsolutePath() );
- getContext().info( message );
- deleteDir( m_dir );
- }
-
- // delete the files in the filesets
- final int size = filesets.size();
- for( int i = 0; i < size; i++ )
- {
- final FileSet fileSet = (FileSet)filesets.get( i );
- final DirectoryScanner scanner =
- ScannerUtil.getDirectoryScanner( fileSet );
- final String[] files = scanner.getIncludedFiles();
- final String[] dirs = scanner.getIncludedDirectories();
- removeFiles( fileSet.getDir(), files, dirs );
- }
- }
-
- private void validate()
- throws TaskException
- {
- if( null == m_file && null == m_dir && 0 == filesets.size() )
- {
- final String message = REZ.getString( "delete.nofiles.error" );
- throw new TaskException( message );
- }
-
- if( null != m_file && m_file.exists() && m_file.isDirectory() )
- {
- final String message =
- REZ.getString( "delete.bad-file.error", m_file.getAbsolutePath() );
- throw new TaskException( message );
- }
-
- if( null != m_file && !m_file.exists() )
- {
- final String message =
- REZ.getString( "delete.missing-file.error", m_file.getAbsolutePath() );
- getContext().debug( message );
- }
- }
-
- private void deleteDir( final File baseDir )
- throws TaskException
- {
- final File[] list = baseDir.listFiles();
- if( list != null )
- {
- deleteFiles( list );
- }
-
- if( getContext().isDebugEnabled() )
- {
- final String message =
- REZ.getString( "delete.delete-dir.notice", m_dir.getAbsolutePath() );
- getContext().debug( message );
- }
-
- if( !baseDir.delete() )
- {
- final String message =
- REZ.getString( "delete.delete-dir.error", m_dir.getAbsolutePath() );
- throw new TaskException( message );
- }
- }
-
- private void deleteFiles( final File[] list )
- throws TaskException
- {
- for( int i = 0; i < list.length; i++ )
- {
- final File file = list[ i ];
- if( file.isDirectory() )
- {
- deleteDir( file );
- }
- else
- {
- deleteFile( file );
- }
- }
- }
-
- private void deleteFile( final File file )
- throws TaskException
- {
- if( getContext().isDebugEnabled() )
- {
- final String message =
- REZ.getString( "delete.delete-file.notice", file.getAbsolutePath() );
- getContext().debug( message );
- }
-
- if( !file.delete() )
- {
- final String message =
- REZ.getString( "delete.delete-file.error", file.getAbsolutePath() );
- throw new TaskException( message );
- }
- }
-
- /**
- * remove an array of files in a directory, and a list of subdirectories
- * which will only be deleted if 'includeEmpty' is true
- *
- * @param d directory to work from
- * @param files array of files to delete; can be of zero length
- * @param dirs array of directories to delete; can of zero length
- */
- protected void removeFiles( final File baseDir,
- final String[] files,
- final String[] dirs )
- throws TaskException
- {
- if( files.length > 0 )
- {
- final String message =
- REZ.getString( "delete.delete-file.error",
- new Integer( files.length ),
- baseDir.getAbsolutePath() );
- getContext().info( message );
- for( int i = 0; i < files.length; i++ )
- {
- final File file = new File( baseDir, files[ i ] );
- deleteFile( file );
- }
- }
-
- if( dirs.length > 0 && m_includeEmpty )
- {
- int dirCount = 0;
- for( int j = dirs.length - 1; j >= 0; j-- )
- {
- final File dir = new File( baseDir, dirs[ j ] );
- final String[] dirFiles = dir.list();
- if( null == dirFiles || 0 == dirFiles.length )
- {
- deleteDir( dir );
- dirCount++;
- }
- }
-
- if( dirCount > 0 )
- {
- final String message =
- REZ.getString( "delete.summary.notice",
- new Integer( dirCount ),
- baseDir.getAbsolutePath() );
- getContext().info( message );
- }
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/FilteredCopyTask.java b/proposal/myrmidon/src/java/org/apache/antlib/file/FilteredCopyTask.java
deleted file mode 100644
index 912bc9cda..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/FilteredCopyTask.java
+++ /dev/null
@@ -1,132 +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.antlib.file;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import org.apache.avalon.excalibur.io.IOUtil;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.filters.LineFilterSet;
-
-/**
- * A task used to copy files and simultaneously apply a
- * filter on said files.
- *
- * @ant.task name="filtered-copy"
- * @author Peter Donald
- * @version $Revision$ $Date$
- */
-public class FilteredCopyTask
- extends CopyTask
-{
- private LineFilterSet m_filterSetCollection = new LineFilterSet();
- private String m_encoding = "US-ASCII";
-
- public void addFilterset( final LineFilterSet filter )
- {
- m_filterSetCollection.add( filter );
- }
-
- public void setEncoding( final String encoding )
- {
- m_encoding = encoding;
- }
-
- /**
- * Utility method to perform operation to transform a single source file
- * to a destination.
- */
- protected void doOperation( final String sourceFilename,
- final String destinationFilename )
- throws IOException
- {
- final File source = new File( sourceFilename );
- final File destination = new File( destinationFilename );
-
- InputStream inputStream = null;
- OutputStream outputStream = null;
- BufferedReader input = null;
- BufferedWriter output = null;
- try
- {
- inputStream = new FileInputStream( source );
- outputStream = new FileOutputStream( destination );
-
- final Reader fileReader = new InputStreamReader( inputStream, m_encoding );
- final Writer fileWriter = new OutputStreamWriter( outputStream, m_encoding );
- input = new BufferedReader( fileReader );
- output = new BufferedWriter( fileWriter );
-
- process( input, output );
- }
- catch( final UnsupportedEncodingException uee )
- {
- throw new IOException( uee.toString() );
- }
- finally
- {
- IOUtil.shutdownReader( input );
- IOUtil.shutdownStream( inputStream );
- IOUtil.shutdownWriter( output );
- IOUtil.shutdownStream( outputStream );
- }
-
- if( isPreserveLastModified() )
- {
- destination.setLastModified( source.lastModified() );
- }
- }
-
- private void process( final BufferedReader input,
- final BufferedWriter output )
- throws IOException
- {
- String newline = null;
- String line = input.readLine();
- while( null != line )
- {
- if( line.length() == 0 )
- {
- output.newLine();
- }
- else
- {
- newline = replaceTokens( line );
- output.write( newline );
- output.newLine();
- }
- line = input.readLine();
- }
- }
-
- private String replaceTokens( final String line )
- throws IOException
- {
- try
- {
- final StringBuffer buffer = new StringBuffer( line );
- m_filterSetCollection.filterLine( buffer, getContext() );
- return buffer.toString();
- }
- catch( final TaskException te )
- {
- throw new IOException( te.getMessage() );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/ListPathTask.java b/proposal/myrmidon/src/java/org/apache/antlib/file/ListPathTask.java
deleted file mode 100644
index b9cdc5170..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/ListPathTask.java
+++ /dev/null
@@ -1,49 +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.antlib.file;
-
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.file.FileList;
-import org.apache.myrmidon.framework.file.Path;
-
-/**
- * A diagnostic task that lists the contents of a path.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.task name="list-path"
- */
-public class ListPathTask
- extends AbstractTask
-{
- private final Path m_path = new Path();
-
- /**
- * Adds a nested path.
- */
- public void add( final FileList list )
- {
- m_path.add( list );
- }
-
- /**
- * Executes the task.
- */
- public void execute()
- throws TaskException
- {
- final String[] files = m_path.listFiles( getContext() );
- for( int i = 0; i < files.length; i++ )
- {
- final String file = files[ i ];
- getContext().info( file );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/Mkdir.java b/proposal/myrmidon/src/java/org/apache/antlib/file/Mkdir.java
deleted file mode 100644
index 2e9e40452..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/Mkdir.java
+++ /dev/null
@@ -1,67 +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.antlib.file;
-
-import java.io.File;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * Creates specified directory.
- *
- * @ant.task name="mkdir"
- * @author Peter Donald
- * @author duncan@x180.com
- * @version $Revision$ $Date$
- */
-public class Mkdir
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( Mkdir.class );
-
- private File m_dir;
-
- public void setDir( final File dir )
- {
- m_dir = dir;
- }
-
- public void execute()
- throws TaskException
- {
- if( null == m_dir )
- {
- final String message = REZ.getString( "mkdir.missing-dir.error" );
- throw new TaskException( message );
- }
-
- if( m_dir.isFile() )
- {
- final String message =
- REZ.getString( "mkdir.file-exists.error", m_dir.getAbsolutePath() );
- throw new TaskException( message );
- }
-
- if( !m_dir.exists() )
- {
- final boolean result = m_dir.mkdirs();
- if( !result )
- {
- final String message =
- REZ.getString( "mkdir.nocreate.error", m_dir.getAbsolutePath() );
- throw new TaskException( message );
- }
- final String message =
- REZ.getString( "mkdir.create.notice", m_dir.getAbsolutePath() );
- getContext().info( message );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/MoveTask.java b/proposal/myrmidon/src/java/org/apache/antlib/file/MoveTask.java
deleted file mode 100644
index 1296fa6a1..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/MoveTask.java
+++ /dev/null
@@ -1,48 +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.antlib.file;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.avalon.excalibur.io.FileUtil;
-
-/**
- * A task used to move files.
- *
- * @ant.task name="move"
- * @author Peter Donald
- * @version $Revision$ $Date$
- */
-public class MoveTask
- extends CopyTask
-{
- /**
- * Utility method to perform operation to transform a single source file
- * to a destination.
- */
- protected void doOperation( final String sourceFilename,
- final String destinationFilename )
- throws IOException
- {
- final File source = new File( sourceFilename );
- final File destination = new File( destinationFilename );
-
- if( destination.exists() )
- {
- FileUtil.forceDelete( destination );
- }
- FileUtil.copyFile( source, destination );
-
- if( isPreserveLastModified() )
- {
- destination.setLastModified( source.lastModified() );
- }
-
- FileUtil.forceDelete( source );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/file/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/file/Resources.properties
deleted file mode 100644
index e0910e0e2..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/file/Resources.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-mkdir.missing-dir.error=dir attribute is required.
-mkdir.file-exists.error=Unable to create directory as a file already exists with that name: "{0}".
-mkdir.nocreate.error=Failed to create directory {0} due to an unknown reason.
-mkdir.create.notice=Created dir: {0}
-
-touch.neg-time.error=Date of {0} results in negative milliseconds value relative to epoch (January 1, 1970, 00:00:00 GMT).
-touch.no-files.error=Specify at least one source - a file or a fileset.
-touch.use-fileset.error=Use a fileset to touch directories.
-touch.readonly-file.error=Can not change modification date of read-only file {0}.
-touch.no-touch.error=Could not create file {0} due to {1}.
-touch.create.notice=Creating {0}.
-
-delete.nofiles.error=At least one of the file or dir attributes, or a fileset element, must be set.
-delete.bad-file.error=Directory {0} cannot be removed using the file attribute. Use dir instead.
-delete.missing-file.error=Could not find file {0} to delete.
-delete.delete-dir.notice=Deleting directory {0}.
-delete.delete-dir.error=Unable to delete directory {0}.
-delete.delete-file.notice=Deleting {0}.
-delete.delete-file.error=Unable to delete file {0}.
-delete.delete-file.error=Deleting {0} files from {1}.
-delete.summary.notice=Deleted {0,choice,0#zero directories|1#1 directory|2<{0} directories} from {1}.
-
-copy.omit-uptodate.notice={0} omitted as {1} is up to date.
-copy.missing-src.error=No source file or fileset specified.
-copy.one-dest-only.error=Only one of destFile or destDir may be set.
-copy.fileset-for-dirs.error=Use a fileset to copy directories.
-copy.need-destdir.error=Cannot copy multiple files into a single file.
-copy.bad-mapping.error=Cannot concatenate multiple files into a single file.
-copy.bad-operation.error=Cannot perform operation from directory to file.
-copy.missing-file.error=Could not find file {0} to copy.
-copy.dir-count.notice=Copied {0} empty director{0,choice,1#y|2
source
: the location of
- * the audio file to be played duration
: play the sound file
- * continuously until "duration" milliseconds has expired loops
:
- * the number of times the sound file should be played until stopped I have only
- * tested this with .WAV and .AIFF sound file formats. Both seem to work fine.
- * plans for the future: - use the midi api to define sounds (or drum beat etc)
- * in xml and have Ant play them back
- *
- * @ant.task name="sound-listener"
- * @author Nick Pellow
- * @author Peter Donald
- * @version $Revision$, $Date$
- */
-public class SoundTask
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( SoundTask.class );
-
- private BuildAlert m_success;
- private BuildAlert m_fail;
-
- public void addFail( final BuildAlert fail )
- {
- m_fail = fail;
- }
-
- public void addSuccess( final BuildAlert success )
- {
- m_success = success;
- }
-
- public void execute()
- throws TaskException
- {
- final AntSoundPlayer soundPlayer = new AntSoundPlayer();
- if( null == m_success )
- {
- final String message = REZ.getString( "sound.missing-success.error" );
- getContext().warn( message );
- }
- else
- {
- final File source = getRandomSource( m_success );
- soundPlayer.addBuildSuccessfulSound( source,
- m_success.getLoops(),
- m_success.getDuration() );
- }
-
- if( null == m_fail )
- {
- final String message = REZ.getString( "sound.missing-failure.error" );
- getContext().warn( message );
- }
- else
- {
- final File source = getRandomSource( m_fail );
- soundPlayer.addBuildFailedSound( source,
- m_fail.getLoops(),
- m_fail.getDuration() );
- }
-
- final Workspace workspace = (Workspace)getContext().getService( Workspace.class );
- workspace.addProjectListener( soundPlayer );
- }
-
- /**
- * Gets the location of the file to get the audio.
- */
- private File getRandomSource( final BuildAlert alert )
- throws TaskException
- {
- final File source = alert.getSource();
- // Check if source is a directory
- if( source.exists() )
- {
- if( source.isDirectory() )
- {
- // get the list of files in the dir
- final String[] entries = source.list();
- final ArrayList files = new ArrayList();
- for( int i = 0; i < entries.length; i++ )
- {
- final File file = new File( source, entries[ i ] );
- if( file.isFile() )
- {
- files.add( file );
- }
- }
- if( files.size() < 1 )
- {
- final String message = REZ.getString( "sound.empty.dir.error", source );
- throw new TaskException( message );
- }
- final int numfiles = files.size();
- // get a random number between 0 and the number of files
- final Random random = new Random();
- final int x = random.nextInt( numfiles );
- // set the source to the file at that location
- return (File)files.get( x );
- }
- else
- {
- return null;
- }
- }
- else
- {
- final String message = REZ.getString( "sound.invalid-path.error", source );
- getContext().warn( message );
- return null;
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/CopyFilesTask.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/CopyFilesTask.java
deleted file mode 100644
index 5bcb2fd0b..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/CopyFilesTask.java
+++ /dev/null
@@ -1,156 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileType;
-import org.apache.aut.vfs.NameScope;
-import org.apache.aut.vfs.FileConstants;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A task that copies files.
- *
- * @author Adam Murdoch
- *
- * @ant.task name="v-copy"
- */
-public class CopyFilesTask
- extends AbstractTask
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( CopyFilesTask.class );
-
- private FileObject m_srcFile;
- private FileObject m_destFile;
- private FileObject m_destDir;
- private ArrayList m_fileSets = new ArrayList();
-
- /**
- * Sets the source file.
- */
- public void setSrcfile( final FileObject file )
- {
- m_srcFile = file;
- }
-
- /**
- * Sets the destination file.
- */
- public void setDestfile( final FileObject file )
- {
- m_destFile = file;
- }
-
- /**
- * Sets the destination directory.
- */
- public void setDestdir( final FileObject file )
- {
- m_destDir = file;
- }
-
- /**
- * Sets the source directory.
- */
- public void setSrcdir( final FileObject dir )
- {
- add( new DefaultFileSet( dir ) );
- }
-
- /**
- * Adds a source file set.
- */
- public void add( final FileSet fileset )
- {
- m_fileSets.add( fileset );
- }
-
- /**
- * Execute task.
- * This method is called to perform actual work associated with task.
- * It is called after Task has been Configured and Initialized and before
- * beig Disposed (If task implements appropriate interfaces).
- *
- * @exception TaskException if an error occurs
- */
- public void execute()
- throws TaskException
- {
- if( m_srcFile == null && m_fileSets.size() == 0 )
- {
- final String message = REZ.getString( "copyfilestask.no-source.error", getContext().getName() );
- throw new TaskException( message );
- }
- if( m_destFile == null && m_destDir == null )
- {
- final String message = REZ.getString( "copyfilestask.no-destination.error", getContext().getName() );
- throw new TaskException( message );
- }
- if( m_fileSets.size() > 0 && m_destDir == null )
- {
- final String message = REZ.getString( "copyfilestask.no-destination-dir.error", getContext().getName() );
- throw new TaskException( message );
- }
-
- try
- {
- // Copy the source file across
- if( m_srcFile != null )
- {
- if( m_destFile == null )
- {
- m_destFile = m_destDir.resolveFile( m_srcFile.getName().getBaseName() );
- }
-
- getContext().verbose( "copy " + m_srcFile + " to " + m_destFile );
- m_destFile.copyFrom( m_srcFile, FileConstants.SELECT_SELF );
- }
-
- // Copy the contents of the filesets across
- for( Iterator iterator = m_fileSets.iterator(); iterator.hasNext(); )
- {
- FileSet fileset = (FileSet)iterator.next();
- FileSetResult result = fileset.getResult( getContext() );
- final FileObject[] files = result.getFiles();
- final String[] paths = result.getPaths();
- for( int i = 0; i < files.length; i++ )
- {
- final FileObject srcFile = files[ i ];
- final String path = paths[ i ];
-
- // TODO - map destination name
-
- // TODO - maybe include empty dirs
- if( srcFile.getType() != FileType.FILE )
- {
- continue;
- }
-
- // Locate the destination file
- final FileObject destFile = m_destDir.resolveFile( path, NameScope.DESCENDENT );
-
- // Copy the file across
- getContext().verbose( "copy " + srcFile + " to " + destFile );
- destFile.copyFrom( srcFile, FileConstants.SELECT_SELF );
- }
- }
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileList.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileList.java
deleted file mode 100644
index 731c7cbd2..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileList.java
+++ /dev/null
@@ -1,78 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A compound file list, which is made up of several other file lists.
- *
- * @author Adam Murdoch
- *
- * @ant.data-type name="v-path"
- * @ant.type type="v-path" name="v-path"
- */
-public class DefaultFileList implements FileList
-{
- private final List m_elements = new ArrayList();
-
- /**
- * Adds a single file to this list.
- */
- public void addLocation( final FileObject file )
- {
- final SingletonFileList element = new SingletonFileList();
- element.setFile( file );
- m_elements.add( element );
- }
-
- /**
- * Adds a path to this list.
- */
- public void addPath( final String pathStr )
- {
- final PathFileList path = new PathFileList();
- path.setPath( pathStr );
- m_elements.add( path );
- }
-
- /**
- * Adds a file list to this list.
- */
- public void add( final FileList list )
- {
- m_elements.add( list );
- }
-
- /**
- * Returns the list of files.
- */
- public FileObject[] listFiles( TaskContext context ) throws TaskException
- {
- // Collect the files from all elements
- final ArrayList allFiles = new ArrayList();
- for( Iterator iterator = m_elements.iterator(); iterator.hasNext(); )
- {
- FileList fileList = (FileList)iterator.next();
- FileObject[] files = fileList.listFiles( context );
- for( int i = 0; i < files.length; i++ )
- {
- FileObject file = files[ i ];
- allFiles.add( file );
- }
- }
-
- // Convert to array
- return (FileObject[])allFiles.toArray( new FileObject[ allFiles.size() ] );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSet.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSet.java
deleted file mode 100644
index 12bdbbe65..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSet.java
+++ /dev/null
@@ -1,120 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import org.apache.antlib.vfile.selectors.AndFileSelector;
-import org.apache.antlib.vfile.selectors.FileSelector;
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileType;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file set, that contains those files under a directory that match
- * a set of selectors.
- *
- * @author Adam Murdoch
- *
- * @ant.data-type name="v-fileset"
- * @ant.type type="v-fileset" name="v-fileset"
- */
-public class DefaultFileSet
- implements FileSet
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( DefaultFileSet.class );
-
- private FileObject m_dir;
- private final AndFileSelector m_selector = new AndFileSelector();
-
- public DefaultFileSet()
- {
- }
-
- public DefaultFileSet( final FileObject dir )
- {
- m_dir = dir;
- }
-
- /**
- * Sets the root directory.
- */
- public void setDir( final FileObject dir )
- {
- m_dir = dir;
- }
-
- /**
- * Adds a selector.
- */
- public void add( final FileSelector selector )
- {
- m_selector.add( selector );
- }
-
- /**
- * Returns the contents of the set.
- */
- public FileSetResult getResult( final TaskContext context )
- throws TaskException
- {
- if( m_dir == null )
- {
- final String message = REZ.getString( "fileset.dir-not-set.error" );
- throw new TaskException( message );
- }
-
- try
- {
- final DefaultFileSetResult result = new DefaultFileSetResult();
- final ArrayList stack = new ArrayList();
- final ArrayList pathStack = new ArrayList();
- stack.add( m_dir );
- pathStack.add( "" );
-
- while( stack.size() > 0 )
- {
- // Pop next folder off the stack
- FileObject folder = (FileObject)stack.remove( 0 );
- String path = (String)pathStack.remove( 0 );
-
- // Queue the children of the folder
- FileObject[] children = folder.getChildren();
- for( int i = 0; i < children.length; i++ )
- {
- FileObject child = children[ i ];
- String childPath = path + child.getName().getBaseName();
-
- // Check whether to include the file in the result
- if( m_selector.accept( child, childPath, context ) )
- {
- result.addElement( child, childPath );
- }
-
- if( child.getType() == FileType.FOLDER )
- {
- // A folder - push it on to the stack
- stack.add( 0, child );
- pathStack.add( 0, childPath + '/' );
- }
- }
- }
-
- return result;
- }
- catch( FileSystemException e )
- {
- final String message = REZ.getString( "fileset.list-files.error", m_dir );
- throw new TaskException( message, e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSetResult.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSetResult.java
deleted file mode 100644
index 9e350a4aa..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSetResult.java
+++ /dev/null
@@ -1,50 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.aut.vfs.FileObject;
-
-/**
- * An implementation of a file set result.
- *
- * @author Adam Murdoch
- */
-public class DefaultFileSetResult
- implements FileSetResult
-{
- private List m_files = new ArrayList();
- private List m_paths = new ArrayList();
-
- /**
- * Adds an element to the result.
- */
- public void addElement( final FileObject file,
- final String path )
- {
- m_files.add( file );
- m_paths.add( path );
- }
-
- /**
- * Returns the files in the result.
- */
- public FileObject[] getFiles()
- {
- return (FileObject[])m_files.toArray( new FileObject[ m_files.size() ] );
- }
-
- /**
- * Returns the virtual paths of the files.
- */
- public String[] getPaths()
- {
- return (String[])m_paths.toArray( new String[ m_paths.size() ] );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileList.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileList.java
deleted file mode 100644
index 2ee4d7e78..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileList.java
+++ /dev/null
@@ -1,35 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.DataType;
-
-/**
- * An ordered list of files.
- *
- * @author Adam Murdoch
- *
- * @ant:role shorthand="v-path"
- */
-public interface FileList
- extends DataType
-{
- /**
- * Returns the files in the list.
- *
- * @param context
- * The context to use to build the list of files.
- *
- * @throws TaskException
- * On error building the list of files.
- */
- FileObject[] listFiles( TaskContext context ) throws TaskException;
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSet.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSet.java
deleted file mode 100644
index 8bf9ec40b..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSet.java
+++ /dev/null
@@ -1,36 +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.antlib.vfile;
-
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.DataType;
-
-/**
- * A set of files, where each file in the list has a virtual path associated
- * with it.
- *
- * @author Adam Murdoch
- *
- * @ant:role shorthand="v-fileset"
- */
-public interface FileSet
- extends DataType
-{
- /**
- * Returns the contents of the set.
- *
- * @param context
- * The context to use to build the set.
- *
- * @throws TaskException
- * On error building the set.
- */
- FileSetResult getResult( TaskContext context )
- throws TaskException;
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetAdaptor.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetAdaptor.java
deleted file mode 100644
index 755e241a3..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetAdaptor.java
+++ /dev/null
@@ -1,39 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * An adaptor from a {@link FileSet} to a {@link FileList}.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- */
-public class FileSetAdaptor
- implements FileList
-{
- private final FileSet m_fileset;
-
- public FileSetAdaptor( final FileSet fileset )
- {
- m_fileset = fileset;
- }
-
- /**
- * Returns the files in the list.
- */
- public FileObject[] listFiles( TaskContext context )
- throws TaskException
- {
- final FileSetResult result = m_fileset.getResult( context );
- return result.getFiles();
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetResult.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetResult.java
deleted file mode 100644
index 6aa66de40..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetResult.java
+++ /dev/null
@@ -1,28 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-
-/**
- * The contents of a {@link FileSet}.
- *
- * @author Adam Murdoch
- */
-public interface FileSetResult
-{
- /**
- * Returns the files in the result.
- */
- FileObject[] getFiles();
-
- /**
- * Returns the virtual paths of the files.
- */
- String[] getPaths();
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetToFileListConverter.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetToFileListConverter.java
deleted file mode 100644
index ed753fba5..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetToFileListConverter.java
+++ /dev/null
@@ -1,39 +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.antlib.vfile;
-
-import org.apache.aut.converter.AbstractConverter;
-import org.apache.aut.converter.ConverterException;
-
-/**
- * A converter from {@link FileSet} to {@link FileList}.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.converter source="org.apache.antlib.vfile.FileSet"
- * destination="org.apache.antlib.vfile.FileList"
- */
-public class FileSetToFileListConverter
- extends AbstractConverter
-{
- public FileSetToFileListConverter()
- {
- super( FileSet.class, FileList.class );
- }
-
- /**
- * Do the conversion.
- */
- protected Object convert( final Object original, final Object context )
- throws ConverterException
- {
- final FileSet src = (FileSet)original;
- return new FileSetAdaptor( src );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FilteredFileList.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FilteredFileList.java
deleted file mode 100644
index 9f002c1ff..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FilteredFileList.java
+++ /dev/null
@@ -1,73 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import org.apache.antlib.vfile.selectors.AndFileSelector;
-import org.apache.antlib.vfile.selectors.FileSelector;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file-list which filters another.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.data-type name="filtered-path"
- * @ant.type type="v-path" name="filtered-path"
- */
-public class FilteredFileList
- implements FileList
-{
- private DefaultFileList m_fileList = new DefaultFileList();
- private FileSelector m_selector;
-
- /**
- * Sets the selector to use to filter with.
- */
- public void setFilter( final AndFileSelector selector )
- {
- m_selector = selector;
- }
-
- /**
- * Sets the filelist to filter.
- */
- public void add( final FileList fileList )
- {
- m_fileList.add( fileList );
- }
-
- /**
- * Returns the files in the list.
- */
- public FileObject[] listFiles( final TaskContext context )
- throws TaskException
- {
- if( m_selector == null )
- {
- throw new TaskException( "filteredfilelist.no-selector.error" );
- }
-
- // Build the set of files
- final ArrayList acceptedFiles = new ArrayList();
- final FileObject[] files = m_fileList.listFiles( context );
- for( int i = 0; i < files.length; i++ )
- {
- final FileObject file = files[ i ];
- if( m_selector.accept( file, null, context ) )
- {
- acceptedFiles.add( file );
- }
- }
-
- return (FileObject[])acceptedFiles.toArray( new FileObject[ acceptedFiles.size() ] );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FlatFileSet.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/FlatFileSet.java
deleted file mode 100644
index bd9f03911..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/FlatFileSet.java
+++ /dev/null
@@ -1,54 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file set that flattens its contents into a single directory.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.data-type name="flat-fileset"
- * @ant.type type="v-fileset" name="flat-fileset"
- */
-public class FlatFileSet
- implements FileSet
-{
- private DefaultFileList m_files = new DefaultFileList();
-
- /**
- * Adds a file list to this set.
- */
- public void add( final FileList files )
- {
- m_files.add( files );
- }
-
- /**
- * Returns the contents of the set.
- */
- public FileSetResult getResult( final TaskContext context )
- throws TaskException
- {
- DefaultFileSetResult result = new DefaultFileSetResult();
- FileObject[] files = m_files.listFiles( context );
- for( int i = 0; i < files.length; i++ )
- {
- final FileObject file = files[ i ];
-
- // TODO - detect collisions
- result.addElement( file, file.getName().getBaseName() );
- }
-
- return result;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFileSetTask.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFileSetTask.java
deleted file mode 100644
index cb607e085..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFileSetTask.java
+++ /dev/null
@@ -1,54 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A debug task, that lists the contents of a {@link FileSet}.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.task name="v-list-fileset"
- */
-public class ListFileSetTask
- extends AbstractTask
-{
- private final ArrayList m_fileSets = new ArrayList();
-
- public void add( final FileSet fileSet )
- {
- m_fileSets.add( fileSet );
- }
-
- /**
- * Execute task.
- */
- public void execute()
- throws TaskException
- {
- final int count = m_fileSets.size();
- for( int i = 0; i < count; i++ )
- {
- final FileSet fileSet = (FileSet)m_fileSets.get(i );
- FileSetResult result = fileSet.getResult( getContext() );
- final FileObject[] files = result.getFiles();
- final String[] paths = result.getPaths();
- for( int j = 0; j < files.length; j++ )
- {
- final FileObject file = files[ j ];
- final String path = paths[ j ];
- getContext().info( path + " = " + file );
- }
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFilesTask.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFilesTask.java
deleted file mode 100644
index 229a9220f..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFilesTask.java
+++ /dev/null
@@ -1,47 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A debug task, which prints out the files in a file list.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.task name="v-list-path"
- */
-public class ListFilesTask
- extends AbstractTask
-{
- private final DefaultFileList m_files = new DefaultFileList();
-
- public void add( final FileList files )
- {
- m_files.add( files );
- }
-
- /**
- * Execute task.
- *
- * @exception TaskException if an error occurs
- */
- public void execute()
- throws TaskException
- {
- final FileObject[] files = m_files.listFiles( getContext() );
- for( int i = 0; i < files.length; i++ )
- {
- FileObject file = files[ i ];
- getContext().info( file.toString() );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/MappedFileSet.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/MappedFileSet.java
deleted file mode 100644
index 138d3b38d..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/MappedFileSet.java
+++ /dev/null
@@ -1,95 +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.antlib.vfile;
-
-import java.util.ArrayList;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.ChainFileNameMapper;
-
-/**
- * A fileset that maps another fileset.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.data-type name="mapped-fileset"
- */
-public class MappedFileSet
- implements FileSet
-{
- private final ArrayList m_filesets = new ArrayList();
- private ChainFileNameMapper m_mapper = new ChainFileNameMapper();
-
- /**
- * Sets the mapper to use.
- */
- public void setMapper( final ChainFileNameMapper mapper )
- {
- m_mapper.add( mapper );
- }
-
- /**
- * Sets the fileset to map.
- */
- public void add( final FileSet fileset )
- {
- m_filesets.add( fileset );
- }
-
- /**
- * Returns the contents of the set.
- */
- public FileSetResult getResult( final TaskContext context )
- throws TaskException
- {
- final DefaultFileSetResult result = new DefaultFileSetResult();
-
- // Map each source fileset.
- final int count = m_filesets.size();
- for( int i = 0; i < count; i++ )
- {
- final FileSet fileSet = (FileSet)m_filesets.get(i );
- mapFileSet( fileSet, result, context );
- }
-
- return result;
- }
-
- /**
- * Maps the contents of a fileset.
- */
- private void mapFileSet( final FileSet fileset,
- final DefaultFileSetResult result,
- final TaskContext context )
- throws TaskException
- {
- // Build the result from the nested fileset
- FileSetResult origResult = fileset.getResult( context );
- final FileObject[] files = origResult.getFiles();
- final String[] paths = origResult.getPaths();
-
- // Map each element of the result
- for( int i = 0; i < files.length; i++ )
- {
- final FileObject file = files[ i ];
- final String path = paths[ i ];
- String[] newPaths = m_mapper.mapFileName( path, context );
- if( newPaths == null )
- {
- continue;
- }
- for( int j = 0; j < newPaths.length; j++ )
- {
- String newPath = newPaths[j ];
- result.addElement( file, newPath );
- }
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/PathFileList.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/PathFileList.java
deleted file mode 100644
index 526350b63..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/PathFileList.java
+++ /dev/null
@@ -1,61 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileSystemManager;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.tools.todo.util.FileUtils;
-
-/**
- * A path made up of file names separated by ; and : characters. Similar to
- * a CLASSPATH or PATH environment variable.
- *
- * @author Adam Murdoch
- */
-public class PathFileList implements FileList
-{
- private String m_path;
-
- /**
- * Sets the path to use for this file list.
- */
- public void setPath( final String path )
- {
- m_path = path;
- }
-
- /**
- * Returns the list of files.
- */
- public FileObject[] listFiles( final TaskContext context )
- throws TaskException
- {
- FileSystemManager fileSystemManager = (FileSystemManager)context.getService( FileSystemManager.class );
-
- // TODO - move parsing to the VFS
- final String[] elements = FileUtils.parsePath( m_path );
- final FileObject[] result = new FileObject[ elements.length ];
- for( int i = 0; i < elements.length; i++ )
- {
- String element = elements[ i ];
- try
- {
- result[ i ] = fileSystemManager.resolveFile( context.getBaseDirectory(), element );
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-
- return result;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/vfile/Resources.properties
deleted file mode 100644
index b0eb4863c..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/Resources.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-bad-convert-string-to-file.error=Could not convert URI "{0}" into a file object.
-
-fileset.dir-not-set.error=Fileset root directory is not set.
-fileset.list-files.error=Could not list the files in folder "{0}".
-
-copyfilestask.no-source.error=No source files specified for {0} task.
-copyfilestask.no-destination.error=No destination file or directory specified for {0} task.
-copyfilestask.no-destination.error=No destination directory specified for {0} task.
-
-filteredfilelist.no-selector.error=No filter criteria specified.
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/SingletonFileList.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/SingletonFileList.java
deleted file mode 100644
index 472c6a5e3..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/SingletonFileList.java
+++ /dev/null
@@ -1,40 +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.antlib.vfile;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file list that contains a single file.
- *
- * @author Adam Murdoch
- *
- */
-public class SingletonFileList
- implements FileList
-{
- private FileObject m_file;
-
- /**
- * Sets the file to use for tils file list.
- */
- public void setFile( final FileObject file )
- {
- m_file = file;
- }
-
- /**
- * Returns the list of files.
- */
- public FileObject[] listFiles( TaskContext context ) throws TaskException
- {
- return new FileObject[]{m_file};
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/StringToFileObjectConverter.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/StringToFileObjectConverter.java
deleted file mode 100644
index 481da5574..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/StringToFileObjectConverter.java
+++ /dev/null
@@ -1,58 +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.antlib.vfile;
-
-import org.apache.aut.converter.AbstractConverter;
-import org.apache.aut.converter.ConverterException;
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemManager;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
-
-/**
- * Converts a String to a {@link FileObject}
- *
- * @author Adam Murdoch
- * @ant.converter source="java.lang.String" destination="org.apache.aut.vfs.FileObject"
- */
-public class StringToFileObjectConverter
- extends AbstractConverter
-{
- private static final Resources REZ =
- ResourceManager.getPackageResources( StringToFileObjectConverter.class );
-
- public StringToFileObjectConverter()
- {
- super( String.class, FileObject.class );
- }
-
- /**
- * Converts a String into a FileObject.
- */
- protected Object convert( final Object original, final Object context )
- throws ConverterException
- {
- final String uri = (String)original;
- final TaskContext taskContext = (TaskContext)context;
-
- try
- {
- final FileSystemManager manager =
- (FileSystemManager)taskContext.getService( FileSystemManager.class );
-
- // TODO - change TaskContext.getBaseDirectory() to return a FileObject
- return manager.resolveFile( taskContext.getBaseDirectory(), uri );
- }
- catch( Exception e )
- {
- final String message = REZ.getString( "bad-convert-string-to-file.error", uri );
- throw new ConverterException( message, e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AbstractNameFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AbstractNameFileSelector.java
deleted file mode 100644
index dc241cf17..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AbstractNameFileSelector.java
+++ /dev/null
@@ -1,137 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.oro.text.GlobCompiler;
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-
-/**
- * An abstract file selector that selects files based on name.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- */
-public abstract class AbstractNameFileSelector
- implements FileSelector
-{
- private static final Resources REZ
- = ResourceManager.getPackageResources( AbstractNameFileSelector.class );
-
- private Object m_type;
- private String m_pattern;
-
- private static final Object TYPE_GLOB = "glob";
- private static final Object TYPE_REGEXP = "regexp";
-
- /**
- * Sets the GLOB pattern to match the name against.
- */
- public void setPattern( final String pattern )
- throws TaskException
- {
- setPattern( TYPE_GLOB, pattern );
- }
-
- /**
- * Sets the Regexp pattern to match the file basename against.
- */
- public void setRegexp( final String pattern )
- throws TaskException
- {
- setPattern( TYPE_REGEXP, pattern );
- }
-
- /**
- * Sets the pattern and type to match
- */
- private void setPattern( final Object type, final String pattern )
- throws TaskException
- {
- if( m_type != null )
- {
- final String message = REZ.getString( "nameselector.too-many-patterns.error" );
- throw new TaskException( message );
- }
- m_type = type;
- m_pattern = pattern;
- }
-
- /**
- * Accepts the file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- if( m_type == null )
- {
- final String message = REZ.getString( "nameselector.no-pattern.error" );
- throw new TaskException( message );
- }
-
- // Create the pattern to match against
- final Pattern pattern;
- try
- {
- if( m_type == TYPE_GLOB )
- {
- pattern = createGlobPattern( m_pattern );
- }
- else
- {
- pattern = createRegexpPattern( m_pattern );
- }
- }
- catch( MalformedPatternException e )
- {
- final String message = REZ.getString( "nameselector.bad-pattern.error", m_pattern );
- throw new TaskException( message );
- }
-
- // Get the name to match against
- final String name = getNameForMatch( path, file );
-
- // Compare the name against the pattern
- return new Perl5Matcher().matches( name, pattern );
- }
-
- /**
- * Creates a GLOB pattern for matching the name against.
- */
- protected Pattern createGlobPattern( final String pattern )
- throws MalformedPatternException
- {
- // TODO - need to implement Ant-style patterns
- return new GlobCompiler().compile( pattern );
- }
-
- /**
- * Creates a Regexp pattern for matching the name against.
- */
- protected Pattern createRegexpPattern( final String pattern )
- throws MalformedPatternException
- {
- return new Perl5Compiler().compile( pattern );
- }
-
- /**
- * Returns the name to match against.
- */
- protected abstract String getNameForMatch( final String path,
- final FileObject file )
- throws TaskException;
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AndFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AndFileSelector.java
deleted file mode 100644
index 0e67b9c1e..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AndFileSelector.java
+++ /dev/null
@@ -1,56 +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.antlib.vfile.selectors;
-
-import java.util.ArrayList;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that performs an AND of nested selectors. Performs
- * lazy evaluation. Returns true when no nested elements are supplied.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="and"
- */
-public class AndFileSelector
- implements FileSelector
-{
- private final ArrayList m_selectors = new ArrayList();
-
- /**
- * Adds a nested selector.
- */
- public void add( final FileSelector selector )
- {
- m_selectors.add( selector );
- }
-
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- for( int i = 0; i < m_selectors.size(); i++ )
- {
- final FileSelector fileSelector = (FileSelector)m_selectors.get( i );
- if( !fileSelector.accept( file, path, context ) )
- {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/BaseNameFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/BaseNameFileSelector.java
deleted file mode 100644
index f656433b1..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/BaseNameFileSelector.java
+++ /dev/null
@@ -1,31 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-
-/**
- * A file selector that selects files based on their base-name.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="basename"
- */
-public class BaseNameFileSelector
- extends AbstractNameFileSelector
-{
- /**
- * Returns the name to match against.
- */
- protected String getNameForMatch( final String path,
- final FileObject file )
- {
- return file.getName().getBaseName();
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ConditionSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ConditionSelector.java
deleted file mode 100644
index 31007c51f..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ConditionSelector.java
+++ /dev/null
@@ -1,47 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.conditions.AndCondition;
-import org.apache.myrmidon.framework.conditions.Condition;
-
-/**
- * A file selector that evaluates a set of nested {@link Condition} elements.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="condition"
- */
-public class ConditionSelector
- implements FileSelector
-{
- private AndCondition m_condition = new AndCondition();
-
- /**
- * Adds a condition.
- */
- public void add( final Condition condition )
- {
- m_condition.add( condition );
- }
-
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- return m_condition.evaluate( context );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ExistenceFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ExistenceFileSelector.java
deleted file mode 100644
index ef7d0a15e..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ExistenceFileSelector.java
+++ /dev/null
@@ -1,43 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that only selects files that exist.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="exists"
- */
-public class ExistenceFileSelector
- implements FileSelector
-{
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- try
- {
- return file.exists();
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileSelector.java
deleted file mode 100644
index f3ce41757..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileSelector.java
+++ /dev/null
@@ -1,34 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * Accepts files as part of a set.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant:role shorthand="v-file-selector"
- */
-public interface FileSelector
-{
- /**
- * Accepts a file.
- *
- * @param path The virtual path associated with the file. May be null
- * if such a path is not available.
- * @param file The file to select.
- * @param context The context to perform the selection in.
- */
- boolean accept( FileObject file, String path, TaskContext context )
- throws TaskException;
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileTestCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileTestCondition.java
deleted file mode 100644
index f7efe586c..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/FileTestCondition.java
+++ /dev/null
@@ -1,63 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.conditions.Condition;
-
-/**
- * A condition that applies a set of file selectors to a file.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="condition" name="file-test"
- */
-public class FileTestCondition
- implements Condition
-{
- private static final Resources REZ
- = ResourceManager.getPackageResources( FileTestCondition.class );
-
- private FileObject m_file;
- private AndFileSelector m_selector = new AndFileSelector();
-
- /**
- * Sets the file to test.
- */
- public void setFile( final FileObject file )
- {
- m_file = file;
- }
-
- /**
- * Adds a selector.
- */
- public void add( final FileSelector selector )
- {
- m_selector.add( selector );
- }
-
- /**
- * Evaluates this condition.
- */
- public boolean evaluate( final TaskContext context )
- throws TaskException
- {
- if( m_file == null )
- {
- final String message = REZ.getString( "filetestcondition.no-file.error" );
- throw new TaskException( message );
- }
- return m_selector.accept( m_file, null, context );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsEmptyFolderSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsEmptyFolderSelector.java
deleted file mode 100644
index da96a721b..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsEmptyFolderSelector.java
+++ /dev/null
@@ -1,46 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileType;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that selects empty directories.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="is-empty-folder"
- */
-public class IsEmptyFolderSelector
- implements FileSelector
-{
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- try
- {
- return ( file.exists()
- && file.getType() == FileType.FOLDER
- && file.getChildren().length == 0 );
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFileSelector.java
deleted file mode 100644
index 6f19a51b8..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFileSelector.java
+++ /dev/null
@@ -1,44 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileType;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector which only selects files, not folders.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="is-file"
- */
-public class IsFileSelector
- implements FileSelector
-{
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- try
- {
- return ( file.exists() && file.getType() == FileType.FILE );
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFolderSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFolderSelector.java
deleted file mode 100644
index 419ed4b61..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFolderSelector.java
+++ /dev/null
@@ -1,44 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.aut.vfs.FileSystemException;
-import org.apache.aut.vfs.FileType;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector which only selects folders, not files.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="is-folder"
- */
-public class IsFolderSelector
- implements FileSelector
-{
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- try
- {
- return ( file.exists() && file.getType() == FileType.FOLDER );
- }
- catch( FileSystemException e )
- {
- throw new TaskException( e.getMessage(), e );
- }
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NameFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NameFileSelector.java
deleted file mode 100644
index aabed0d5f..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NameFileSelector.java
+++ /dev/null
@@ -1,43 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that selects files based on their name.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="name"
- */
-public class NameFileSelector
- extends AbstractNameFileSelector
-{
- private static final Resources REZ
- = ResourceManager.getPackageResources( NameFileSelector.class );
-
- /**
- * Returns the name to match against.
- */
- protected String getNameForMatch( final String path,
- final FileObject file )
- throws TaskException
- {
- if( path == null )
- {
- final String message = REZ.getString( "namefileselector.no-path.error" );
- throw new TaskException( message );
- }
- return path;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NotFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NotFileSelector.java
deleted file mode 100644
index e4019f35c..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NotFileSelector.java
+++ /dev/null
@@ -1,55 +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.antlib.vfile.selectors;
-
-import org.apache.aut.vfs.FileObject;
-import org.apache.avalon.excalibur.i18n.ResourceManager;
-import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that negates a nested file selector.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="not"
- */
-public class NotFileSelector
- implements FileSelector
-{
- private static final Resources REZ
- = ResourceManager.getPackageResources( NotFileSelector.class );
-
- private FileSelector m_selector;
-
- /**
- * Sets the nested selector.
- */
- public void set( final FileSelector selector )
- {
- m_selector = selector;
- }
-
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- if( m_selector == null )
- {
- final String message = REZ.getString( "notfileselector.no-selector.error" );
- throw new TaskException( message );
- }
- return !m_selector.accept( file, path, context );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/OrFileSelector.java b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/OrFileSelector.java
deleted file mode 100644
index 7517196d3..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/OrFileSelector.java
+++ /dev/null
@@ -1,57 +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.antlib.vfile.selectors;
-
-import java.util.ArrayList;
-import org.apache.aut.vfs.FileObject;
-import org.apache.myrmidon.api.TaskContext;
-import org.apache.myrmidon.api.TaskException;
-
-/**
- * A file selector that performs an OR of nested selectors. Performs
- * lazy evaluation. Returns true when no nested elements are supplied.
- *
- * @author Adam Murdoch
- * @version $Revision$ $Date$
- *
- * @ant.type type="v-file-selector" name="or"
- */
-public class OrFileSelector
- implements FileSelector
-{
- private final ArrayList m_selectors = new ArrayList();
-
- /**
- * Adds a nested selector.
- */
- public void add( final FileSelector selector )
- {
- m_selectors.add( selector );
- }
-
- /**
- * Accepts a file.
- */
- public boolean accept( final FileObject file,
- final String path,
- final TaskContext context )
- throws TaskException
- {
- for( int i = 0; i < m_selectors.size(); i++ )
- {
- final FileSelector fileSelector = (FileSelector)m_selectors.get( i );
- if( fileSelector.accept( file, path, context ) )
- {
- return true;
- }
- }
-
- // Return true if there are no selectors, false if there are
- return ( m_selectors.size() == 0 );
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/Resources.properties
deleted file mode 100644
index 55e91a60f..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/Resources.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-nameselector.too-many-patterns.error=Too many name patterns specified.
-nameselector.no-pattern.error=No name pattern specified.
-nameselector.bad-pattern.error=Invalid name pattern "{0}".
-
-notfileselector.no-selector.error=No selector specified.
-
-namefileselector.no-path.error=Cannot use the XMLValidateTask
checks that an XML document is valid, with a
- * SAX validating parser.
- *
- * @author Raphael Pierquin
- * raphael.pierquin@agisphere.com
- */
-public class XMLValidateTask
- extends AbstractTask
-{
- /**
- * The default implementation parser classname used by the task to process
- * validation.
- */
- // The crimson implementation is shipped with ant.
- public static String DEFAULT_XML_READER_CLASSNAME = "org.apache.crimson.parser.XMLReaderImpl";
-
- private static String INIT_FAILED_MSG = "Could not start xml validation: ";
-
- // ant task properties
- // defaults
- private boolean m_warn = true;
- private boolean m_lenient;
- private String m_readerClassName = DEFAULT_XML_READER_CLASSNAME;
- private File m_file;// file to be validated
- private ArrayList m_filesets = new ArrayList();
-
- /**
- * the parser is viewed as a SAX2 XMLReader. If a SAX1 parser is specified,
- * it's wrapped in an adapter that make it behave as a XMLReader. a more
- * 'standard' way of doing this would be to use the JAXP1.1 SAXParser
- * interface.
- */
- private XMLReader m_xmlReader;// XMLReader used to validation process
-
- /**
- * to report sax parsing errors
- */
- private ValidatorErrorHandler m_errorHandler;
- private Hashtable m_features = new Hashtable();
-
- /**
- * The list of configured DTD locations
- */
- private ArrayList m_dtdLocations = new ArrayList();// sets of file to be validated
- private Path m_classpath = new Path();
-
- /**
- * Specify the class name of the SAX parser to be used. (optional)
- *
- * @param className should be an implementation of SAX2 org.xml.sax.XMLReader
- * or SAX2 org.xml.sax.Parser
.
- *
- * if className is an implementation of org.xml.sax.Parser
- * , {@link #setLenient(boolean)}, will be ignored.
- *
- * if not set, the default {@link #DEFAULT_XML_READER_CLASSNAME} will
- * be used.
- * @see org.xml.sax.XMLReader
- * @see org.xml.sax.Parser
- */
- public void setClassName( final String className )
- {
- m_readerClassName = className;
- }
-
- /**
- * Specify the classpath to be searched to load the parser (optional)
- */
- public void setClasspath( final String classpath )
- throws TaskException
- {
- m_classpath.add( classpath );
- }
-
- /**
- * specifify the file to be checked
- *
- * @param file The new File value
- */
- public void setFile( File file )
- {
- m_file = file;
- }
-
- /**
- * Specify whether the parser should be validating. Default is true
- * .
- * - * If set to false, the validation will fail only if the parsed document is - * not well formed XML.
- * - * this option is ignored if the specified class with {@link - * #setClassName(String)} is not a SAX2 XMLReader. - */ - public void setLenient( final boolean bool ) - { - m_lenient = bool; - } - - /** - * Specify how parser error are to be handled.
- *
- * If set to
- *
- * This task will recursively scan the sourcedir and destdir looking for XML
- * documents to process via XSLT. Any other files, such as images, or html files
- * in the source directory will be copied into the destination directory.
- *
- * @author Keith Visco
- * @author Sam Ruby
- * @author Russell Gold
- * @author Stefan Bodewig
- */
-public class XSLTProcess
- extends AbstractMatchingTask
-{
- private File m_destdir;
- private File m_basedir;
- private String m_targetExtension = ".html";
- private ArrayList m_params = new ArrayList();
- private File m_in;
- private File m_out;
- private Path m_classpath;
- private boolean m_force;
- private File m_stylesheet;
-
- private boolean m_processorPrepared;
- private TransformerFactory m_transformerFactory;
- private Transformer m_transformer;
-
- /**
- * Set the base directory.
- */
- public void setBasedir( final File basedir )
- {
- m_basedir = basedir;
- }
-
- /**
- * Set the classpath to load the Processor through (attribute).
- */
- public void setClasspath( final Path classpath )
- throws TaskException
- {
- addClasspath( classpath );
- }
-
- /**
- * Set the destination directory into which the XSL result files should be
- * copied to
- */
- public void setDestdir( final File destdir )
- {
- m_destdir = destdir;
- }
-
- /**
- * Set the desired file extension to be used for the target
- */
- public void setExtension( final String targetExtension )
- {
- m_targetExtension = targetExtension;
- }
-
- /**
- * Set whether to check dependencies, or always generate.
- */
- public void setForce( final boolean force )
- {
- m_force = force;
- }
-
- /**
- * Sets an input xml file to be styled
- */
- public void setIn( final File in )
- {
- m_in = in;
- }
-
- /**
- * Sets an out file
- */
- public void setOut( final File out )
- {
- m_out = out;
- }
-
- /**
- * Sets the file to use for styling relative to the base directory of this
- * task.
- */
- public void setStyle( final File stylesheet )
- {
- m_stylesheet = stylesheet;
- }
-
- /**
- * Set the classpath to load the Processor through (nested element).
- */
- public void addClasspath( final Path path )
- throws TaskException
- {
- if( m_classpath == null )
- {
- m_classpath = new Path();
- }
- m_classpath.add( path );
- }
-
- public void addParam( final XSLTParam param )
- {
- m_params.add( param );
- }
-
- public void execute()
- throws TaskException
- {
- validate();
-
- final FileSet fileSet = getFileSet();
- fileSet.setDir( m_basedir );
- final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
-
- prepareProcessor();
-
- // if we have an in file and out then process them
- if( m_in != null && m_out != null )
- {
- processSingleFile( m_in, m_out );
- return;
- }
-
- final String message = "Transforming into " + m_destdir;
- getContext().info( message );
-
- // Process all the files marked for styling
- processFiles( scanner );
-
- // Process all the directoried marked for styling
- processDirs( scanner );
- }
-
- private void validate()
- throws TaskException
- {
- if( null == m_stylesheet )
- {
- final String message = "no stylesheet specified";
- throw new TaskException( message );
- }
-
- if( null == m_basedir )
- {
- m_basedir = getBaseDirectory();
- }
-
- //-- make sure Source directory exists...
- if( null == m_destdir )
- {
- final String message = "destdir attributes must be set!";
- throw new TaskException( message );
- }
- }
-
- private void processDirs( final DirectoryScanner scanner )
- throws TaskException
- {
- final String[] dirs = scanner.getIncludedDirectories();
- for( int i = 0; i < dirs.length; i++ )
- {
- final String[] list = new File( m_basedir, dirs[ i ] ).list();
- for( int j = 0; j < list.length; j++ )
- {
- process( m_basedir, list[ j ], m_destdir );
- }
- }
- }
-
- private void processFiles( final DirectoryScanner scanner )
- throws TaskException
- {
- final String[] list = scanner.getIncludedFiles();
- for( int i = 0; i < list.length; ++i )
- {
- process( m_basedir, list[ i ], m_destdir );
- }
- }
-
- /**
- * Create transformer factory, loads the stylesheet and set xsl:param parameters.
- */
- protected void prepareProcessor()
- throws TaskException
- {
- if( m_processorPrepared )
- {
- return;
- }
- m_processorPrepared = true;
-
- //Note the next line should use the specified Classpath
- //and load the class dynaically
- m_transformerFactory = TransformerFactory.newInstance();
- m_transformerFactory.setErrorListener( new TraxErrorListener( true ) );
- //m_transformer.setOutputProperty( OutputKeys.METHOD, m_type );
-
- try
- {
- getContext().info( "Loading stylesheet " + m_stylesheet );
- specifyStylesheet();
- specifyParams();
- }
- catch( final Exception e )
- {
- final String message = "Failed to read stylesheet " + m_stylesheet;
- throw new TaskException( e.getMessage(), e );
- }
- }
-
- private void specifyStylesheet()
- throws Exception
- {
- final FileInputStream xslStream = new FileInputStream( m_stylesheet );
- try
- {
- final StreamSource source = new StreamSource( xslStream );
- source.setSystemId( getSystemId( m_stylesheet ) );
- final Templates template = m_transformerFactory.newTemplates( source );
- m_transformer = template.newTransformer();
- m_transformer.setErrorListener( new TraxErrorListener( true ) );
- }
- finally
- {
- IOUtil.shutdownStream( xslStream );
- }
- }
-
- private void specifyParams() throws TaskException
- {
- final Iterator params = m_params.iterator();
- while( params.hasNext() )
- {
- final XSLTParam param = (XSLTParam)params.next();
-
- final String expression = param.getExpression();
- if( expression == null )
- {
- throw new TaskException( "Expression attribute is missing." );
- }
-
- final String name = param.getName();
- if( name == null )
- {
- throw new TaskException( "Name attribute is missing." );
- }
-
- m_transformer.setParameter( name, expression );
- }
- }
-
- /**
- * Processes the given input XML file and stores the result in the given
- * resultFile.
- */
- private void process( final File baseDir, final String xmlFile, final File destDir )
- throws TaskException
- {
- final String filename = FileUtil.removeExtension( xmlFile );
-
- final File in = new File( baseDir, xmlFile );
- final File out = new File( destDir, filename + m_targetExtension );
-
- processFile( in, out );
- }
-
- private void processFile( final File in, final File out )
- throws TaskException
- {
- final long styleSheetLastModified = m_stylesheet.lastModified();
- try
- {
- if( m_force ||
- in.lastModified() > out.lastModified() ||
- styleSheetLastModified > out.lastModified() )
- {
- ensureDirectoryFor( out );
-
- final String notice = "Processing " + in + " to " + out;
- getContext().info( notice );
- transform( in, out );
- }
- }
- catch( final Exception e )
- {
- // If failed to process document, must delete target document,
- // or it will not attempt to process it the second time
- final String message = "Failed to process " + in;
- getContext().info( message );
- if( out != null )
- {
- out.delete();
- }
-
- throw new TaskException( e.getMessage(), e );
- }
- }
-
- private void processSingleFile( final File in, final File out )
- throws TaskException
- {
- final long styleSheetLastModified = m_stylesheet.lastModified();
- getContext().debug( "In file " + in + " time: " + in.lastModified() );
- getContext().debug( "Out file " + out + " time: " + out.lastModified() );
- getContext().debug( "Style file " + m_stylesheet + " time: " + styleSheetLastModified );
-
- processFile( in, out );
- }
-
- private void transform( final File in, final File out )
- throws Exception
- {
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try
- {
- fis = new FileInputStream( in );
- fos = new FileOutputStream( out );
- final StreamSource source = new StreamSource( fis, getSystemId( in ) );
- final StreamResult result = new StreamResult( fos );
-
- m_transformer.transform( source, result );
- }
- finally
- {
- IOUtil.shutdownStream( fis );
- IOUtil.shutdownStream( fos );
- }
- }
-
- private String getSystemId( final File file )
- throws IOException
- {
- return file.getCanonicalFile().toURL().toExternalForm();
- }
-
- private void ensureDirectoryFor( final File targetFile )
- throws TaskException
- {
- //In future replace me with
- //FileUtil.forceMkdir( targetFile.getParent() );
- File directory = new File( targetFile.getParent() );
- if( !directory.exists() )
- {
- if( !directory.mkdirs() )
- {
- throw new TaskException( "Unable to create directory: " +
- directory.getAbsolutePath() );
- }
- }
- }
-}
true
- *
- *(default), log a warn message for each SAX warn event.
- */
- public void setWarn( final boolean warn )
- {
- m_warn = warn;
- }
-
- /**
- * specifify a set of file to be checked
- */
- public void addFileset( final FileSet fileSet )
- {
- m_filesets.add( fileSet );
- }
-
- /**
- * @see #setClasspath
- */
- public void addClasspath( final Path path )
- throws TaskException
- {
- m_classpath.add( path );
- }
-
- /**
- * Create a DTD location record. This stores the location of a DTD. The DTD
- * is identified by its public Id. The location may either be a file
- * location or a resource location.
- *
- * @return Description of the Returned Value
- */
- public DTDLocation createDTD()
- {
- final DTDLocation dtdLocation = new DTDLocation();
- m_dtdLocations.add( dtdLocation );
- return dtdLocation;
- }
-
- public void execute()
- throws TaskException
- {
- int fileProcessed = 0;
- final int size = m_filesets.size();
- if( m_file == null && ( size == 0 ) )
- {
- final String message = "Specify at least one source - a file or a fileset.";
- throw new TaskException( message );
- }
-
- initValidator();
-
- if( m_file != null )
- {
- if( m_file.exists() && m_file.canRead() && m_file.isFile() )
- {
- doValidate( m_file );
- fileProcessed++;
- }
- else
- {
- final String message = "File " + m_file + " cannot be read";
- throw new TaskException( message );
- }
- }
-
- for( int i = 0; i < size; i++ )
- {
- final FileSet fileSet = (FileSet)m_filesets.get( i );
- final DirectoryScanner scanner = ScannerUtil.getDirectoryScanner( fileSet );
- final String[] files = scanner.getIncludedFiles();
-
- for( int j = 0; j < files.length; j++ )
- {
- final File srcFile = new File( fileSet.getDir(), files[ j ] );
- doValidate( srcFile );
- fileProcessed++;
- }
- }
- final String message = fileProcessed + " file(s) have been successfully validated.";
- getContext().info( message );
- }
-
- private EntityResolver buildEntityResolver()
- {
- final LocalResolver resolver = new LocalResolver( getContext() );
-
- final int size = m_dtdLocations.size();
- for( int i = 0; i < size; i++ )
- {
- final DTDLocation location = (DTDLocation)m_dtdLocations.get( i );
- resolver.registerDTD( location );
- }
-
- return resolver;
- }
-
- /*
- * set a feature on the parser.
- * TODO: find a way to set any feature from build.xml
- */
- private boolean setFeature( final String feature,
- final boolean value,
- final boolean warn )
- {
- boolean toReturn = false;
- try
- {
- m_xmlReader.setFeature( feature, value );
- toReturn = true;
- }
- catch( SAXNotRecognizedException e )
- {
- final String message = "Could not set feature '" + feature + "' because the parser doesn't recognize it";
- if( warn )
- {
- getContext().warn( message );
- }
- }
- catch( SAXNotSupportedException e )
- {
- final String message = "Could not set feature '" + feature + "' because the parser doesn't support it";
- if( warn )
- {
- getContext().warn( message );
- }
- }
- return toReturn;
- }
-
- /*
- * parse the file
- */
- private void doValidate( File afile )
- throws TaskException
- {
- try
- {
- getContext().debug( "Validating " + afile.getName() + "... " );
- m_errorHandler.reset();
- InputSource is = new InputSource( new FileReader( afile ) );
- String uri = "file:" + afile.getAbsolutePath().replace( '\\', '/' );
- for( int index = uri.indexOf( '#' ); index != -1;
- index = uri.indexOf( '#' ) )
- {
- uri = uri.substring( 0, index ) + "%23" + uri.substring( index + 1 );
- }
- is.setSystemId( uri );
- m_xmlReader.parse( is );
- }
- catch( SAXException ex )
- {
- final String message = "Could not validate document " + afile;
- throw new TaskException( message );
- }
- catch( IOException ex )
- {
- final String message = "Could not validate document " + afile;
- throw new TaskException( message, ex );
- }
-
- if( m_errorHandler.getFailure() )
- {
- final String message = afile + " is not a valid XML document.";
- throw new TaskException( message );
- }
- }
-
- /**
- * init the parser : load the parser class, and set features if necessary
- */
- private void initValidator()
- throws TaskException
- {
- try
- {
- // load the parser class
- // with JAXP, we would use a SAXParser factory
- final ClassLoader classLoader = FileListUtil.createClassLoader( m_classpath, getContext() );
- final Class readerClass = classLoader.loadClass( m_readerClassName );
-
- // then check it implements XMLReader
- if( XMLReader.class.isAssignableFrom( readerClass ) )
- {
-
- m_xmlReader = (XMLReader)readerClass.newInstance();
- getContext().debug( "Using SAX2 reader " + m_readerClassName );
- }
- else
- {
-
- // see if it is a SAX1 Parser
- if( Parser.class.isAssignableFrom( readerClass ) )
- {
- Parser parser = (Parser)readerClass.newInstance();
- m_xmlReader = new ParserAdapter( parser );
- getContext().debug( "Using SAX1 parser " + m_readerClassName );
- }
- else
- {
- throw new TaskException( INIT_FAILED_MSG
- + m_readerClassName
- + " implements nor SAX1 Parser nor SAX2 XMLReader." );
- }
- }
- }
- catch( ClassNotFoundException e )
- {
- throw new TaskException( INIT_FAILED_MSG + m_readerClassName, e );
- }
- catch( InstantiationException e )
- {
- throw new TaskException( INIT_FAILED_MSG + m_readerClassName, e );
- }
- catch( IllegalAccessException e )
- {
- throw new TaskException( INIT_FAILED_MSG + m_readerClassName, e );
- }
-
- m_xmlReader.setEntityResolver( buildEntityResolver() );
-
- m_errorHandler = new ValidatorErrorHandler( m_warn, getContext() );
- m_xmlReader.setErrorHandler( m_errorHandler );
-
- if( !( m_xmlReader instanceof ParserAdapter ) )
- {
- // turn validation on
- if( !m_lenient )
- {
- boolean ok = setFeature( "http://xml.org/sax/features/validation", true, true );
- if( !ok )
- {
- throw new TaskException( INIT_FAILED_MSG
- + m_readerClassName
- + " doesn't provide validation" );
- }
- }
- // set other features
- Enumeration enum = m_features.keys();
- while( enum.hasMoreElements() )
- {
- String featureId = (String)enum.nextElement();
- setFeature( featureId, ( (Boolean)m_features.get( featureId ) ).booleanValue(), true );
- }
- }
- }
-
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTParam.java b/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTParam.java
deleted file mode 100644
index 0adf87a58..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTParam.java
+++ /dev/null
@@ -1,34 +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.antlib.xml;
-
-public final class XSLTParam
-{
- private String m_name;
- private String m_expression;
-
- public void setExpression( String expression )
- {
- m_expression = expression;
- }
-
- public void setName( String name )
- {
- m_name = name;
- }
-
- protected String getExpression()
- {
- return m_expression;
- }
-
- protected String getName()
- {
- return m_name;
- }
-}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTProcess.java b/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTProcess.java
deleted file mode 100644
index cab3af969..000000000
--- a/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTProcess.java
+++ /dev/null
@@ -1,399 +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.antlib.xml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import org.apache.avalon.excalibur.io.FileUtil;
-import org.apache.avalon.excalibur.io.IOUtil;
-import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.framework.AbstractMatchingTask;
-import org.apache.myrmidon.framework.FileSet;
-import org.apache.tools.todo.types.DirectoryScanner;
-import org.apache.myrmidon.framework.file.Path;
-import org.apache.tools.todo.types.ScannerUtil;
-
-/**
- * A Task to process via XSLT a set of XML documents. This is useful for
- * building views of XML based documentation. arguments:
- *
- *
- * Of these arguments, the sourcedir and destdir are required.