-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.ps1
32 lines (25 loc) · 863 Bytes
/
compiler.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Define the source and output directories
$srcDir = "src"
$binDir = "bin"
# Create the output directory if it doesn't exist
if (-Not (Test-Path $binDir)) {
New-Item -ItemType Directory -Path $binDir
Write-Host "Created output directory: $binDir"
}
Write-Host "Compilation Running..."
# Recursively find all Java files in the source directory
$javaFiles = Get-ChildItem -Recurse -Filter *.java -Path $srcDir
# Generate a list of all Java file paths
$filePaths = $javaFiles | ForEach-Object { $_.FullName }
# Compile all Java files, specifying the output directory for compiled classes
& javac -d $binDir $filePaths
# Print file-name of all compiled classes
foreach ($file in $javaFiles) {
Write-Host $file.FullName
}
if ($LASTEXITCODE -eq 0) {
Write-Host "Compilation finished successfully!"
}
else {
Write-Host "Compilation failed!"
}