diff --git a/.gitignore b/.gitignore index 848d14da9..43716306e 100644 --- a/.gitignore +++ b/.gitignore @@ -239,6 +239,7 @@ rt/test/save/ZSTRMAC2.[mM][lL][cC] **/*.[xX][lL][sS] **/*.[xX][lL][sS][xX] **/*.[xX][mM][lL] +!src/**/*.[xX][mM][lL] # Backup and junk files macold/ diff --git a/bat/BLDJAR.BAT b/bat/BLDJAR.BAT index bb8bae826..f1247c5b7 100644 --- a/bat/BLDJAR.BAT +++ b/bat/BLDJAR.BAT @@ -32,6 +32,16 @@ shift /1 goto opt_loop :options_ok +rem download linter jar +if not exist "build\checkstyle" mkdir build\checkstyle +if not exist "build\checkstyle\checkstyle-all.jar" powershell -NoProfile -ExecutionPolicy Bypass -File "bat\GetCheckStyle.ps1" +if not exist "build\checkstyle\checkstyle-all.jar" goto return || rem download must have failed - cannot continue +java -jar build\checkstyle\checkstyle-all.jar --version + +rem run the linter +java -jar build\checkstyle\checkstyle-all.jar -c src\checkstyle.xml src +if %ERRORLEVEL% NEQ 0 goto return + rem prepare to compile java code and create jar file if not exist ".\jar\" mkdir jar cd jar diff --git a/bat/GetCheckStyle.PS1 b/bat/GetCheckStyle.PS1 new file mode 100644 index 000000000..ef58cdd90 --- /dev/null +++ b/bat/GetCheckStyle.PS1 @@ -0,0 +1,39 @@ +# Suppress Invoke-WebRequest's built-in progress bar +$ProgressPreference = 'SilentlyContinue' + +# Request latest release information +$apiUrl = 'https://api.github.com/repos/checkstyle/checkstyle/releases/latest' +$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'z390-build' } + +# Tag is usually "checkstyle-13.4.2" +$tag = $release.tag_name + +$asset = $release.assets | Where-Object { $_.name -match '-all\.jar$' } | Select-Object -First 1 +if (-not $asset) { + Write-Host "No -all.jar asset found for $tag" -ForegroundColor Red + exit 1 +} + +$uri = $asset.browser_download_url +$outFile = "build\checkstyle\checkstyle-all.jar" +$versionFile = 'build\checkstyle\version.txt' + +# Issue status message +Write-Host "Downloading linter from checkstyle repository on github.com..." + +# Define our own progress bar +Write-Progress -Activity "Download" -Status $uri -PercentComplete 0 + +# Download linter jar and report results +try { + Invoke-WebRequest -Uri $uri -OutFile $outFile -UseBasicParsing + $tag | Set-Content -Path $versionFile -NoNewline + Write-Progress -Activity "Download" -Completed + Write-Host "Download finished: $tag" + exit 0 +} +catch { + Write-Progress -Activity "Download" -Completed + Write-Host "Download failed: $($_.Exception.Message)" -ForegroundColor Red + exit 1 +} \ No newline at end of file diff --git a/src/az390.java b/src/az390.java index c2c419fc5..85dd38152 100644 --- a/src/az390.java +++ b/src/az390.java @@ -20,8 +20,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; import java.io.RandomAccessFile; import java.lang.reflect.Array; import java.math.BigDecimal; diff --git a/src/checkstyle.xml b/src/checkstyle.xml new file mode 100644 index 000000000..47e8393d6 --- /dev/null +++ b/src/checkstyle.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mz390.java b/src/mz390.java index 1f3225333..0919a2f17 100644 --- a/src/mz390.java +++ b/src/mz390.java @@ -20,8 +20,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; import java.lang.reflect.Array; import java.text.SimpleDateFormat; import java.util.Arrays;