package com.erggroup.mass.ant.taskdefs; import java.io.*; import java.util.*; import java.util.zip.*; import org.apache.tools.ant.*; import org.apache.tools.ant.taskdefs.*; import org.apache.tools.ant.types.*; /** * Custom ANT task - given a code JAR and a source base, build a JAR * containing the corresponding source code. * * @ant.examples Here are examples * */ public class JarSrc extends Task { /** * The binary source file; the src jar will be constructed with a * corresponding name (-src) and will contain the code counterparts. */ private String binary; /** * The location that the source file will be created in. */ private String toDir; /** * The FileSet indicating which corresponding source files should be * obtained (if they exist) from the source path. */ private FileSet correspondingFileSet = null; /** * The set of directories under which the source code is located in * its' expected location. */ private ArrayList dirsets = new ArrayList(); /** * Set the filename of the source file. This file is used as a basis * for emulation, by constructing a src package to match. * * @param value the filename. */ public void setBinary( String value ) { binary = value; } /** * Set the 'todir', being the directory location in which the source * file will be constructed. * * @param value the directory. */ public void setToDir( String value ) { toDir = value; } /** * Nested element - this tag supports nested 'DirSet' elements. */ public DirSet createDirSet() { DirSet dirset = new DirSet(); dirsets.add( dirset ); return dirset; } /** * */ public void execute() throws BuildException { if ( dirsets.size() == 0 ) { throw new BuildException("At least one DirSet must be provided"); } for ( Iterator i=dirsets.iterator(); i.hasNext(); ) { DirSet dirset = (DirSet)i.next(); FileScanner scanner = dirset.getDirectoryScanner( getProject() ); String[] directories = scanner.getIncludedDirectories(); File basedir = scanner.getBasedir(); for ( int j=0; j