AT-64 Move collecting of Maven and Gradle imports' metrics intellij.tools.ide.metricsCollector

Move Maven to Maven plugin

GitOrigin-RevId: 69fb6a5b73d92543b8a397f5e3b9502d1ee1aaee
This commit is contained in:
Maxim.Kolmakov
2023-01-12 17:40:06 +01:00
committed by intellij-monorepo-bot
parent b33ce5b5e3
commit 15c7be0aa1
10 changed files with 136 additions and 15 deletions

View File

@@ -2112,18 +2112,6 @@
"pluginId": "com.jetbrains.performancePlugin.gradle",
"type": 1
}
}, {
"group": "nodes",
"data": {
"id": "jU",
"name": "intellij.performanceTesting.maven",
"n": "i.performanceTesting.maven",
"package": "com.jetbrains.performancePlugin.maven",
"sourceModule": "intellij.performanceTesting.maven",
"descriptor": "plugins/performanceTesting/maven/resources/META-INF/plugin.xml",
"pluginId": "com.jetbrains.performancePlugin.maven",
"type": 1
}
}, {
"group": "nodes",
"data": {

View File

@@ -163,7 +163,6 @@
"com.jetbrains.performancePlugin.gradle",
"com.jetbrains.performancePlugin.java",
"com.jetbrains.performancePlugin.kotlin",
"com.jetbrains.performancePlugin.maven",
"com.jetbrains.performancePlugin.workspaceModel",
"com.jetbrains.plugins.webDeployment",
"com.jetbrains.projector.libs",

View File

@@ -165,7 +165,6 @@
"com.jetbrains.performancePlugin.gradle",
"com.jetbrains.performancePlugin.java",
"com.jetbrains.performancePlugin.kotlin",
"com.jetbrains.performancePlugin.maven",
"com.jetbrains.performancePlugin.workspaceModel",
"com.jetbrains.plugins.webDeployment",
"com.jetbrains.projector.libs",

View File

@@ -162,7 +162,6 @@
"com.jetbrains.performancePlugin.gradle",
"com.jetbrains.performancePlugin.java",
"com.jetbrains.performancePlugin.kotlin",
"com.jetbrains.performancePlugin.maven",
"com.jetbrains.performancePlugin.workspaceModel",
"com.jetbrains.plugins.webDeployment",
"com.jetbrains.projector.libs",

View File

@@ -78,6 +78,7 @@
<orderEntry type="module" module-name="intellij.platform.buildScripts.downloader" />
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="module" module-name="intellij.performanceTesting" />
</component>
<component name="copyright">
<Base>

View File

@@ -0,0 +1,101 @@
package org.jetbrains.idea.maven.performancePlugin;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTrackerSettings;
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.playback.PlaybackContext;
import com.intellij.openapi.ui.playback.commands.AbstractCommand;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.util.DisposeAwareRunnable;
import com.jetbrains.performancePlugin.utils.ActionCallbackProfilerStopper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.concurrency.AsyncPromise;
import org.jetbrains.concurrency.Promise;
import org.jetbrains.concurrency.Promises;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.project.importing.FilesList;
import org.jetbrains.idea.maven.project.importing.MavenImportingManager;
import org.jetbrains.idea.maven.utils.MavenUtil;
public final class ImportMavenProjectCommand extends AbstractCommand {
public static final String PREFIX = "%importMavenProject";
public ImportMavenProjectCommand(@NotNull String text, int line) {
super(text, line);
}
@NotNull
@Override
protected Promise<Object> _execute(@NotNull PlaybackContext context) {
@NotNull Project project = context.getProject();
if (MavenUtil.isLinearImportEnabled()) {
return runLinearMavenImport(context, project);
}
else {
ActionCallback actionCallback = new ActionCallbackProfilerStopper();
runWhenMavenImportAndIndexingFinished(context, () -> actionCallback.setDone(), project);
return Promises.toPromise(actionCallback);
}
}
private Promise<Object> runLinearMavenImport(PlaybackContext context, Project project) {
ExternalSystemProjectTrackerSettings projectTrackerSettings = ExternalSystemProjectTrackerSettings.getInstance(project);
ExternalSystemProjectTrackerSettings.AutoReloadType currentAutoReloadType = projectTrackerSettings.getAutoReloadType();
projectTrackerSettings.setAutoReloadType(ExternalSystemProjectTrackerSettings.AutoReloadType.NONE);
context.message("Waiting for fully open and initialized maven project", getLine());
context.message("Import of the project has been started", getLine());
AsyncPromise<Object> result = new AsyncPromise<>();
ExternalProjectsManagerImpl.getInstance(project).runWhenInitialized(() -> {
MavenProjectsManager mavenManager = MavenProjectsManager.getInstance(project);
MavenImportingManager.getInstance(project).openProjectAndImport(
new FilesList(mavenManager.collectAllAvailablePomFiles())
).getFinishPromise().onSuccess(t -> {
context.message("Import of the maven project has been finished", getLine());
projectTrackerSettings.setAutoReloadType(currentAutoReloadType);
DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(() -> result.setResult(t), project));
}).onError(t -> result.setError(t));
});
return result;
}
private void runWhenMavenImportAndIndexingFinished(@NotNull PlaybackContext context,
@NotNull Runnable runnable,
@NotNull Project project) {
ExternalSystemProjectTrackerSettings projectTrackerSettings = ExternalSystemProjectTrackerSettings.getInstance(project);
ExternalSystemProjectTrackerSettings.AutoReloadType currentAutoReloadType = projectTrackerSettings.getAutoReloadType();
projectTrackerSettings.setAutoReloadType(ExternalSystemProjectTrackerSettings.AutoReloadType.NONE);
context.message("Waiting for fully open and initialized maven project", getLine());
ExternalProjectsManagerImpl.getInstance(project).runWhenInitialized(() -> MavenUtil.runWhenInitialized(project, () -> {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
waitForCurrentMavenImportActivities(context, project)
.thenAsync(promise -> {
context.message("Import of the project has been started", getLine());
MavenProjectsManager mavenManager = MavenProjectsManager.getInstance(project);
if (!mavenManager.isMavenizedProject()) {
mavenManager.addManagedFiles(mavenManager.collectAllAvailablePomFiles());
}
return mavenManager.forceUpdateProjects();
})
.thenAsync(promise -> waitForCurrentMavenImportActivities(context, project))
.onProcessed(promise -> {
context.message("Import of the maven project has been finished", getLine());
projectTrackerSettings.setAutoReloadType(currentAutoReloadType);
DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(runnable, project));
});
});
}));
}
private Promise<?> waitForCurrentMavenImportActivities(@NotNull PlaybackContext context, @NotNull Project project) {
context.message("Waiting for current maven import activities", getLine());
return MavenProjectsManager.getInstance(project).waitForImportCompletion().onProcessed(o -> {
context.message("Maven import activities completed", getLine());
});
}
}

View File

@@ -0,0 +1,14 @@
package org.jetbrains.idea.maven.performancePlugin;
import com.jetbrains.performancePlugin.CommandProvider;
import com.jetbrains.performancePlugin.CreateCommand;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
final class MavenCommandProvider implements CommandProvider {
@Override
public @NotNull Map<String, CreateCommand> getCommands() {
return Map.of(ImportMavenProjectCommand.PREFIX, ImportMavenProjectCommand::new);
}
}

View File

@@ -0,0 +1,5 @@
<idea-plugin>
<extensions defaultExtensionNs="com.jetbrains">
<performancePlugin.commandProvider implementation="org.jetbrains.idea.maven.performancePlugin.MavenCommandProvider"/>
</extensions>
</idea-plugin>

View File

@@ -63,6 +63,7 @@
<depends>org.jetbrains.idea.maven.server.api</depends>
<depends optional="true" config-file="groovy-support.xml">org.intellij.groovy</depends>
<depends optional="true" config-file="errorProne-compiler-support.xml">Error-prone plugin</depends>
<depends optional="true" config-file="performance-plugin-support.xml">com.jetbrains.performancePlugin</depends>
<extensions defaultExtensionNs="com.intellij">
<pathMacroContributor implementation="org.jetbrains.idea.maven.utils.MavenPathMacroContributor"/>

View File

@@ -0,0 +1,14 @@
<html>
<title>Command imports maven project</title>
<body>
<p>
Simulate invocation of reimport of maven project.
</p>
<p>
Syntax: %importMavenProject
</p>
<p>
Example: %importMavenProject
</p>
</body>
</html>