Allow to override plugin version with system property
Need this during testing and development.
This commit is contained in:
@@ -14,24 +14,45 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class KotlinPluginUtil {
|
||||
|
||||
public static final PluginId KOTLIN_PLUGIN_ID;
|
||||
|
||||
private static final String PATCHED_PLUGIN_VERSION;
|
||||
private static final String PATCHED_PLUGIN_VERSION_KEY = "kotlin.plugin.version";
|
||||
|
||||
static {
|
||||
PluginId pluginId = PluginManagerCore.getPluginByClassName(KotlinPluginUtil.class.getName());
|
||||
if (pluginId == null) {
|
||||
pluginId = PluginId.getId("org.jetbrains.kotlin");
|
||||
}
|
||||
KOTLIN_PLUGIN_ID = pluginId;
|
||||
|
||||
PATCHED_PLUGIN_VERSION = System.getProperty(PATCHED_PLUGIN_VERSION_KEY, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getPluginVersion() {
|
||||
if (PATCHED_PLUGIN_VERSION != null) {
|
||||
assert isPatched();
|
||||
return PATCHED_PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
//noinspection deprecation
|
||||
return getPluginVersionFromIdea();
|
||||
}
|
||||
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public static String getPluginVersionFromIdea() {
|
||||
IdeaPluginDescriptor plugin = PluginManager.getPlugin(KOTLIN_PLUGIN_ID);
|
||||
assert plugin != null : "Kotlin plugin not found: " + Arrays.toString(PluginManagerCore.getPlugins());
|
||||
return plugin.getVersion();
|
||||
}
|
||||
|
||||
public static boolean isPatched() {
|
||||
return PATCHED_PLUGIN_VERSION != null;
|
||||
}
|
||||
|
||||
public static boolean isSnapshotVersion() {
|
||||
return "@snapshot@".equals(getPluginVersion());
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos
|
||||
|
||||
private fun updateCheck(callback: (PluginUpdateStatus) -> Boolean) {
|
||||
var updateStatus: PluginUpdateStatus
|
||||
if (KotlinPluginUtil.isSnapshotVersion()) {
|
||||
if (KotlinPluginUtil.isSnapshotVersion() || KotlinPluginUtil.isPatched()) {
|
||||
updateStatus = PluginUpdateStatus.LatestVersionInstalled
|
||||
} else {
|
||||
try {
|
||||
|
||||
+10
-1
@@ -29,7 +29,16 @@ public class ConfigurePluginUpdatesForm {
|
||||
|
||||
public ConfigurePluginUpdatesForm() {
|
||||
showVerifierDisabledStatus();
|
||||
currentVersion.setText(KotlinPluginUtil.getPluginVersion());
|
||||
|
||||
String pluginVersion = KotlinPluginUtil.getPluginVersion();
|
||||
|
||||
if (KotlinPluginUtil.isPatched()) {
|
||||
@SuppressWarnings("deprecation")
|
||||
String pluginVersionFromIdea = KotlinPluginUtil.getPluginVersionFromIdea();
|
||||
currentVersion.setText(pluginVersion + " (Patched! Original: " + pluginVersionFromIdea + ")");
|
||||
} else {
|
||||
currentVersion.setText(pluginVersion);
|
||||
}
|
||||
|
||||
if (ApplicationManager.getApplication().isInternal()) {
|
||||
String buildNumber = VersioningKt.getBuildNumber();
|
||||
|
||||
@@ -16,9 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.reporter
|
||||
|
||||
import com.intellij.diagnostic.ReportMessages
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
|
||||
import com.intellij.openapi.diagnostic.SubmittedReportInfo
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.util.Consumer
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUpdater
|
||||
@@ -56,6 +61,19 @@ class KotlinReportSubmitter : ITNReporterCompat() {
|
||||
return super.submitCompat(events, additionalInfo, parentComponent, consumer)
|
||||
}
|
||||
|
||||
val project: Project? = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(parentComponent))
|
||||
if (KotlinPluginUtil.isPatched()) {
|
||||
ReportMessages.GROUP
|
||||
.createNotification(
|
||||
ReportMessages.ERROR_REPORT,
|
||||
"Can't report exception from patched plugin",
|
||||
NotificationType.INFORMATION,
|
||||
null)
|
||||
.setImportant(false)
|
||||
.notify(project)
|
||||
return true
|
||||
}
|
||||
|
||||
KotlinPluginUpdater.getInstance().runUpdateCheck { status ->
|
||||
if (status is PluginUpdateStatus.Update) {
|
||||
hasUpdate = true
|
||||
@@ -82,6 +100,7 @@ class KotlinReportSubmitter : ITNReporterCompat() {
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user