@@ -2,7 +2,6 @@ import org.gradle.api.DefaultTask
22import org.gradle.api.file.ConfigurableFileCollection
33import org.gradle.api.file.RegularFileProperty
44import org.gradle.api.provider.ListProperty
5- import org.gradle.api.provider.Property
65import org.gradle.api.tasks.Input
76import org.gradle.api.tasks.InputFile
87import org.gradle.api.tasks.InputFiles
@@ -14,9 +13,6 @@ abstract class ValidateToolboxPluginZipTask : DefaultTask() {
1413 @get:InputFile
1514 abstract val pluginFile: RegularFileProperty
1615
17- @get:Input
18- abstract val extensionId: Property <String >
19-
2016 @get:InputFiles
2117 abstract val expectedLibraries: ConfigurableFileCollection
2218
@@ -25,42 +21,36 @@ abstract class ValidateToolboxPluginZipTask : DefaultTask() {
2521
2622 @TaskAction
2723 fun validate () {
28- val pluginDirectory = " ${extensionId.get()} /"
2924 val expectedResources = setOf (" dependencies.json" , " icon.svg" , " pluginIcon.svg" )
3025
3126 ZipFile (pluginFile.get().asFile).use { zip ->
3227 val entries = zip.entries().asSequence().filterNot { it.isDirectory }.map { it.name }.toSet()
3328 val missingEntries = buildSet {
3429 if (" extension.json" !in entries) add(" extension.json" )
35- expectedResources
36- .map { " $pluginDirectory$it " }
37- .filterNot(entries::contains)
38- .forEach(::add)
30+ expectedResources.filterNot(entries::contains).forEach(::add)
3931 expectedLibraries.files
40- .map { " $pluginDirectory " + " lib/ ${ it.name} " }
32+ .map { it.name }
4133 .filterNot(entries::contains)
4234 .forEach(::add)
4335 }
4436 check(missingEntries.isEmpty()) {
4537 " Plugin ZIP is missing required entries: ${missingEntries.sorted().joinToString()} "
4638 }
4739
48- val rootEntries = entries.filterNot { ' /' in it }.toSet()
49- check(rootEntries == setOf (" extension.json" )) {
50- " Plugin ZIP must contain only extension.json at its root; found: ${rootEntries.sorted().joinToString()} "
51- }
52-
53- val misplacedLibraries = entries.filter { it.endsWith(" .jar" ) && ! it.startsWith(" ${pluginDirectory} lib/" ) }
54- check(misplacedLibraries.isEmpty()) {
55- " Plugin ZIP libraries must be under ${pluginDirectory} lib: ${misplacedLibraries.sorted().joinToString()} "
40+ val nestedEntries = entries.filter { ' /' in it }
41+ check(nestedEntries.isEmpty()) {
42+ " Plugin ZIP must use the flat Toolbox plugin layout; found nested entries: ${
43+ nestedEntries.sorted().joinToString()
44+ } "
5645 }
5746
5847 val bundledToolboxDependencies = entries.filter { entry ->
59- entry.startsWith(" ${pluginDirectory} lib/" ) &&
60- toolboxProvidedDependencyNames.get().any(entry::contains)
48+ entry.endsWith(" .jar" ) && toolboxProvidedDependencyNames.get().any(entry::contains)
6149 }
6250 check(bundledToolboxDependencies.isEmpty()) {
63- " Plugin ZIP must not bundle Toolbox-provided dependencies: ${bundledToolboxDependencies.sorted().joinToString()} "
51+ " Plugin ZIP must not bundle Toolbox-provided dependencies: ${
52+ bundledToolboxDependencies.sorted().joinToString()
53+ } "
6454 }
6555 }
6656 }
0 commit comments