mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-223808 IJ-MR-181153 jps was effectively dead several years ago, and we weren’t able to fix it. On-demand compilation was already unusable at the time it was implemented. Now that we have a proper solution — Bazel — we can remove it.
GitOrigin-RevId: e248cc04e8745dd5367cf27473b9147b10a10337
This commit is contained in:
committed by
intellij-monorepo-bot
parent
27f232c922
commit
2cf9c863d7
@@ -32,7 +32,6 @@
|
||||
<automaticRenamerFactory implementation="org.jetbrains.idea.devkit.refactoring.InspectionAutomaticRenamerFactory"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.idea.devkit.requestHandlers.HttpDebugListener"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.idea.devkit.requestHandlers.BuildHttpRequestHandler"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.idea.devkit.requestHandlers.CompileHttpRequestHandler"/>
|
||||
|
||||
<junitPatcher implementation="org.jetbrains.idea.devkit.run.JUnitDevKitPatcher"/>
|
||||
<runConfigurationExtension implementation="org.jetbrains.idea.devkit.run.DevKitApplicationPatcher"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceGetOrSet")
|
||||
|
||||
package org.jetbrains.idea.devkit.requestHandlers
|
||||
@@ -33,7 +33,6 @@ import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.decodeFromStream
|
||||
import org.jetbrains.ide.HttpRequestHandler
|
||||
@@ -47,11 +46,10 @@ private val LOG = logger<BuildHttpRequestHandler>()
|
||||
/**
|
||||
* Starts JPS build for targets passed in the content in JSON format (array of [BuildScopeDescription] objects).
|
||||
*
|
||||
* Currently, it's enabled for 'intellij' project only, and can be used to build additional required modules when a developer runs a test or
|
||||
* Currently, it's enabled for 'intellij' project only and can be used to build additional required modules when a developer runs a test or
|
||||
* an application from the IDE.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
private class BuildHttpRequestHandler : HttpRequestHandler() {
|
||||
internal class BuildHttpRequestHandler : HttpRequestHandler() {
|
||||
override fun isSupported(request: FullHttpRequest): Boolean {
|
||||
return request.method() == HttpMethod.POST && request.uri().startsWith(PREFIX)
|
||||
}
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceGetOrSet")
|
||||
|
||||
package org.jetbrains.idea.devkit.requestHandlers
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.IntelliJProjectUtil
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.task.ProjectTaskManager
|
||||
import com.intellij.util.io.DigestUtil
|
||||
import io.netty.buffer.ByteBufUtil
|
||||
import io.netty.buffer.Unpooled
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.handler.codec.http.*
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.decodeFromByteArray
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import org.jetbrains.ide.HttpRequestHandler
|
||||
import org.jetbrains.io.send
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
private const val PREFIX = "/devkit/make"
|
||||
private val LOG = logger<CompileHttpRequestHandler>()
|
||||
|
||||
@Service
|
||||
internal class CompileHttpRequestHandlerToken {
|
||||
// build of dev-mode make take a while, so, 15 minutes
|
||||
// (run configuration -> IDE make for configuration is started -> external process started to execute)
|
||||
private val tokens = Caffeine.newBuilder().expireAfterAccess(15, TimeUnit.MINUTES).build<String, Boolean>()
|
||||
|
||||
fun acquireToken(): String {
|
||||
var token = tokens.asMap().keys.firstOrNull()
|
||||
if (token == null) {
|
||||
token = DigestUtil.randomToken()
|
||||
tokens.put(token, true)
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
fun hasToken(token: String): Boolean = tokens.getIfPresent(token) == true
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts JPS build for targets passed in the content in JSON format (array of [BuildScopeDescription] objects).
|
||||
*
|
||||
* Currently, it's enabled for 'intellij' project only, and can be used to build additional required modules when a developer runs a test or
|
||||
* an application from the IDE.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
private class CompileHttpRequestHandler : HttpRequestHandler() {
|
||||
override fun isSupported(request: FullHttpRequest): Boolean {
|
||||
return request.method() == HttpMethod.POST && request.uri().startsWith(PREFIX)
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE")
|
||||
override fun process(urlDecoder: QueryStringDecoder, request: FullHttpRequest, context: ChannelHandlerContext): Boolean {
|
||||
val channel = context.channel()
|
||||
|
||||
val query = urlDecoder.parameters()
|
||||
val token = query.get("token")?.firstOrNull()
|
||||
if (token == null || !service<CompileHttpRequestHandlerToken>().hasToken(token)) {
|
||||
HttpResponseStatus.FORBIDDEN.send(channel, request)
|
||||
return true
|
||||
}
|
||||
|
||||
val projectHash = query.get("project-hash")?.firstOrNull()
|
||||
val project = ProjectManager.getInstance().findOpenProjectByHash(projectHash)
|
||||
if (project == null) {
|
||||
LOG.info("Project is not found (query=$query)")
|
||||
HttpResponseStatus.NOT_FOUND.send(channel, request)
|
||||
return true
|
||||
}
|
||||
|
||||
if (!IntelliJProjectUtil.isIntelliJPlatformProject(project)) {
|
||||
LOG.info("Build requests are currently handled for 'intellij' project only, so request won't be processed (query=$query)")
|
||||
HttpResponseStatus.FORBIDDEN.send(channel, request)
|
||||
return true
|
||||
}
|
||||
|
||||
val modules = try {
|
||||
ProtoBuf.decodeFromByteArray<List<String>>(ByteBufUtil.getBytes(request.content()))
|
||||
}
|
||||
catch (e: SerializationException) {
|
||||
LOG.info(e)
|
||||
HttpResponseStatus.BAD_REQUEST.send(channel, request)
|
||||
return true
|
||||
}
|
||||
|
||||
val projectTaskManager = ProjectTaskManager.getInstance(project)
|
||||
val moduleManager = ModuleManager.getInstance(project)
|
||||
val projectTask = projectTaskManager.createModulesBuildTask(
|
||||
/* modules = */ modules.map { moduleManager.findModuleByName(it) }.toTypedArray(),
|
||||
/* isIncrementalBuild = */ true,
|
||||
/* includeDependentModules = */ false,
|
||||
/* includeRuntimeDependencies = */ false,
|
||||
/* includeTests = */ false,
|
||||
)
|
||||
projectTaskManager.run(projectTask)
|
||||
.onSuccess { taskResult ->
|
||||
val content = Unpooled.copiedBuffer("{hasErrors: ${taskResult.hasErrors()}, isAborted: ${taskResult.isAborted}}", Charsets.UTF_8)
|
||||
val response = DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, content)
|
||||
response.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
|
||||
response.send(channel, request)
|
||||
}
|
||||
.onError { error ->
|
||||
HttpResponseStatus.INTERNAL_SERVER_ERROR.send(channel, request, description = "Build cancelled")
|
||||
LOG.warn(error)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.devkit.requestHandlers
|
||||
|
||||
import com.intellij.debugger.impl.attach.JavaAttachDebuggerProvider
|
||||
@@ -16,15 +16,12 @@ import org.jetbrains.ide.HttpRequestHandler
|
||||
import org.jetbrains.io.send
|
||||
import java.nio.charset.Charset
|
||||
|
||||
private val LOG = Logger.getInstance(HttpDebugListener::class.java)
|
||||
|
||||
@NonNls
|
||||
private const val PREFIX = "/debug/attachToTestProcess"
|
||||
|
||||
internal class HttpDebugListener : HttpRequestHandler() {
|
||||
|
||||
companion object {
|
||||
@NonNls
|
||||
private const val PREFIX = "/debug/attachToTestProcess"
|
||||
}
|
||||
|
||||
private val logger = Logger.getInstance(HttpDebugListener::class.java)
|
||||
|
||||
override fun isSupported(request: FullHttpRequest): Boolean {
|
||||
return request.method() == HttpMethod.POST && request.uri().startsWith(PREFIX)
|
||||
}
|
||||
@@ -39,12 +36,12 @@ internal class HttpDebugListener : HttpRequestHandler() {
|
||||
|
||||
val port = contentLines[0]
|
||||
val name = contentLines.getOrNull(1)
|
||||
logger.info("Debugger attach request to a test process by port '$port' as '$name'")
|
||||
LOG.info("Debugger attach request to a test process by port '$port' as '$name'")
|
||||
|
||||
val projectHash = urlDecoder.parameters()["project-hash"]?.firstOrNull()
|
||||
val project = findTargetProject(projectHash)
|
||||
if (project == null) {
|
||||
logger.info("Suitable target project was not found")
|
||||
LOG.info("Suitable target project was not found")
|
||||
HttpResponseStatus.BAD_REQUEST.send(context.channel(), request)
|
||||
return true
|
||||
}
|
||||
@@ -58,11 +55,11 @@ internal class HttpDebugListener : HttpRequestHandler() {
|
||||
|
||||
private fun findTargetProject(projectHash: String?): Project? {
|
||||
if (projectHash != null) {
|
||||
logger.debug("Locating target project by hash '$projectHash'")
|
||||
LOG.debug("Locating target project by hash '$projectHash'")
|
||||
return ProjectManager.getInstance().findOpenProjectByHash(projectHash)
|
||||
}
|
||||
|
||||
logger.debug("project-hash parameter is not specified, locating target project by active test session")
|
||||
LOG.debug("project-hash parameter is not specified, locating target project by active test session")
|
||||
val project = ProjectManager.getInstance().openProjects.firstOrNull { project ->
|
||||
IntelliJProjectUtil.isIntelliJPlatformProject(project) && ExecutionManager.getInstance(project).getRunningProcesses().any {
|
||||
!it.isProcessTerminated
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.devkit.run
|
||||
|
||||
import com.intellij.compiler.options.MakeProjectStepBeforeRun
|
||||
import com.intellij.execution.JavaRunConfigurationBase
|
||||
import com.intellij.execution.RunConfigurationExtension
|
||||
import com.intellij.execution.application.ApplicationConfiguration
|
||||
import com.intellij.execution.configurations.*
|
||||
import com.intellij.execution.scratch.JavaScratchConfiguration
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.module.impl.ModuleManagerEx
|
||||
import com.intellij.openapi.project.IntelliJProjectUtil
|
||||
@@ -24,8 +22,6 @@ import com.intellij.platform.ijent.community.buildConstants.MULTI_ROUTING_FILE_S
|
||||
import com.intellij.util.PlatformUtils
|
||||
import com.intellij.util.lang.UrlClassLoader
|
||||
import com.intellij.util.system.CpuArch
|
||||
import org.jetbrains.ide.BuiltInServerManager
|
||||
import org.jetbrains.idea.devkit.requestHandlers.CompileHttpRequestHandlerToken
|
||||
import org.jetbrains.idea.devkit.requestHandlers.passDataAboutBuiltInServer
|
||||
import java.lang.ClassLoader.getSystemClassLoader
|
||||
import java.net.URLClassLoader
|
||||
@@ -78,15 +74,10 @@ internal class DevKitApplicationPatcher : RunConfigurationExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
val is17 = javaParameters.jdk?.versionString?.contains("17") == true
|
||||
if (!vmParametersAsList.any { it.contains("CICompilerCount") || it.contains("TieredCompilation") }) {
|
||||
vmParameters.addAll("-XX:CICompilerCount=2")
|
||||
if (!is17) {
|
||||
//vmParameters.addAll("-XX:-TieredCompilation")
|
||||
//vmParameters.addAll("-XX:+SegmentedCodeCache")
|
||||
vmParameters.addAll("-XX:+UnlockDiagnosticVMOptions")
|
||||
vmParameters.addAll("-XX:TieredOldPercentage=100000")
|
||||
}
|
||||
vmParameters.addAll("-XX:+UnlockDiagnosticVMOptions")
|
||||
vmParameters.addAll("-XX:TieredOldPercentage=100000")
|
||||
}
|
||||
|
||||
vmParameters.addAll(
|
||||
@@ -104,9 +95,7 @@ internal class DevKitApplicationPatcher : RunConfigurationExtension() {
|
||||
if (vmParametersAsList.none { it.startsWith("-XX:JbrShrinkingGcMaxHeapFreeRatio=") }) {
|
||||
vmParameters.add("-XX:JbrShrinkingGcMaxHeapFreeRatio=40")
|
||||
}
|
||||
if (is17 && vmParametersAsList.none { it.startsWith("-XX:SoftRefLRUPolicyMSPerMB") }) {
|
||||
vmParameters.add("-XX:SoftRefLRUPolicyMSPerMB=50")
|
||||
}
|
||||
vmParameters.add("-XX:SoftRefLRUPolicyMSPerMB=50")
|
||||
if (vmParametersAsList.none { it.startsWith("-XX:ReservedCodeCacheSize") }) {
|
||||
vmParameters.add("-XX:ReservedCodeCacheSize=512m")
|
||||
}
|
||||
@@ -120,7 +109,7 @@ internal class DevKitApplicationPatcher : RunConfigurationExtension() {
|
||||
enableIjentDefaultFsProvider(project, vmParameters)
|
||||
|
||||
if (isDevBuild) {
|
||||
updateParametersForDevBuild(javaParameters, configuration, project)
|
||||
updateParametersForDevBuild(javaParameters, configuration)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,13 +119,8 @@ internal class DevKitApplicationPatcher : RunConfigurationExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateParametersForDevBuild(javaParameters: JavaParameters, configuration: JavaRunConfigurationBase, project: Project) {
|
||||
private fun updateParametersForDevBuild(javaParameters: JavaParameters, configuration: JavaRunConfigurationBase) {
|
||||
val vmParameters = javaParameters.vmParametersList
|
||||
if (configuration.beforeRunTasks.none { it.providerId === MakeProjectStepBeforeRun.ID }) {
|
||||
vmParameters.addProperty("compile.server.port", BuiltInServerManager.getInstance().port.toString())
|
||||
vmParameters.addProperty("compile.server.project", project.locationHash)
|
||||
vmParameters.addProperty("compile.server.token", service<CompileHttpRequestHandlerToken>().acquireToken())
|
||||
}
|
||||
|
||||
var productClassifier = vmParameters.getPropertyValue("idea.platform.prefix")
|
||||
productClassifier = when (productClassifier) {
|
||||
|
||||
Reference in New Issue
Block a user