ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 29633] New: - Need DirDiff Task
Date Thu, 17 Jun 2004 08:08:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29633>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29633

Need DirDiff Task

           Summary: Need DirDiff Task
           Product: Ant
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: Nagendra.Raja@sun.com


When porting make to ant we need to see what is the difference between the 
build files when done from make and when done from ant. In such case it would 
be better to have DirDiff Task which takes in src and dest directories to 
compare and also the full file name(including path as we support for javac 
includes and excludes) patterns sets to compare.

I have one written see if this code helps

This code does not compare the files with-in the jar files. We may think of 
supporting this in the official ant task of DirDiff.


import org.apache.tools.ant.DirectoryScanner;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class DirDiff
{
    final DirectoryScanner masterDS;
    final DirectoryScanner childDS;

    public DirDiff( final DirectoryScanner aMasterDS,
		    final DirectoryScanner aChildDS )
    {
	masterDS = aMasterDS;
	childDS = aChildDS;
    }//constructor

    public void diff()
    {
	List exactMatchers = new ArrayList();
	List missingInChild = new ArrayList();
	List differsInChild = new ArrayList();
	List extraInChild = new ArrayList();
	extraInChild.addAll( Arrays.asList( childDS.getIncludedFiles() ) );

	String[] masterFiles = masterDS.getIncludedFiles();
	for ( int j = 0; j < masterFiles.length; j++ )
	{
	    File bMasterFile = new File( masterDS.getBasedir(), masterFiles
[j] );
	    File bChildFile = new File( childDS.getBasedir(), masterFiles[j] );
	    if ( bMasterFile.exists() )
	    {
		if ( !bChildFile.exists() )
		{
		    missingInChild.add( masterFiles[j] + "\n" );
		}
		else if ( bMasterFile.length() == bChildFile.length() )
		{
		    exactMatchers.add( masterFiles[j] + "\n" );
		}
		else
		{
		    differsInChild.add(
			    masterFiles[j] + "(" + (bMasterFile.length() - 
bChildFile.length()) +
			    ")\n" );
		}
		extraInChild.remove( masterFiles[j] );
	    }
	}

	System.out.println( "\n\nmissing In Child:" + missingInChild );
	System.out.println( "\n\ndiffers In Child:" + differsInChild );
	System.out.println( "\n\nextra In Child:" + extraInChild );
	//System.out.println( "Exact Match files:" + exactMatchers );
    }

    public static void main( String[] args )
    {
	DirectoryScanner master = new DirectoryScanner();
	master.setBasedir( "c:/temp" );
	DirectoryScanner child = master;
	new DirDiff( master, child ).diff();
    }//main()
}//class DirDiff

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


Mime
View raw message