mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[build scripts] don't disable a plugin in IDE started from build scripts, if the plugin is explicitly added
... via getAdditionalPluginPaths. We had to add kotlin.idea module to compatiblePluginsToIgnore path because it's layout isn't specified (KTIJ-11539), but we need to have it while building provided modules list, otherwise non-bundled plugins which depend on Kotlin plugin won't be built. GitOrigin-RevId: ac64ba9bc3c1036b395057946c30cb2b48c43218
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5383ca921e
commit
d30b768679
+13
-5
@@ -14,13 +14,14 @@ import java.util.zip.ZipFile
|
||||
class ArchiveUtils {
|
||||
static boolean archiveContainsEntry(String archivePath, String entryPath) {
|
||||
File archiveFile = new File(archivePath)
|
||||
if (archiveFile.name.endsWith(".zip")) {
|
||||
String fileName = archiveFile.name
|
||||
if (isZipFile(fileName)) {
|
||||
return new ZipFile(archiveFile).withCloseable {
|
||||
it.getEntry(entryPath) != null
|
||||
}
|
||||
}
|
||||
|
||||
if (archiveFile.name.endsWith(".tar.gz")) {
|
||||
if (fileName.endsWith(".tar.gz")) {
|
||||
return archiveFile.withInputStream {
|
||||
TarInputStream inputStream = new TarInputStream(new GZIPInputStream(it))
|
||||
TarEntry entry
|
||||
@@ -37,17 +38,20 @@ class ArchiveUtils {
|
||||
}
|
||||
|
||||
static @Nullable String loadEntry(Path archiveFile, String entryPath) {
|
||||
if (archiveFile.fileName.toString().endsWith(".zip")) {
|
||||
String fileName = archiveFile.fileName.toString()
|
||||
if (isZipFile(fileName)) {
|
||||
ZipFile zipFile = new ZipFile(archiveFile.toFile())
|
||||
try {
|
||||
InputStream inputStream = zipFile.getInputStream(zipFile.getEntry(entryPath))
|
||||
def zipEntry = zipFile.getEntry(entryPath)
|
||||
if (zipEntry == null) return null
|
||||
InputStream inputStream = zipFile.getInputStream(zipEntry)
|
||||
return inputStream == null ? null : new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)
|
||||
}
|
||||
finally {
|
||||
zipFile.close()
|
||||
}
|
||||
}
|
||||
else if (archiveFile.fileName.toString().endsWith(".tar.gz")) {
|
||||
else if (fileName.endsWith(".tar.gz")) {
|
||||
TarInputStream inputStream = new TarInputStream(new GZIPInputStream(Files.newInputStream(archiveFile)))
|
||||
try {
|
||||
TarEntry entry
|
||||
@@ -64,4 +68,8 @@ class ArchiveUtils {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private static boolean isZipFile(String fileName) {
|
||||
fileName.endsWith(".zip") || fileName.endsWith(".jar")
|
||||
}
|
||||
}
|
||||
|
||||
+20
-3
@@ -9,6 +9,7 @@ import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.text.Formats
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.util.text.Strings
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.system.CpuArch
|
||||
import groovy.io.FileType
|
||||
import groovy.transform.CompileStatic
|
||||
@@ -223,6 +224,14 @@ final class BuildTasksImpl extends BuildTasks {
|
||||
}
|
||||
}
|
||||
|
||||
//todo remove this when KTIJ-11539 is fixed; currently if we add kotlin.idea module to the classpath as a transitive dependency of some other module,
|
||||
// it'll cause conflicts with Kotlin plugin loaded from JAR
|
||||
String pathToIgnore = new File(context.projectOutputDirectory, "production/kotlin.idea").absolutePath
|
||||
if (ideClasspath.remove(pathToIgnore)) {
|
||||
context.messages.debug(" remove $pathToIgnore from classpath to avoid conflicts")
|
||||
}
|
||||
|
||||
|
||||
List<String> jvmArgs = new ArrayList<>(BuildUtils.propertiesToJvmArgs(new HashMap<String, Object>([
|
||||
"idea.home.path" : context.paths.projectHome,
|
||||
"idea.system.path" : "${FileUtilRt.toSystemIndependentName(tempDir.toString())}/system",
|
||||
@@ -236,16 +245,18 @@ final class BuildTasksImpl extends BuildTasks {
|
||||
jvmArgs.addAll(vmOptions)
|
||||
|
||||
List<Path> additionalPluginPaths = context.productProperties.getAdditionalPluginPaths(context)
|
||||
Set<String> additionalPluginIds = new HashSet<>()
|
||||
for (Path pluginPath : additionalPluginPaths) {
|
||||
for (File jarFile : BuildUtils.getPluginJars(pluginPath.toString())) {
|
||||
if (ideClasspath.add(jarFile.absolutePath)) {
|
||||
context.messages.debug("$jarFile from plugin $pluginPath")
|
||||
ContainerUtil.addIfNotNull(additionalPluginIds, BuildUtils.readPluginId(jarFile))
|
||||
}
|
||||
}
|
||||
}
|
||||
ideClasspath = classpathCustomizer.customize(ideClasspath)
|
||||
|
||||
disableCompatibleIgnoredPlugins(context, tempDir.resolve("config"))
|
||||
disableCompatibleIgnoredPlugins(context, tempDir.resolve("config"), additionalPluginIds)
|
||||
|
||||
BuildHelper.runJava(
|
||||
context,
|
||||
@@ -256,11 +267,17 @@ final class BuildTasksImpl extends BuildTasks {
|
||||
timeoutMillis)
|
||||
}
|
||||
|
||||
private static void disableCompatibleIgnoredPlugins(@NotNull BuildContext context, @NotNull Path configDir) {
|
||||
private static void disableCompatibleIgnoredPlugins(@NotNull BuildContext context,
|
||||
@NotNull Path configDir,
|
||||
@NotNull Set<String> explicitlyEnabledPlugins) {
|
||||
Set<String> toDisable = new HashSet<>()
|
||||
for (String moduleName : context.productProperties.productLayout.compatiblePluginsToIgnore) {
|
||||
Path pluginXml = context.findFileInModuleSources(moduleName, "META-INF/plugin.xml")
|
||||
toDisable.add(JDOMUtil.load(pluginXml).getChildTextTrim("id"))
|
||||
def pluginId = JDOMUtil.load(pluginXml).getChildTextTrim("id")
|
||||
if (!explicitlyEnabledPlugins.contains(pluginId)) {
|
||||
toDisable.add(pluginId)
|
||||
context.messages.debug("runApplicationStarter: '$pluginId' will be disabled, because it's mentioned in 'compatiblePluginsToIgnore'")
|
||||
}
|
||||
}
|
||||
if (!toDisable.isEmpty()) {
|
||||
Files.createDirectories(configDir)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.intellij.build.impl
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtilRt
|
||||
import groovy.transform.CompileDynamic
|
||||
@@ -10,7 +11,9 @@ import org.apache.tools.ant.BuildException
|
||||
import org.apache.tools.ant.Main
|
||||
import org.apache.tools.ant.Project
|
||||
import org.apache.tools.ant.util.SplitClassLoader
|
||||
import org.jdom.JDOMException
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.intellij.build.BuildContext
|
||||
import org.jetbrains.intellij.build.BuildOptions
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||
@@ -186,4 +189,17 @@ final class BuildUtils {
|
||||
new File(libFile, jarName)
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static String readPluginId(File pluginJar) {
|
||||
if (!pluginJar.isFile() || !FileUtil.extensionEquals(pluginJar.name, "jar")) return null
|
||||
String pluginXmlText = ArchiveUtils.loadEntry(pluginJar.toPath(), "META-INF/plugin.xml")
|
||||
if (pluginXmlText == null) return null
|
||||
try {
|
||||
return JDOMUtil.load(pluginXmlText).getChildTextTrim("id")
|
||||
}
|
||||
catch (JDOMException ignored) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user