VL-Programmieren/run.ps1

37 lines
1.1 KiB
PowerShell
Raw Permalink Normal View History

2024-05-02 14:42:56 +00:00
<#
.SYNOPSIS
Runs the solution of a specific exercise.
.DESCRIPTION
This script runs the solution of a specific exercise.
.PARAMETER Vorlesung
The number of the lecture to run the solution.
.PARAMETER Aufgabe
The number of the exercise to run the solution.
.EXAMPLE
Run the solution of exercise 1 of lecture 12.
.\Run -Vorlesung 12 -Aufgabe 1
#>
param(
[UInt16]$Vorlesung,
[Uint16]$Aufgabe
)
if ((-not (Get-Command java -ErrorAction SilentlyContinue)) -or (-not (Get-Command javac -ErrorAction SilentlyContinue))) {
throw "Java is not installed. Please install Java."
}
$formatVorlesung = '{0:d2}' -f $Vorlesung
$formatAufgabe = '{0:d2}' -f $Aufgabe
Write-Host "Vorlesung $formatVorlesung / Aufgabe $formatAufgabe"
$folderPathAufgabe = "VL$formatVorlesung/Aufgabe$formatAufgabe"
$filePathAufgabe = "$folderPathAufgabe/Aufgabe$formatAufgabe.java"
if (Test-Path $folderPathAufgabe -PathType Container) {
Get-ChildItem -path $folderPathAufgabe -Filter *.java -File | ForEach-Object { &"javac" $_.FullName}
}
if (Test-Path $filePathAufgabe -PathType Leaf) {
java $filePathAufgabe.Replace('/', '.').Replace('.java', '')
}