@@ -20,7 +20,11 @@ import org.gradle.api.Project
20
20
import org.gradle.api.file.Directory
21
21
import org.gradle.api.provider.Provider
22
22
import org.gradle.kotlin.dsl.dependencies
23
+ import org.gradle.kotlin.dsl.support.unzipTo
24
+ import org.gradle.kotlin.dsl.support.zipTo
23
25
import java.io.File
26
+ import java.nio.file.Files
27
+ import java.nio.file.StandardCopyOption
24
28
import java.util.zip.ZipInputStream
25
29
26
30
val Project .mpsMajorVersion: String get() {
@@ -105,6 +109,32 @@ fun Project.copyMps(): File {
105
109
}
106
110
}
107
111
112
+ // Workaround for https://youtrack.jetbrains.com/issue/KT-69541/Kotlin-2.0-compiler-cannot-use-JAR-packaged-as-ZIP64
113
+ //
114
+ // The issue was first detected with `lib/app.jar` in 2022.2 and 2022.3.
115
+ // This JAR is needed since this versions because it contained `com.intellij.openapi.project.ProjectManager`.
116
+ // Before that, `lib/platform-api.jar` contained `com.intellij.openapi.project.ProjectManager`.
117
+ //
118
+ // The workaround is to unzip the JAR with and zip it again.
119
+ // Unzipping with Gradle supports ZIP64, but ZIP64 is not used when zipping again.
120
+ //
121
+ // TODO MODELIX-968 Remove this workaround after it is not needed anymore.
122
+ val appJarFile = mpsHomeDir.get().asFile.resolve(" lib/app.jar" )
123
+ if (appJarFile.exists()) {
124
+ val appJarContent = mpsHomeDir.get().asFile.resolve(" lib/appJarContent" )
125
+ val appJarFileNotZip64 = mpsHomeDir.get().asFile.resolve(" lib/appNotZip64.jar" )
126
+ println (" Unzipping $appJarFile into $appJarContent " )
127
+ unzipTo(appJarContent, appJarFile)
128
+ println (" Zipping $appJarContent into $appJarFileNotZip64 " )
129
+ zipTo(appJarFileNotZip64, appJarContent)
130
+ println (" Deleting $appJarContent " )
131
+ delete {
132
+ this .delete(appJarContent)
133
+ }
134
+ println (" Overriding $appJarFile with $appJarFileNotZip64 " )
135
+ Files .move(appJarFileNotZip64.toPath(), appJarFile.toPath(), StandardCopyOption .REPLACE_EXISTING )
136
+ }
137
+
108
138
// The build number of a local IDE is expected to contain a product code, otherwise an exception is thrown.
109
139
val buildTxt = mpsHomeDir.get().asFile.resolve(" build.txt" )
110
140
val buildNumber = buildTxt.readText()
0 commit comments