@@ -0,0 +1,33 @@
|
||||
param([switch]$Verify)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$projectRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location -LiteralPath $projectRoot
|
||||
|
||||
if (Test-Path -LiteralPath '.env') {
|
||||
foreach ($line in [System.IO.File]::ReadAllLines((Join-Path $projectRoot '.env'), [System.Text.Encoding]::UTF8)) {
|
||||
if ($line -match '^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$') {
|
||||
$settingName = $Matches[1]
|
||||
$settingValue = $Matches[2].Trim()
|
||||
if ($settingValue.Length -ge 2) {
|
||||
if (($settingValue.StartsWith('"') -and $settingValue.EndsWith('"')) -or
|
||||
($settingValue.StartsWith("'") -and $settingValue.EndsWith("'"))) {
|
||||
$settingValue = $settingValue.Substring(1, $settingValue.Length - 2)
|
||||
}
|
||||
}
|
||||
[Environment]::SetEnvironmentVariable($settingName, $settingValue, 'Process')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Host 'No existe .env. Se usarán las variables del proceso; consulta .env.example.'
|
||||
}
|
||||
|
||||
if (!(Get-Command java -ErrorAction SilentlyContinue)) {
|
||||
if ($env:JAVA_HOME -and (Test-Path -LiteralPath (Join-Path $env:JAVA_HOME 'bin/java.exe'))) {
|
||||
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"
|
||||
} else {
|
||||
throw 'No se encuentra Java. Instala JDK 25 o configura JAVA_HOME.'
|
||||
}
|
||||
}
|
||||
if ($Verify) { & (Join-Path $projectRoot 'mvnw.cmd') verify }
|
||||
else { & (Join-Path $projectRoot 'mvnw.cmd') spring-boot:run }
|
||||
exit $LASTEXITCODE
|
||||
Reference in New Issue
Block a user