mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[maven] IDEA-370480 optimize managed dependency storage
GitOrigin-RevId: 5106e3da140ed8fad109b3a282af3638d95bcfe6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a5be4cd680
commit
a4b716ef03
+2
-2
@@ -22,8 +22,8 @@ import org.jdom.Element
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.idea.maven.importing.MavenAnnotationProcessorConfiguratorUtil.getProcessorArtifactInfos
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.annotationProcessorOptions
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.declaredAnnotationProcessors
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.compilerConfigsForCompilePhase
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.declaredAnnotationProcessors
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.getAnnotationProcessorDirectory
|
||||
import org.jetbrains.idea.maven.importing.MavenImportUtil.procMode
|
||||
import org.jetbrains.idea.maven.importing.MavenWorkspaceConfigurator.*
|
||||
@@ -405,7 +405,7 @@ object MavenAnnotationProcessorConfiguratorUtil {
|
||||
val pluginVersion = project.findPlugin(PLUGIN_GROUP_ID, PLUGIN_ARTIFACT_ID)?.version ?: return null
|
||||
|
||||
if (VersionComparatorUtil.compare(pluginVersion, "3.12.0") >= 0 && groupId != null && artifactId != null) {
|
||||
return project.findManagedDependency(groupId, artifactId)?.version
|
||||
return project.findManagedDependencyVersion(groupId, artifactId)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -54,15 +54,21 @@ class MavenProject(val file: VirtualFile) {
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun write(out: DataOutputStream) {
|
||||
out.writeUTF(path)
|
||||
try {
|
||||
out.writeUTF(path)
|
||||
|
||||
BufferExposingByteArrayOutputStream().use { bs ->
|
||||
ObjectOutputStream(bs).use { os ->
|
||||
os.writeObject(myState)
|
||||
out.writeInt(bs.size())
|
||||
out.write(bs.internalBuffer, 0, bs.size())
|
||||
BufferExposingByteArrayOutputStream().use { bs ->
|
||||
ObjectOutputStream(bs).use { os ->
|
||||
os.writeObject(myState)
|
||||
out.writeInt(bs.size())
|
||||
out.write(bs.internalBuffer, 0, bs.size())
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: IOException) {
|
||||
MavenLog.LOG.error("Unable to write project " + file.path, e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@Internal
|
||||
@@ -587,7 +593,7 @@ class MavenProject(val file: VirtualFile) {
|
||||
setState(newState)
|
||||
}
|
||||
|
||||
fun findManagedDependency(groupId: String, artifactId: String): MavenId? = myState.managedDependencies["$groupId:$artifactId"]
|
||||
fun findManagedDependencyVersion(groupId: String, artifactId: String): String? = myState.managedDependencies[GroupAndArtifact(groupId, artifactId)]
|
||||
|
||||
fun findDependencies(depProject: MavenProject): List<MavenArtifact> {
|
||||
return findDependencies(depProject.mavenId)
|
||||
@@ -856,7 +862,7 @@ class MavenProject(val file: VirtualFile) {
|
||||
val newPluginInfos = LinkedHashSet<MavenPluginWithArtifact>()
|
||||
val newExtensions = LinkedHashSet<MavenArtifact>()
|
||||
val newAnnotationProcessors = LinkedHashSet<MavenArtifact>()
|
||||
val newManagedDeps = LinkedHashMap<String, MavenId>()
|
||||
val newManagedDeps = HashMap<GroupAndArtifact, String>(managedDependencies.size)
|
||||
|
||||
if (keepPreviousArtifacts) {
|
||||
newUnresolvedArtifacts.addAll(state.unresolvedArtifactIds)
|
||||
@@ -886,7 +892,10 @@ class MavenProject(val file: VirtualFile) {
|
||||
newDependencyTree.addAll(model.dependencyTree)
|
||||
newDependencies.addAll(model.dependencies)
|
||||
newExtensions.addAll(model.extensions)
|
||||
managedDependencies.forEach { md -> newManagedDeps.put("${md.groupId}:${md.artifactId}", md) }
|
||||
|
||||
for (md in managedDependencies) {
|
||||
newManagedDeps.put(GroupAndArtifact(md.groupId ?: "", md.artifactId ?: ""), md.version ?: "")
|
||||
}
|
||||
|
||||
val remoteRepositories = ArrayList(newRepositories)
|
||||
val remotePluginRepositories = ArrayList(newPluginRepositories)
|
||||
|
||||
@@ -11,6 +11,9 @@ import java.util.*
|
||||
@ApiStatus.Experimental
|
||||
data class MavenPluginWithArtifact(val plugin: MavenPlugin, val artifact: MavenArtifact?) : Serializable
|
||||
|
||||
@ApiStatus.Experimental
|
||||
data class GroupAndArtifact(val groupId: String, val artifactId: String) : Serializable
|
||||
|
||||
@ApiStatus.Internal
|
||||
data class MavenProjectState(
|
||||
val lastReadStamp: Long = 0,
|
||||
@@ -35,7 +38,7 @@ data class MavenProjectState(
|
||||
val remoteRepositories: List<MavenRemoteRepository> = emptyList(),
|
||||
val remotePluginRepositories: List<MavenRemoteRepository> = emptyList(),
|
||||
val annotationProcessors: List<MavenArtifact> = emptyList(),
|
||||
val managedDependencies: Map<String, MavenId> = emptyMap(),
|
||||
val managedDependencies: Map<GroupAndArtifact, String> = emptyMap(),
|
||||
val modulesPathsAndNames: Map<String, String> = emptyMap(),
|
||||
val modelMap: Map<String, String> = emptyMap(),
|
||||
val profilesIds: Collection<String> = emptySet(),
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.idea.maven.dom.references.MavenFilteredPropertyPsiReferenceProvider
|
||||
import org.jetbrains.idea.maven.model.*
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsTreeUpdater.UpdateSpec
|
||||
import org.jetbrains.idea.maven.server.NativeMavenProjectHolder
|
||||
import org.jetbrains.idea.maven.telemetry.tracer
|
||||
import org.jetbrains.idea.maven.utils.*
|
||||
import java.io.*
|
||||
@@ -951,7 +952,7 @@ class MavenProjectsTree(val project: Project) {
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("use projectResolved(Pair<MavenProject, MavenProjectChanges>)")
|
||||
fun projectResolved(projectWithChanges: Pair<MavenProject, MavenProjectChanges>,
|
||||
nativeMavenProject: org.jetbrains.idea.maven.server.NativeMavenProjectHolder?) {
|
||||
nativeMavenProject: NativeMavenProjectHolder?) {
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -1093,8 +1094,8 @@ class MavenProjectsTree(val project: Project) {
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(MavenProjectsTree::class.java)
|
||||
|
||||
private const val STORAGE_VERSION_NUMBER = 13
|
||||
val STORAGE_VERSION = MavenProjectsTree::class.java.simpleName + "." + STORAGE_VERSION_NUMBER
|
||||
private const val STORAGE_VERSION_NUMBER = 14
|
||||
val STORAGE_VERSION: String = MavenProjectsTree::class.java.simpleName + "." + STORAGE_VERSION_NUMBER
|
||||
|
||||
private fun String.getStorageVersionNumber(): Int {
|
||||
val parts = this.split(".")
|
||||
|
||||
+4
-4
@@ -937,7 +937,7 @@ class MavenProjectTest : MavenMultiVersionImportingTestCase() {
|
||||
|
||||
importProjectAsync()
|
||||
|
||||
assertEquals("4.0", projectsTree.findProject(p)!!.findManagedDependency("junit", "junit")!!.version)
|
||||
assertEquals("4.0", projectsTree.findProject(p)!!.findManagedDependencyVersion("junit", "junit")!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -973,7 +973,7 @@ class MavenProjectTest : MavenMultiVersionImportingTestCase() {
|
||||
|
||||
importProjectAsync()
|
||||
|
||||
assertEquals("4.0", projectsTree.findProject(m1)!!.findManagedDependency("junit", "junit")!!.version)
|
||||
assertEquals("4.0", projectsTree.findProject(m1)!!.findManagedDependencyVersion("junit", "junit")!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1018,8 +1018,8 @@ class MavenProjectTest : MavenMultiVersionImportingTestCase() {
|
||||
|
||||
importProjectAsync()
|
||||
|
||||
assertEquals("4.0", projectsTree.findProject(m1)!!.findManagedDependency("junit", "junit")!!.version)
|
||||
assertEquals("1.0", projectsTree.findProject(m1)!!.findManagedDependency("another", "dep")!!.version)
|
||||
assertEquals("4.0", projectsTree.findProject(m1)!!.findManagedDependencyVersion("junit", "junit")!!)
|
||||
assertEquals("1.0", projectsTree.findProject(m1)!!.findManagedDependencyVersion("another", "dep")!!)
|
||||
}
|
||||
|
||||
protected fun assertDependenciesNodes(nodes: List<MavenArtifactNode?>?, expected: String?) {
|
||||
|
||||
+2
-2
@@ -17,12 +17,12 @@ import kotlin.reflect.full.findAnnotation
|
||||
class MavenProjectTreeVersionNumberTest : UsefulTestCase() {
|
||||
|
||||
fun `test do not forget updating STORAGE_VERSION_NUMBER when structure changed`() {
|
||||
val hash = Hashing.komihash5_0().hashStream();
|
||||
val hash = Hashing.komihash5_0().hashStream()
|
||||
val recursionKeeper = HashSet<String>()
|
||||
hashKType(MavenProjectState::class.createType(), recursionKeeper, hash)
|
||||
|
||||
hash.putString(MavenProjectsTree.STORAGE_VERSION)
|
||||
assertEquals("UPDATE STORAGE VERSION ALONG WITH THIS HASH!!!", 8386196208490699208, hash.asLong)
|
||||
assertEquals("UPDATE STORAGE VERSION ALONG WITH THIS HASH!!!", 5736572056086370157, hash.asLong)
|
||||
}
|
||||
|
||||
private fun hashKType(type: KType, recursionKeeper: MutableSet<String>, hash: HashSink) {
|
||||
|
||||
Reference in New Issue
Block a user