# 将 Libs 目录下的所有 *.jar 安装到本地 Maven 仓库 # groupId: org.dromara, version: 5.6.0 # 若同目录存在同名 .pom 文件,则使用真实 POM(传递依赖完整);否则自动生成空 POM。 $libsDir = $PSScriptRoot $groupId = "org.dromara" $version = "5.6.0" Get-ChildItem -Path $libsDir -Filter "*.jar" | ForEach-Object { $jarFile = $_.FullName # 从文件名中提取 artifactId,例如 zdxt-common-core-5.6.0.jar -> zdxt-common-core $artifactId = $_.BaseName -replace "-$version$", "" $pomFile = Join-Path $libsDir "$artifactId-$version.pom" if (Test-Path $pomFile) { Write-Host "Installing: $artifactId (with real POM)" -ForegroundColor Cyan mvn install:install-file ` "-Dfile=$jarFile" ` "-DpomFile=$pomFile" ` "-Dpackaging=jar" } else { Write-Host "Installing: $artifactId (generated POM, no transitive deps)" -ForegroundColor Yellow mvn install:install-file ` "-Dfile=$jarFile" ` "-DgroupId=$groupId" ` "-DartifactId=$artifactId" ` "-Dversion=$version" ` "-Dpackaging=jar" ` "-DgeneratePom=true" } if ($LASTEXITCODE -eq 0) { Write-Host " -> OK" -ForegroundColor Green } else { Write-Host " -> FAILED" -ForegroundColor Red } } Write-Host "`nAll done." -ForegroundColor Yellow