ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb InnerClassFilenameFilter.java GenericDeploymentTool.java
Date Sun, 24 Sep 2000 11:50:20 GMT
conor       00/09/24 04:50:19

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        GenericDeploymentTool.java
  Added:       src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        InnerClassFilenameFilter.java
  Log:
  Include any inner classes in the generated Jar file.
  
  Submitted by:	Brian Towles <brian@towles.com>
  
  Revision  Changes    Path
  1.4       +26 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  
  Index: GenericDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GenericDeploymentTool.java	2000/09/09 11:48:11	1.3
  +++ GenericDeploymentTool.java	2000/09/24 11:50:18	1.4
  @@ -369,6 +369,8 @@
           Iterator entryIterator = null;
           String entryName = null;
           File entryFile = null;
  +	File entryDir = null;
  +	String innerfiles[] = null;
   
           try {
               /* If the jarfile already exists then whack it and recreate it.
  @@ -398,6 +400,27 @@
                   addFileToJar(jarStream,
                                new FileInputStream(entryFile),
                                entryName);
  +
  +		// See if there are any inner classes for this class and add them in if there are
  +		InnerClassFilenameFilter flt = new InnerClassFilenameFilter(entryFile.getName());
  +		entryDir = entryFile.getParentFile();
  +		innerfiles = entryDir.list(flt);
  +		for (int i=0, n=innerfiles.length; i < n; i++) {
  +	
  +			//get and clean up innerclass name
  +			entryName = entryName.substring(0, entryName.lastIndexOf(entryFile.getName())-1) + File.separatorChar
+ innerfiles[i];
  +
  +			// link the file
  +			entryFile = new File(srcDir, entryName);
  +
  +			getTask().log("adding innerclass file '" + entryName + "'", 
  +				    Project.MSG_VERBOSE);
  +
  +			addFileToJar(jarStream,
  +                                     new FileInputStream(entryFile),
  +                                     entryName);
  +
  +		}
               }
               // All done.  Close the jar stream.
               jarStream.close();
  @@ -410,6 +433,9 @@
               throw new BuildException(msg, ioe);
           }
       } // end of writeJar
  +
  + 
  +
       
   
       /**
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/InnerClassFilenameFilter.java
  
  Index: InnerClassFilenameFilter.java
  ===================================================================
  package org.apache.tools.ant.taskdefs.optional.ejb;
  
  import java.io.*;
  
  public class InnerClassFilenameFilter implements FilenameFilter {
  	private String baseClassName;
  
  	InnerClassFilenameFilter(String baseclass){
  		int extidx = baseclass.lastIndexOf(".class");
  		if (extidx == -1) {
  			extidx = baseclass.length()-1;
  		}
  		baseClassName = baseclass.substring(0,extidx);
  	}
  
  	public boolean accept (File Dir, String filename){
          	if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) 
  		    || (filename.indexOf(baseClassName + "$") != 0)) {
  				return false;
  		}
  		return true;
  	}
  }
  
  
  

Mime
View raw message