Change core env and proguard config for compatibility with new gradle build

(the build.xml should be modified to support the proguard config in this form)
This commit is contained in:
Ilya Chernikov
2017-08-02 12:19:19 +02:00
parent 6b22282ad4
commit f053ed968f
2 changed files with 28 additions and 20 deletions
@@ -109,6 +109,7 @@ import org.jetbrains.kotlin.script.ScriptDependenciesProvider
import org.jetbrains.kotlin.script.ScriptReportSink
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import java.util.zip.ZipFile
class KotlinCoreEnvironment private constructor(
parentDisposable: Disposable,
@@ -482,20 +483,25 @@ class KotlinCoreEnvironment private constructor(
}
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
var pluginRoot =
fun File.hasConfigFile(configFile: String): Boolean =
if (isDirectory) File(this, "META-INF" + File.separator + configFile).exists()
else try {
ZipFile(this).use {
it.getEntry("META-INF/" + configFile) != null
}
}
catch (e: Throwable) {
false
}
val pluginRoot =
configuration.get(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT)?.let(::File)
?: configuration.get(CLIConfigurationKeys.COMPILER_JAR_LOCATOR)?.compilerJar
?: PathUtil.pathUtilJar
val app = ApplicationManager.getApplication()
val parentFile = pluginRoot.parentFile
if (pluginRoot.isDirectory && app != null && app.isUnitTestMode
&& FileUtil.toCanonicalPath(parentFile.path).endsWith("out/production")) {
// hack for load extensions when compiler run directly from out directory(e.g. in tests)
val srcDir = parentFile.parentFile.parentFile
pluginRoot = File(srcDir, "idea/src")
}
?: PathUtil.getPathUtilJar().takeIf { it.hasConfigFile(configFilePath) }
// hack for load extensions when compiler run directly from project directory (e.g. in tests)
?: File("idea/src").takeIf { it.hasConfigFile(configFilePath) }
?: throw IllegalStateException("Unable to find extension point configuration $configFilePath")
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, configFilePath, Extensions.getRootArea())
}
+10 -8
View File
@@ -1,4 +1,4 @@
-injars '<output>/kotlin-compiler-before-shrink.jar'(
-injars '<kotlin-compiler-jar-before-shrink>'(
!com/thoughtworks/xstream/converters/extended/ISO8601**,
!com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter**,
!com/thoughtworks/xstream/io/xml/JDom**,
@@ -23,7 +23,7 @@
META-INF/services/**,META-INF/native/**,META-INF/extensions/**,META-INF/MANIFEST.MF,
messages/**)
-outjars '<kotlin-home>/lib/kotlin-compiler.jar'
-outjars '<kotlin-compiler-jar>'
-dontnote **
-dontwarn com.intellij.util.ui.IsRetina*
@@ -58,13 +58,15 @@ messages/**)
-dontwarn java.lang.invoke.MethodHandle
-dontwarn org.jline.builtins.Nano$Buffer
-dontwarn net.jpountz.lz4.LZ4Factory
-dontwarn org.jetbrains.annotations.ReadOnly
-dontwarn org.jetbrains.annotations.Mutable
-libraryjars '<rtjar>'
-libraryjars '<jssejar>'
-libraryjars '<bootstrap.runtime>'
-libraryjars '<bootstrap.reflect>'
-libraryjars '<bootstrap.script.runtime>'
-libraryjars '<tools.jar>'
#-libraryjars '<rtjar>'
#-libraryjars '<jssejar>'
#-libraryjars '<bootstrap.runtime>'
#-libraryjars '<bootstrap.reflect>'
#-libraryjars '<bootstrap.script.runtime>'
#-libraryjars '<tools.jar>'
-dontoptimize
-dontobfuscate