-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpackage.ps1
More file actions
80 lines (68 loc) · 2.45 KB
/
Copy pathpackage.ps1
File metadata and controls
80 lines (68 loc) · 2.45 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
param(
[switch]$SkipTests,
[string]$ReleaseDir = $env:INAZUMAGO_RELEASE_DIR
)
$ErrorActionPreference = 'Stop'
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectRoot = Split-Path -Parent $scriptDir
if (-not $ReleaseDir -or [string]::IsNullOrWhiteSpace($ReleaseDir)) {
$ReleaseDir = Join-Path $projectRoot 'target\releases'
}
# Manejo simple de variable JAVA_HOME: usa entorno actual o lee doc/ia/user-prompt.md.
$userPromptPath = Join-Path $projectRoot 'doc\ia\user-prompt.md'
if (-not $env:JAVA_HOME -and (Test-Path $userPromptPath)) {
$userPromptContent = Get-Content $userPromptPath -Raw
if ($userPromptContent -match '(?m)^\s*JDK_PATH\s*=\s*(.+?)\s*$') {
$candidate = $matches[1].Trim('"','''',' ')
if (Test-Path (Join-Path $candidate 'bin\java.exe')) {
$env:JAVA_HOME = $candidate
}
}
elseif ($userPromptContent -match "\$env:JAVA_HOME\s*=\s*'([^']+)'") {
$candidate = $matches[1]
if (Test-Path (Join-Path $candidate 'bin\java.exe')) {
$env:JAVA_HOME = $candidate
}
}
}
if ($env:JAVA_HOME) {
$javaBin = Join-Path $env:JAVA_HOME 'bin'
if (-not (($env:Path -split ';') -contains $javaBin)) {
$env:Path = "$javaBin;$env:Path"
}
}
$mvnw = Join-Path $projectRoot 'mvnw.cmd'
if (-not (Test-Path $mvnw)) {
Write-Error "No se encontro mvnw.cmd en la raiz del proyecto."
exit 1
}
Push-Location $projectRoot
try {
$mavenArgs = @('clean', 'package')
if ($SkipTests -or $env:INAZUMAGO_PACKAGE_SKIP_TESTS -eq 'true') {
$mavenArgs += '-DskipTests=true'
}
Write-Host "Ejecutando Maven Wrapper: $($mavenArgs -join ' ')" -ForegroundColor Cyan
& $mvnw @mavenArgs
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$jar = Get-ChildItem -Path (Join-Path $projectRoot 'target') -Filter '*.jar' |
Where-Object {
$_.Name -notlike '*-sources.jar' -and
$_.Name -notlike '*-javadoc.jar' -and
$_.Name -notlike 'original-*.jar'
} |
Select-Object -First 1
if (-not $jar) {
Write-Error 'No se encontro un JAR empaquetado en target/.'
exit 2
}
New-Item -ItemType Directory -Path $ReleaseDir -Force | Out-Null
$destination = Join-Path $ReleaseDir $jar.Name
Copy-Item -Path $jar.FullName -Destination $destination -Force
Write-Host "Packaging completado. Artefacto: $destination" -ForegroundColor Green
}
finally {
Pop-Location
}