You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
3.1 KiB
74 lines
3.1 KiB
# 将 Libs 目录下的所有 *.jar 安装到本地 Maven 仓库
|
|
# groupId: org.dromara, version: 5.6.0
|
|
# 安装顺序:根POM → 纯POM父模块 → JAR(确保 parent 链完整)
|
|
# 若同目录存在同名 .pom 文件,则使用真实 POM(传递依赖完整);否则自动生成空 POM。
|
|
|
|
$libsDir = $PSScriptRoot
|
|
$groupId = "org.dromara"
|
|
$version = "5.6.0"
|
|
|
|
# ====== 第一步:安装根 POM(提供 dependencyManagement) ======
|
|
Write-Host "`n=== Step 1: Installing root POM (EnforcementCode) ===" -ForegroundColor Magenta
|
|
$rootPomPath = (Resolve-Path (Join-Path $libsDir "..\pom.xml")).Path
|
|
if (Test-Path $rootPomPath) {
|
|
mvn install:install-file `
|
|
"-Dfile=$rootPomPath" `
|
|
"-DgroupId=$groupId" `
|
|
"-DartifactId=EnforcementCode" `
|
|
"-Dversion=$version" `
|
|
"-Dpackaging=pom"
|
|
if ($LASTEXITCODE -eq 0) { Write-Host " -> OK" -ForegroundColor Green }
|
|
else { Write-Host " -> FAILED" -ForegroundColor Red }
|
|
} else {
|
|
Write-Host " -> Root pom.xml not found at $rootPomPath, skipping" -ForegroundColor Yellow
|
|
}
|
|
|
|
# ====== 第二步:安装纯 POM 父模块(只有 .pom 没有对应 .jar 的文件) ======
|
|
Write-Host "`n=== Step 2: Installing parent POMs (no matching JAR) ===" -ForegroundColor Magenta
|
|
Get-ChildItem -Path $libsDir -Filter "*.pom" | Where-Object {
|
|
$jarName = $_.BaseName + ".jar"
|
|
-not (Test-Path (Join-Path $libsDir $jarName))
|
|
} | ForEach-Object {
|
|
$pomFile = $_.FullName
|
|
$artifactId = $_.BaseName -replace "-$version$", ""
|
|
Write-Host "Installing POM: $artifactId" -ForegroundColor Cyan
|
|
mvn install:install-file `
|
|
"-Dfile=$pomFile" `
|
|
"-DgroupId=$groupId" `
|
|
"-DartifactId=$artifactId" `
|
|
"-Dversion=$version" `
|
|
"-Dpackaging=pom"
|
|
if ($LASTEXITCODE -eq 0) { Write-Host " -> OK" -ForegroundColor Green }
|
|
else { Write-Host " -> FAILED" -ForegroundColor Red }
|
|
}
|
|
|
|
# ====== 第三步:安装 JAR(使用真实 POM 或生成空 POM) ======
|
|
Write-Host "`n=== Step 3: Installing JARs ===" -ForegroundColor Magenta
|
|
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
|
|
|