1
1
import de.undercouch.gradle.tasks.download.Download
2
2
import org.jetbrains.intellij.tasks.PrepareSandboxTask
3
3
import java.security.MessageDigest
4
+ import java.util.zip.ZipFile
4
5
import kotlin.io.path.deleteExisting
5
6
6
7
plugins {
@@ -107,6 +108,8 @@ tasks {
107
108
val psScriptAnalyzerOutFile = downloads.file(psScriptAnalyzerFileName)
108
109
109
110
val downloadPsScriptAnalyzer by register<Download >(" downloadPsScriptAnalyzer" ) {
111
+ group = " dependencies"
112
+
110
113
inputs.property(" version" , psScriptAnalyzerVersion)
111
114
inputs.property(" hash" , psScriptAnalyzerSha256Hash)
112
115
@@ -132,7 +135,9 @@ tasks {
132
135
}
133
136
}
134
137
135
- val getPsScriptAnalyzer by register<Copy >(" getPsScriptAnalyzer" ) {
138
+ val getPsScriptAnalyzer by registering(Copy ::class ) {
139
+ group = " dependencies"
140
+
136
141
val outDir = projectDir.resolve(" language_host/current/LanguageHost/modules/PSScriptAnalyzer" )
137
142
doFirst {
138
143
if (! outDir.deleteRecursively()) error(" Cannot delete \" $outDir \" ." )
@@ -155,6 +160,30 @@ tasks {
155
160
}
156
161
}
157
162
163
+ val maxUnpackedPluginBytes: String by project
164
+ val verifyDistributionSize by registering {
165
+ group = " verification"
166
+ dependsOn(buildPlugin)
167
+
168
+ doLast {
169
+ val artifact = buildPlugin.flatMap { it.archiveFile }.get().asFile
170
+ val unpackedSize = ZipFile (artifact).use { it.entries().asSequence().sumOf { e -> e.size } }
171
+ val unpackedSizeMiB = " %.3f" .format(unpackedSize / 1024.0 / 1024.0 )
172
+ if (unpackedSize > maxUnpackedPluginBytes.toLong()) {
173
+ error(
174
+ " The resulting artifact size is too large. Expected no more than $maxUnpackedPluginBytes , but got" +
175
+ " $unpackedSize bytes ($unpackedSizeMiB MiB).\n Artifact path: \" $artifact \" ."
176
+ )
177
+ }
178
+
179
+ println (" Verified unpacked distribution size: $unpackedSizeMiB MiB." )
180
+ }
181
+ }
182
+
183
+ check {
184
+ dependsOn(verifyDistributionSize)
185
+ }
186
+
158
187
runIde {
159
188
jvmArgs(" -Dide.plugins.snapshot.on.unload.fail=true" , " -XX:+UnlockDiagnosticVMOptions" )
160
189
autoReloadPlugins.set(true )
0 commit comments