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;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class KotlinPluginUtil {
|
public class KotlinPluginUtil {
|
||||||
|
|
||||||
public static final PluginId KOTLIN_PLUGIN_ID;
|
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 {
|
static {
|
||||||
PluginId pluginId = PluginManagerCore.getPluginByClassName(KotlinPluginUtil.class.getName());
|
PluginId pluginId = PluginManagerCore.getPluginByClassName(KotlinPluginUtil.class.getName());
|
||||||
if (pluginId == null) {
|
if (pluginId == null) {
|
||||||
pluginId = PluginId.getId("org.jetbrains.kotlin");
|
pluginId = PluginId.getId("org.jetbrains.kotlin");
|
||||||
}
|
}
|
||||||
KOTLIN_PLUGIN_ID = pluginId;
|
KOTLIN_PLUGIN_ID = pluginId;
|
||||||
|
|
||||||
|
PATCHED_PLUGIN_VERSION = System.getProperty(PATCHED_PLUGIN_VERSION_KEY, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String getPluginVersion() {
|
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);
|
IdeaPluginDescriptor plugin = PluginManager.getPlugin(KOTLIN_PLUGIN_ID);
|
||||||
assert plugin != null : "Kotlin plugin not found: " + Arrays.toString(PluginManagerCore.getPlugins());
|
assert plugin != null : "Kotlin plugin not found: " + Arrays.toString(PluginManagerCore.getPlugins());
|
||||||
return plugin.getVersion();
|
return plugin.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPatched() {
|
||||||
|
return PATCHED_PLUGIN_VERSION != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSnapshotVersion() {
|
public static boolean isSnapshotVersion() {
|
||||||
return "@snapshot@".equals(getPluginVersion());
|
return "@snapshot@".equals(getPluginVersion());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos
|
|||||||
|
|
||||||
private fun updateCheck(callback: (PluginUpdateStatus) -> Boolean) {
|
private fun updateCheck(callback: (PluginUpdateStatus) -> Boolean) {
|
||||||
var updateStatus: PluginUpdateStatus
|
var updateStatus: PluginUpdateStatus
|
||||||
if (KotlinPluginUtil.isSnapshotVersion()) {
|
if (KotlinPluginUtil.isSnapshotVersion() || KotlinPluginUtil.isPatched()) {
|
||||||
updateStatus = PluginUpdateStatus.LatestVersionInstalled
|
updateStatus = PluginUpdateStatus.LatestVersionInstalled
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+10
-1
@@ -29,7 +29,16 @@ public class ConfigurePluginUpdatesForm {
|
|||||||
|
|
||||||
public ConfigurePluginUpdatesForm() {
|
public ConfigurePluginUpdatesForm() {
|
||||||
showVerifierDisabledStatus();
|
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()) {
|
if (ApplicationManager.getApplication().isInternal()) {
|
||||||
String buildNumber = VersioningKt.getBuildNumber();
|
String buildNumber = VersioningKt.getBuildNumber();
|
||||||
|
|||||||
@@ -16,9 +16,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.reporter
|
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.application.ApplicationManager
|
||||||
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
|
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
|
||||||
import com.intellij.openapi.diagnostic.SubmittedReportInfo
|
import com.intellij.openapi.diagnostic.SubmittedReportInfo
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.Messages
|
import com.intellij.openapi.ui.Messages
|
||||||
import com.intellij.util.Consumer
|
import com.intellij.util.Consumer
|
||||||
import org.jetbrains.kotlin.idea.KotlinPluginUpdater
|
import org.jetbrains.kotlin.idea.KotlinPluginUpdater
|
||||||
@@ -56,6 +61,19 @@ class KotlinReportSubmitter : ITNReporterCompat() {
|
|||||||
return super.submitCompat(events, additionalInfo, parentComponent, consumer)
|
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 ->
|
KotlinPluginUpdater.getInstance().runUpdateCheck { status ->
|
||||||
if (status is PluginUpdateStatus.Update) {
|
if (status is PluginUpdateStatus.Update) {
|
||||||
hasUpdate = true
|
hasUpdate = true
|
||||||
@@ -82,6 +100,7 @@ class KotlinReportSubmitter : ITNReporterCompat() {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user