Last active
October 16, 2019 02:59
-
-
Save mavaddat/ef23fda9ddfe7bf12e460a8cf25340f2 to your computer and use it in GitHub Desktop.
Preliminary version of a PowerShell script to get the .jar dependencies for a java build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Dependencies { | |
[CmdletBinding()] | |
param ( | |
[Alias("CP", "ClassPath")] | |
[Parameter(Mandatory = $false)] | |
[string] ${Class-Path} = "F:\lwjgl-release-3.2.3-custom\", | |
[Alias("File", "JavaFile", "Target")] | |
[Parameter(Mandatory = $true)] | |
${Target-JavaFile} | |
) | |
begin { | |
$r = New-Object -TypeName System.Collections.ArrayList | |
} | |
process { | |
if ((Test-Path -Path ${Target-JavaFile}) -and (Test-Path -Path ${Class-Path})) { | |
$r.Add("$(Join-Path -Path $(Split-Path -Path ${Target-JavaFile}) -ChildPath '')*") > $null | |
$(Get-Content ${Target-JavaFile} | Where-Object -FilterScript { $_ -match "import" }) -creplace '^[\S\s]*?(\S+?)(?:\.[A-Z]\w+\.\*)?(?:\.\*)?;$', '$1' -replace '(?:^java.*$|org\.)', '' -replace '\.', '-' | Select-Object -Unique | ForEach-Object { | |
if ($_.Length -ne 0) { | |
$i = $(Get-ChildItem -Path ${Class-Path} -Name "$_.jar") -replace '^', "${Class-Path}" -join ';' | |
if ($i.Length -eq 0) { | |
$i = $(Get-ChildItem -Path ${Class-Path} -Filter "$_*.jar") -replace '^', "${Class-Path}" -join ';' | |
if ($i.Length -ne 0) { | |
$r.Add($i) > $null | |
} | |
} | |
else { | |
$r.Add($i) > $null | |
} | |
} | |
} | |
return $($r -join ';') | |
} | |
else { | |
return $false; | |
} | |
} | |
end { | |
Remove-Variable "r" | |
} | |
} | |
function Get-JavaParams { | |
[CmdletBinding()] | |
param ( | |
[Alias("CP", "ClassPath")] | |
[Parameter(Mandatory = $false)] | |
[string] ${Class-Path} = "F:\lwjgl-release-3.2.3-custom\", | |
[Alias("File", "JavaFile", "Target")] | |
[Parameter(Mandatory = $true)] | |
${Target-JavaFile} | |
) | |
begin { | |
} | |
process { | |
} | |
end { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment