CroftSoft / Portfolio

Compile All

This product was conceived of and implemented by David Wallace Croft for Analytic Services, Inc. while working on the Technology for Identifying Missing Children project.

This product may be downloaded and used under the terms of the license agreement below. As a recommended alternative, please consider the Apache Ant build and documentation tool.

1998-10-21

Function
Generates a script (or batch file), a compile report log file, and a package list to support autonomous periodic compilation and documentation of large Java source codebases organized in a package hierarchy directory tree. Traverses the source codebase directory tree searching for directories with one or more *.java files to generate the support files.
Applications
Autonomous nightly compilation of large in-house libraries and the generation of a log of the compile errors.
Creation of a list of Java packages for the automated generation of code documentation from a continuously updated source code repository.
Current Features
Recursive search for directories containing one or more *.java files.
Future Features
Option to list just compile errors instead of both successes and errors.
E-mail notification of the compile log.
Known Bugs
None.

Version

The latest version is 1.1, 1998-10-21.

License




CreateCompileAllScript

Version 1.1, 1998-10-21

Binary Code License



This binary code license ("License") contains rights and

restrictions associated with use of the accompanying



CreateCompileAllScript Version 1.1, 1998-10-21



software and documentation ("Software"). Read the License

carefully before using the Software. By using the Software

you agree to the terms and conditions of this License.



1.  License to Distribute. Licensee is granted a royalty-free

right to reproduce and distribute the Software provided that

Licensee: (i) distributes the Software complete and

unmodified; (ii) does not distribute additional software

intended to replace any component(s) of the Software; (iii)

does not remove or alter any proprietary legends or notices

contained in the Software; (iv) only distributes the Program

subject to a license agreement that protects ANSER's

interests consistent with the terms contained herein; and

(v) agrees to indemnify, hold harmless, and defend ANSER and

its licensors from and against any claims or lawsuits,

including attorneys' fees, that arise or result from the use

or distribution of the Program. 



2.  Restrictions. (a) Software is confidential copyrighted

information of ANSER and title to all copies is retained by

ANSER and/or its licensors. Except as otherwise provided by

law for purposes of decompilation of the Software, Licensee

shall not translate, reverse engineer, disassemble,

decompile, or otherwise attempt to derive the source code of

Software. Software may not be leased, assigned, or

sublicensed, in whole or in part, except as specifically

authorized in Section 1. (b) Software is not designed or

intended, and ANSER expressly disclaims any representations or

warranties (either expressed or implied), for use (i) in

online control of aircraft, air traffic, aircraft navigation

or aircraft communications; or (ii) in the design,

construction, operation or maintenance of any nuclear

facility.  



3.  Trademarks and Logos. This License does not authorize

Licensee to use any ANSER name, trademark or logo.



4.  Disclaimer of Warranty. Software is provided "AS IS,"

without a warranty of any kind. ALL EXPRESS OR IMPLIED

REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED

WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR

PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.



5.  Limitation of Liability.   IN NO EVENT WILL ANSER OR ITS

LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR

FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR

PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE

THEORY OF LIABILITY, RELATING TO THE USE, DOWNLOAD,

DISTRIBUTION OF OR INABILITY TO USE SOFTWARE, EVEN IF ANSER

HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



6.  Termination.  Licensee may terminate this License at any

time by destroying all copies of Software. This License will

terminate immediately without notice from ANSER if Licensee

fails to comply with any provision of this License. Upon

such termination, Licensee must destroy all copies of

Software.



7.  Maintenance and Support.  No upgrades or support are to

be provided to Licensee under the terms of this License.



8.  Export Regulations. Software, including technical data,

is subject to U.S. export control laws, including the U.S.

Export Administration Act and its associated regulations,

and may be subject to export or import regulations in other

countries. Licensee agrees to comply strictly with all such

regulations and acknowledges that it has the responsibility

to obtain licenses to export, re-export, or import Software.

Software may not be downloaded, or otherwise exported or

re-exported (i) into, or to a national or resident of, Cuba,

Iraq,Iran, North Korea, Libya, Sudan, Syria or any country

to which the U.S.has embargoed goods; or (ii) to anyone on

the U.S. Treasury Department's list of Specially Designated

Nations or the U.S. Commerce Department's Table of Denial

Orders.



9.  Restricted Rights. Use, duplication or disclosure by the

United States government is subject to the restrictions as

set forth in the Rights in Technical Data and Computer

Software Clauses in DFARS 252.227-7013(c) (1) (ii) and FAR

52.227-19(c) (2) as applicable.



10. Governing Law. Any action related to this License will

be governed by West Virginia law and controlling U.S. federal

law. No choice of law rules of any jurisdiction will apply.



11. Severability. If any of the above provisions are held to

be in violation of applicable law, void, or unenforceable in

any jurisdiction, then such provisions are herewith waived

or amended to the extent necessary for the License to be

otherwise enforceable in such jurisdiction.   However, if in

ANSER's opinion deletion or amendment of any provisions of the

License by operation of this paragraph unreasonably

compromises the rights or increase the liabilities of ANSER or

its licensors, ANSER reserves the right to terminate the

License and refund the fee paid by Licensee, if any, as

Licensee's sole and exclusive remedy.



Installation and Execution

  1. Download CreateCompileAllScript.zip.
    Extract CreateCompileAllScript.jar from the zip file.

  2. Install Java on your computer if you do not already have it.

  3. If you are using Java 1.1 instead of Java 1.2, include the location of the downloaded JAR file in your CLASSPATH environment variable.

    Example:

    
         set classpath=%classpath%;J:\lib\CreateCompileAllScript.jar
    
         

  4. For instructions, from the operating system command line prompt, run
    
         java -jar CreateCompileAllScript.jar
    
         
    if you have Java 1.2 or
    
         java org.anser.proj.timc.prog.croft.dev.CreateCompileAllScript
    
         
    if you have Java 1.1.

  5. You may wish to use a DOS batch file or Unix script.
    See compileAndDocAll.bat below.

Usage

Note that this program does not compile your source code library but rather creates a script that can be used to do so. The script is intended to work with both Wintel and Unix but it has only been tested at this time on Wintel.

Running the program without arguments will generate the following help message.




CreateCompileAllScript (1998-10-15)



Arguments (ordered):



  source code base directory

  compile destination directory

  compile results log filename

  javadoc packages list filename (optional)

  additional javac arguments (optional)



  Ex:  J:\src J:\lib compileAll.log javadoc_dirs.txt -nowarn



Usage:



  Redirect the output to a file and run as your script.



The source code base directory is the root of your package hierarchy of source code files. For example, if your first argument were J:\src and your source code tree were organized like this:

J:\src\org\anser\proj\timc\io\FileLib.java

J:\src\org\anser\proj\timc\lang\StringLib.java

J:\src\org\anser\proj\timc\prog\croft\dev\CreateCompileAllScript.java

it would imply that you have the following Java packages:

org.anser.proj.timc.io

org.anser.proj.timc.lang

org.anser.proj.timc.prog.croft.dev

The compile destination directory is the same as the -d option for javac.

The compile results log filename will be added to the script to store the results from the calls to javac. It can be reviewed periodically to determine if any Java classes are failing to compile.

When the optional javadoc packages list filename argument is provided, the program will append apparent package names to a separate file as it is generating the compile script. The package names are assumed to be relative to the source base directory. For those classes not in a package, their class names will be added instead. This list can be used for the automated generation of javadoc over all of the available packages with at least one *.java file. Use a batch file with the javadoc "@filename" option to take full advantage of the possibility of automating this as a nightly event.

Any additional arguments will be passed along as arguments to the javac commands in the generated script. For example, if you wish to ignore deprecation warnings, you can pass the argument "-nowarn".

Sample Output

This is a batch file, createCompileAllScript.bat, that I use to run the program. Note that additional arguments beyond the first 5 are passed along javac compiler directives.




set SOURCE_BASE=%1

if "%1"=="" set SOURCE_BASE=L:\java\src



set DESTINATION=%2

if "%2"=="" set DESTINATION=L:\java\lib



set COMPILE_LOG=%3

if "%3"=="" set COMPILE_LOG=L:\java\bat\compileAll.log



set SCRIPT=%4

if "%4"=="" set SCRIPT=L:\java\bat\compileAll.bat



set PACKAGE_LIST=%5

if "%5"=="" set PACKAGE_LIST=L:\java\bat\anserjavadoc_dirs.txt



java -jar CreateCompileAllScript.jar %SOURCE_BASE% %DESTINATION% %COMPILE_LOG% %PACKAGE_LIST% %6 %7 %8 %9 > %SCRIPT%



set SOURCE_BASE=

set DESTINATION=

set COMPILE_LOG=

set SCRIPT=

set PACKAGE_LIST=



This is a truncated sample of the output of the CreateCompileAllScript program. The output was redirected in the batch file above to the file compileAll.bat.



echo *** org.anser.proj.timc.app.agents.face.store > L:\java\bat\compileAll.log

javac -d L:\java\lib -J-Djavac.pipe.output=true L:\java\src\org\anser\proj\timc\app\agents\face\store\*.java >> L:\java\bat\compileAll.log

echo *** org.anser.proj.timc.prog.croft.dev >> L:\java\bat\compileAll.log

javac -d L:\java\lib -J-Djavac.pipe.output=true L:\java\src\org\anser\proj\timc\prog\croft\dev\*.java >> L:\java\bat\compileAll.log

echo *** org.anser.proj.timc.prog.croft.io >> L:\java\bat\compileAll.log

javac -d L:\java\lib -J-Djavac.pipe.output=true L:\java\src\org\anser\proj\timc\prog\croft\io\*.java >> L:\java\bat\compileAll.log



As you can see from above, the generated script will echo the name of the package to a report log (compileAll.log in this example), compile all of the source code in the package directory, and direct the compilation error output to the report log. If the javadoc packages list option is being used, a separate file would be created as well.

The report log file will contain the list of packages compiled with their respective compile errors:




*** org.anser.proj.timc.app.agents.face.store

*** org.anser.proj.timc.prog.croft.dev 

L:\java\src\org\anser\proj\timc\prog\croft\dev\LineCount.java:57: Wrong number of arguments in constructor.

       super ( true, null, new File ( directory, "." ) );

             ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\LineCount.java:69: Incompatible type for method. Explicit cast needed to convert java.lang.Object to java.io.File.

       if ( !super.isFiltrate ( node ) ) return false;

                                ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\LineCount.java:78: Class org.anser.proj.timc.prog.croft.dev.SearchEvent not found.

     public void  nextFetched ( SearchEvent  se )

                  ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\LineCount.java:81: Class org.anser.proj.timc.prog.croft.dev.SearchEvent not found in void nextFetched(org.anser.proj.timc.prog.croft.dev.SearchEvent).

       File  file = ( File ) se.getNode ( );

                                        ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\PackageChange.java:56: Wrong number of arguments in constructor.

       super ( true, null, new File ( directory, "." ) );

             ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\PackageChange.java:69: Incompatible type for method. Explicit cast needed to convert java.lang.Object to java.io.File.

       if ( !super.isFiltrate ( node ) ) return false;

                                ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\PackageChange.java:78: Class org.anser.proj.timc.prog.croft.dev.SearchEvent not found.

     public void  nextFetched ( SearchEvent  se )

                  ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\PackageChange.java:81: Class org.anser.proj.timc.prog.croft.dev.SearchEvent not found in void nextFetched(org.anser.proj.timc.prog.croft.dev.SearchEvent).

       File  file = ( File ) se.getNode ( );

                                        ^

L:\java\src\org\anser\proj\timc\prog\croft\dev\PackageChange.java:91: Method toKey(java.io.File) not found in class org.anser.proj.timc.prog.croft.dev.PackageChange.

         File  file_new = new File ( toKey ( file ) + ".new" );

                                           ^

Note: 2 files use or override a deprecated API.  Recompile with "-deprecation" for details.

9 errors, 1 warning

*** org.anser.proj.timc.prog.croft.io 



Note that the specific choices of the filenames were specified as parameter arguments above. You may choose your own filenames for any of these generated files.

org.anser.proj.timc.app.agents.face.store 

org.anser.proj.timc.prog.croft.dev 

org.anser.proj.timc.prog.croft.io 

As an example, here is a batch file, anserjavadoc.bat, that I use to automatically read anserjavadoc_dirs.txt and create the javadoc HTML documentation. Note that it uses the Java 1.2 javadoc "@filename" argument format.




set JAVADIR=%1

if "%JAVADIR%"=="" set JAVADIR=C:\jdk1.2b4



set DEST_DIR=%2

if "%DEST_DIR%"=="" set DEST_DIR=L:



deltree /Y %DEST_DIR%\java\doc

mkdir %DEST_DIR%\java\doc



%JAVADIR%\bin\javadoc @anserjavadoc_args.txt @anserjavadoc_dirs.txt



For completeness, here is the anserjavadoc_args.txt file that I use above as an example.



-linkall

-version

-author

-package

-d L:\java\doc

-sourcepath L:\java\src

-classpath L:\java\lib\ext\mail.jar;L:\java\lib\ext\activation.jar;L:\java\lib\ext\jws.jar;L:\java\lib\ext\NetComponents-1.3.7.zip;L:\java\lib\ext\swingall.jar;L:\java\lib\ext\collections.jar;L:\java\lib\ext\servlet.jar



Finally, here is a monolithic batch file, compileAndDocAll.bat, that can be modified and scheduled to run nightly to compile, log, and document your entire in-house source code library. This is only provided as an example and will need path and filename customization to be used in your environment.



@REM  compileAndDocAll.bat

@REM  1998-10-16

@REM  David Wallace Croft

@REM  croftd@nexos.anser.org

@REM

@REM  Uses the CreateCompileAllScript to automatically compile

@REM  and document a Java source code library.

@REM  Customize the path and filenames to your taste.





@REM  Start by deleting all of the old copies of the files to be generated.

@REM  If this batch file completes and they are missing, it is

@REM  probable that some process that was supposed to generate them

@REM  went awry.





del L:\java\bat\compileAll.bat

del L:\java\bat\compileAll.log

del L:\java\bat\javadoc_dirs.txt

del L:\java\bat\javadoc.log





@REM  This following command synchronizes the local source code library

@REM  directory tree with the latest updates from the configuration

@REM  management version control repository.



C:

cd C:\javasafe

C:\"Program Files"\JavaSafe1.0\Client\bin\js.exe sync -m__all__.JavaSafeMap





@REM  This clears out the older versions of the in-house library class files

@REM  and source code.  Note that we are just deleting the directories

@REM  at our project level.



deltree /y L:\java\lib\org\anser\proj\timc

deltree /y L:\java\src\org\anser\proj\timc





@REM  This creates the compile destination directory for the class files

@REM  and source code if they do not already exist.



mkdir L:\java\lib

mkdir L:\java\src





@REM  This copies the current updated copy of our source code

@REM  to a common work area to be used as the source code base.



xcopy /s C:\javasafe\java\src\*.java L:\java\src\*.java





@REM  This runs the CreateCompileAllScript program.

@REM  The output of this is directed to compileAll.bat.

@REM  The order of the arguments is source base, destination,

@REM  compile log, package list, and additional javac arguments.

@REM  Note that the "-jar" option to java only works with

@REM  Java version 1.2 (or above).



java -jar L:\java\bat\CreateCompileAllScript.jar L:\java\src L:\java\lib L:\java\bat\compileAll.log L:\java\bat\javadoc_dirs.txt -nowarn > L:\java\bat\compileAll.bat





@REM  This sets up our classpath.



set classpath=L:\java\src

call L:\java\bat\anser_ext_classpath





@REM  This runs the script that we generated using the

@REM  CreateCompileAllScript program.



call L:\java\bat\compileAll.bat





@REM  If we want, we can stop and view the compile report log.

@REM

@REM  type L:\java\bat\compileAll.log | more





@REM  Or we can have it automatically e-mailed to ourselves.

@REM  On UNIX, this may or may not be the command to do this.

@REM

@REM  mail croftd@nexos.anser.org < compileAll.log





@REM  Clean out the old javadoc HTML directory.

@REM  Load it up with the core Java class documentation

@REM  so that our in-house code documentation can link to it.



deltree /y L:\java\doc

mkdir L:\java\doc

xcopy /s C:\jdk1.2beta4\docs\*.* L:\java\doc\*.*





@REM  Now we generate the javadoc using the list of packages,

@REM  javadoc_dirs.txt, that the script compileAll.bat

@REM  created as it ran.



javadoc @L:\java\bat\javadoc_args.txt @L:\java\bat\javadoc_dirs.txt > L:\java\bat\javadoc.log





@REM  Here is what an example javadoc_args.txt may look like.

@REM  Note that the above "@filename" convention only works with

@REM  javadoc from the JDK version 1.2 (or above).

@REM

@REM  -linkall

@REM  -version

@REM  -author

@REM  -package

@REM  -d L:\java\doc

@REM  -sourcepath L:\java\src

@REM  -classpath L:\java\lib;L:\java\src;L:\java\lib\ext\swingall.jar;L:\java\lib\ext\collections.jar





@REM  Done.



Bug-Fixes

Version 1.1 shifts the creation of the javadoc packages list file to the first pass.

Version 1.0.1 correctly handles source code in the root of the source path in the "default" package.