Skip to content

Commit 6c20e19

Browse files
committed
Build: download PSScriptAnalyzer using Gradle dependency API
1 parent 581dd9c commit 6c20e19

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

build.gradle.kts

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,32 @@ version = "2.6.1"
3939

4040
repositories {
4141
mavenCentral()
42+
ivy {
43+
url = uri("https://github.com/PowerShell/PSScriptAnalyzer/releases/download/")
44+
patternLayout {
45+
artifact("[revision]/[module].[revision].[ext]")
46+
}
47+
content {
48+
includeGroup("PSScriptAnalyzer")
49+
}
50+
metadataSources {
51+
artifact()
52+
}
53+
}
4254
}
4355

56+
val psScriptAnalyzer: Configuration by configurations.creating
57+
4458
dependencies {
4559
implementation(libs.bundles.junixsocket)
4660

4761
implementation(libs.lsp4j)
4862
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
4963
testImplementation(libs.junit)
64+
65+
libs.psScriptAnalyzer.get().apply {
66+
psScriptAnalyzer(group = this.group!!, name = this.name, version = this.version, ext = "nupkg")
67+
}
5068
}
5169

5270
configurations {
@@ -158,29 +176,21 @@ tasks {
158176

159177
val downloads = layout.buildDirectory.get().dir("download")
160178

161-
val psScriptAnalyzerVersion: String by project
162-
val psScriptAnalyzerSha256Hash: String by project
163-
val psScriptAnalyzerFileName = "PSScriptAnalyzer.$psScriptAnalyzerVersion.nupkg"
164-
val psScriptAnalyzerOutFile = downloads.file(psScriptAnalyzerFileName)
165-
166179
val psesVersion: String by project
167180
val psesSha256Hash: String by project
168181

169-
val getPsScriptAnalyzer = getDependencyTask(
170-
"PSScriptAnalyzer",
171-
psScriptAnalyzerVersion,
172-
psScriptAnalyzerSha256Hash,
173-
URI(
174-
"https://github.com/PowerShell/PSScriptAnalyzer/releases/download/" +
175-
"$psScriptAnalyzerVersion/$psScriptAnalyzerFileName"
176-
),
177-
psScriptAnalyzerOutFile
178-
) {
179-
// NuGet stuff:
180-
exclude("_manifest/**", "_rels/**", "package/**", "[Content_Types].xml", "*.nuspec")
182+
fun PrepareSandboxTask.unpackPsScriptAnalyzer(outDir: String) {
183+
dependsOn(psScriptAnalyzer)
184+
185+
from(zipTree(psScriptAnalyzer.singleFile)) {
186+
into("$outDir/PSScriptAnalyzer")
181187

182-
// Compatibility profiles, see https://github.com/PowerShell/PSScriptAnalyzer/issues/1148
183-
exclude("compatibility_profiles/**")
188+
// NuGet stuff:
189+
exclude("_manifest/**", "_rels/**", "package/**", "[Content_Types].xml", "*.nuspec")
190+
191+
// Compatibility profiles, see https://github.com/PowerShell/PSScriptAnalyzer/issues/1148
192+
exclude("compatibility_profiles/**")
193+
}
184194
}
185195

186196
val getPowerShellEditorServices = getDependencyTask(
@@ -200,11 +210,14 @@ tasks {
200210
}
201211

202212
val getAllDependencies by registering {
203-
dependsOn(getPsScriptAnalyzer, getPowerShellEditorServices)
213+
dependsOn(getPowerShellEditorServices)
204214
}
205215

206216
withType<PrepareSandboxTask> {
207217
dependsOn(getAllDependencies)
218+
val outDir = "${intellij.pluginName.get()}/lib/LanguageHost/modules"
219+
unpackPsScriptAnalyzer(outDir)
220+
208221
from("${project.rootDir}/language_host") {
209222
into("${intellij.pluginName.get()}/lib/")
210223
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kotlin.stdlib.default.dependency=false
33
# 30 MiB:
44
maxUnpackedPluginBytes=31457280
55

6-
psScriptAnalyzerVersion=1.22.0
6+
# TODO: Move to Gradle verification file
77
psScriptAnalyzerSha256Hash=71BFB9EB58E19D4B662F4494A7D572A724B60E0588848DCFF34195A0E08AE1BE
88

99
psesVersion=3.20.1

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common
77
junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" }
88
lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1"
99
junit = "junit:junit:4.13.2"
10+
psScriptAnalyzer = { group = "PSScriptAnalyzer", name = "PSScriptAnalyzer", version = "1.22.0" }
1011

1112
[bundles]
1213
junixsocket = ["junixsocket-common", "junixsocket-native-common"]

0 commit comments

Comments
 (0)