Package Torello.Java.Build
Class BuildDataFiles
- java.lang.Object
-
- Torello.Java.Build.BuildDataFiles
-
public class BuildDataFiles extends java.lang.Object
The purpose of a Build-Tool is, fundamentally, to make a project possible by doing what a programmer would otherwise need enter manually into a keyboard hundreds of thousands of times himself. The package provides a CLI Menu that would performs hundreds and hundreds of otherwise extremely trivial tasks via a single UNIX CLI Command.
It is likely that no programmer on earth would determine that running the Standard Java Command'javac'
at a UNIX prompt to be an overly cumbersome or difficult task. Building and re-building the Data-Files for a particular project requires just that: compiling some'.java'
files, and then executing their'.class'
Files in order to obtain their output. Everything seems quite trivial so far.
Things become difficult when a project (for example the Java-HTML Library Tool) has such Data-File Building'.java'
classes spread out across quite a number of../data-files/
directories, and furthermore each of those directories have multiple Data-Files Classes to both compile and build. In such cases, whenever the need arises to tweak, debug, update or add to the../data-files/
directories, the value of some sort of scripting tool starts to look like an invaluable tool in the programmer's arsenal.
Why?
Because typing:'cd <dir-name>'
and'javac -switches <java-files>'
and'java <class-files>'
over and over again is a ROYAL PAIN IN THE ASS.
That's what this tool does for you. It enters all'../data-files/'
sub-directories of all Package Source Directories in your project and compiles then. Afterwards, it invokes thebuild
Method on any'.class'
files which have implemented theDataFileBuilderClass
inteface.- Enter all
my/package/dir/data-files/
directories
- Wipe / Delete all Java
'.class'
-Files present in../data-files/
and its sub-directories.
- Invoke
'javac'
(Re-Compile) all'.java'
-Files present in the directory and its sub-directories.
- Scan
../data-files/
and its sub directories for any and all'.class'
-Files. Afterwards, seek and identify if any of them implement theDataFileBuilderClass
interface.
- Invoke the
DataFileBuilderClass.build(String)
method on those classes which do implement the aforementioned interface. If the user has properly written them, those classes will produce Data-Files which are needed and required for the particular Java-Package being examined.
- That's all folks! It is that simple... 😊😊😊
CLI Output Example:
The following'.html'
-Page demonstrates what the output looks like when running this class against all of the'../data-files/'
directries which are utilized by this Java-HTML JAR-Library. This output was generated by this tool on Janaury 6th, 2025.Data-File-Builder.Output.html
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/Java/Build/BuildDataFiles.java
- Open New Browser-Tab: Torello/Java/Build/BuildDataFiles.java
File Size: 10,093 Bytes Line Count: 237 '\n' Characters Found
Internal Class: Compile Builders:
- View Here: CompileDataFilesBuilders.java
- Open New Browser-Tab: CompileDataFilesBuilders.java
File Size: 2,023 Bytes Line Count: 73 '\n' Characters Found
Internal Class: Run Builders:
- View Here: RunDataFilesBuilders.java
- Open New Browser-Tab: RunDataFilesBuilders.java
File Size: 4,940 Bytes Line Count: 122 '\n' Characters Found
How the Java-HTML Library Uses this Class:
- View Here: BuildJAR/DataFiles.java
- Open New Browser-Tab: BuildJAR/DataFiles.java
File Size: 588 Bytes Line Count: 23 '\n' Characters Found
-
-
Method Summary
Invoke this Method in order to use this CLI-Based Data Files Tool Modifier and Type Method static void
build(BuildPackage[] pkgList, String[] argv, ReadOnlyList<String> additionalCompilerArgs, String JAVAC_BIN)
-
-
-
Method Detail
-
build
public static void build (BuildPackage[] pkgList, java.lang.String[] argv, ReadOnlyList<java.lang.String> additionalCompilerArgs, java.lang.String JAVAC_BIN) throws java.io.IOException
This method should be invoked by anypublic static void main
method, and pass BOTH the provided'String[] argv'
parameter to this method, AND the remained of the required parameters needed.
Helper Code:
This method invokes two Package-Private and Internal-Classes for help. These external classes are listed above, at the top of this class' documentation page, and also here, below:
Example & Output:
This class & method are, indeed, utilized by the Java-HTML JAR-Library (this tool) to build its own Data-Files. The links here are also included above. These links are to Syntax-Hilited Source - and the output it produces- showing how this method & class may be used. These links are also included, here, directly below:- Parameters:
pkgList
- This list ofBuildPackage
instances ought to be the exact same list which is passed to theConfig
class instance used for running a build with this package.argv
- This is theString[] argv
parameter received from a CLI Processor at the Command-Line.additionalCompilerArgs
- This should be a listJAVAC_BIN
- This parameter may be null, and if it is, it shall be safely ignored. This parameter may include a relative or full path to a binary for the'javac'
program.
When this parameter is null, this Data-File Builder-Class will utilize whichever'javac'
binary is available within the Operating-System's'PATH'
Environment-Variable.- Throws:
java.io.IOException
- If any Operating-System I/O Errors throw.- Code:
- Exact Method Body:
final ReadOnlyList<BuildPackage> selectedPackages = DataFilesCLI.run(pkgList, argv); final PkgTextBar textBarPrinter = new PkgTextBar (selectedPackages, "Working Package", BGREEN_BKGND, BCYAN); final Map<String, Integer> totals = new TreeMap<>(); int maxLen = 0; for (final BuildPackage bp : selectedPackages) { textBarPrinter.print(bp); clearClassFiles(bp.pkgRootDirectory + "data-files" + File.separator); CompileDataFilesBuilders.compile(bp, additionalCompilerArgs, JAVAC_BIN); int numExecuted = RunDataFilesBuilders.run(bp); totals.put(bp.fullName, numExecuted); if (bp.fullName.length() > maxLen) maxLen = bp.fullName.length(); } if (selectedPackages.size() > 1) printTotals(totals, maxLen+2);
-
-