build-module.ps1 927 B

123456789101112131415161718192021222324252627282930313233
  1. param(
  2. [Parameter(Mandatory = $true)]
  3. [string]$Module,
  4. [Parameter(Mandatory = $true)]
  5. [string]$Namespace,
  6. [string]$Tag = "1.1.0",
  7. [switch]$SkipMaven
  8. )
  9. $ErrorActionPreference = "Stop"
  10. $JavaRoot = Split-Path -Parent $PSScriptRoot
  11. $ModuleDir = Join-Path $JavaRoot $Module
  12. $JarPath = Join-Path $ModuleDir "target/$Module.jar"
  13. $Image = "ccr.ccs.tencentyun.com/$Namespace/${Module}:$Tag"
  14. Set-Location $JavaRoot
  15. if (-not $SkipMaven) {
  16. Write-Host "Maven packaging $Module ..."
  17. mvn -pl $Module -am clean package -DskipTests -B
  18. if ($LASTEXITCODE -ne 0) { throw "Maven build failed: $Module" }
  19. }
  20. if (-not (Test-Path $JarPath)) {
  21. throw "Jar not found: $JarPath. Run: mvn -pl $Module -am clean package -DskipTests"
  22. }
  23. Write-Host "Building $Image ..."
  24. Set-Location $ModuleDir
  25. docker build -t $Image .
  26. if ($LASTEXITCODE -ne 0) { throw "Docker build failed: $Module" }
  27. Write-Host "Done: $Image"