The CompileScripts class is a singleton that handles dynamic compilation of Java script files into usable components for the Pi-Engine.
public class CompileScripts
| Property |
Type |
Description |
instance |
CompileScripts |
Singleton instance of CompileScripts |
scriptFolder |
File |
Source folder containing Java script files |
outputFolder |
File |
Output folder for compiled class files |
engineJar |
File |
Path to the engine JAR for compilation dependencies |
| Method |
Parameters |
Return Type |
Description |
getInstance(String scriptPath, String outputPath, String engineJarPath) |
String scriptPath, String outputPath, String engineJarPath |
CompileScripts |
Static method to get or create instance with paths |
getInstance() |
None |
CompileScripts |
Static method to get existing instance |
| Method |
Parameters |
Return Type |
Description |
compileScripts() |
None |
void |
Compiles all scripts in the script folder |
compileScript(File scriptFile) |
File scriptFile |
void |
Compiles a single script file |
compileSystems() |
None |
void |
(Reserved) Compiles system script files |
- Java source files are located in the script folder
- Each file is compiled using the Java compiler tool
- Compiled classes are output to the specified folder
- Compilation errors are logged for debugging
- Compiled scripts become available for loading by ScriptLoader
// Initialize CompileScripts with paths
CompileScripts compiler = CompileScripts.getInstance(
"Scripts", // Source folder
"Compiled", // Output folder
null // Engine JAR path (optional)
);
// Compile a specific script
compiler.compileScript(new File("Scripts/MyComponent.java"));
// Compile all scripts
compiler.compileScripts();
- Compilation errors are logged with source file information
- Invalid script files are skipped
- Runtime errors are caught and logged
- Failed compilations don't affect other scripts
- Keep script source files organized
- Handle compilation errors gracefully
- Use proper Java package declarations
- Maintain clear separation of concerns
- Follow component scripting guidelines