don't show pre-1.0 versions of Kotlin in "Configure Kotlin in project" action
This commit is contained in:
@@ -51,8 +51,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class KotlinMavenConfigurator implements KotlinProjectConfigurator {
|
public abstract class KotlinMavenConfigurator implements KotlinProjectConfigurator {
|
||||||
private static final String[] KOTLIN_VERSIONS = {KotlinVersion.VERSION};
|
|
||||||
|
|
||||||
public static final String NAME = "maven";
|
public static final String NAME = "maven";
|
||||||
|
|
||||||
private static final String GROUP_ID = "org.jetbrains.kotlin";
|
private static final String GROUP_ID = "org.jetbrains.kotlin";
|
||||||
@@ -112,7 +110,7 @@ public abstract class KotlinMavenConfigurator implements KotlinProjectConfigurat
|
|||||||
@Override
|
@Override
|
||||||
public void configure(@NotNull Project project, Collection<Module> excludeModules) {
|
public void configure(@NotNull Project project, Collection<Module> excludeModules) {
|
||||||
ConfigureDialogWithModulesAndVersion dialog =
|
ConfigureDialogWithModulesAndVersion dialog =
|
||||||
new ConfigureDialogWithModulesAndVersion(project, this, KOTLIN_VERSIONS, excludeModules);
|
new ConfigureDialogWithModulesAndVersion(project, this, excludeModules);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
if (!dialog.isOK()) return;
|
if (!dialog.isOK()) return;
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ import java.io.File;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public abstract class KotlinWithGradleConfigurator implements KotlinProjectConfigurator {
|
public abstract class KotlinWithGradleConfigurator implements KotlinProjectConfigurator {
|
||||||
private static final String[] KOTLIN_VERSIONS = {"0.6.+"};
|
|
||||||
|
|
||||||
protected static final String VERSION_TEMPLATE = "$VERSION$";
|
protected static final String VERSION_TEMPLATE = "$VERSION$";
|
||||||
|
|
||||||
protected static final String CLASSPATH = "classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"";
|
protected static final String CLASSPATH = "classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"";
|
||||||
@@ -85,7 +83,7 @@ public abstract class KotlinWithGradleConfigurator implements KotlinProjectConfi
|
|||||||
@Override
|
@Override
|
||||||
public void configure(@NotNull Project project, Collection<Module> excludeModules) {
|
public void configure(@NotNull Project project, Collection<Module> excludeModules) {
|
||||||
ConfigureDialogWithModulesAndVersion dialog =
|
ConfigureDialogWithModulesAndVersion dialog =
|
||||||
new ConfigureDialogWithModulesAndVersion(project, this, KOTLIN_VERSIONS, excludeModules);
|
new ConfigureDialogWithModulesAndVersion(project, this, excludeModules);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
if (!dialog.isOK()) return;
|
if (!dialog.isOK()) return;
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Choose Kotlin plugin version"/>
|
<text value="Kotlin compiler and runtime version:"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="1034b" class="javax.swing.JComboBox" binding="kotlinVersionComboBox">
|
<component id="1034b" class="javax.swing.JComboBox" binding="kotlinVersionComboBox">
|
||||||
|
|||||||
+10
-8
@@ -29,6 +29,7 @@ import com.intellij.openapi.progress.Task;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.ui.DialogWrapper;
|
import com.intellij.openapi.ui.DialogWrapper;
|
||||||
import com.intellij.util.net.HttpConfigurable;
|
import com.intellij.util.net.HttpConfigurable;
|
||||||
|
import com.intellij.util.text.VersionComparatorUtil;
|
||||||
import com.intellij.util.ui.AsyncProcessIcon;
|
import com.intellij.util.ui.AsyncProcessIcon;
|
||||||
import com.intellij.util.ui.UIUtil;
|
import com.intellij.util.ui.UIUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -41,8 +42,8 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -62,7 +63,6 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
|||||||
public ConfigureDialogWithModulesAndVersion(
|
public ConfigureDialogWithModulesAndVersion(
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull KotlinProjectConfigurator configurator,
|
@NotNull KotlinProjectConfigurator configurator,
|
||||||
@NotNull final String[] kotlinVersions,
|
|
||||||
@NotNull Collection<Module> excludeModules
|
@NotNull Collection<Module> excludeModules
|
||||||
) {
|
) {
|
||||||
super(project);
|
super(project);
|
||||||
@@ -74,7 +74,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
|||||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Find Kotlin Maven plugin versions", false) {
|
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Find Kotlin Maven plugin versions", false) {
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull ProgressIndicator indicator) {
|
public void run(@NotNull ProgressIndicator indicator) {
|
||||||
setVersions(kotlinVersions);
|
loadKotlinVersions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,14 +111,14 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
|||||||
return contentPane;
|
return contentPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVersions(@NotNull String[] kotlinVersions) {
|
private void loadKotlinVersions() {
|
||||||
Collection<String> items;
|
Collection<String> items;
|
||||||
try {
|
try {
|
||||||
items = loadVersions();
|
items = loadVersions();
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable t) {
|
||||||
items = Arrays.asList(kotlinVersions);
|
items = Collections.singletonList("1.0.0");
|
||||||
showWarning();
|
showWarning();
|
||||||
}
|
}
|
||||||
updateVersions(items);
|
updateVersions(items);
|
||||||
@@ -153,11 +153,10 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
|||||||
public void run() {
|
public void run() {
|
||||||
kotlinVersionComboBox.removeAllItems();
|
kotlinVersionComboBox.removeAllItems();
|
||||||
kotlinVersionComboBox.setEnabled(true);
|
kotlinVersionComboBox.setEnabled(true);
|
||||||
kotlinVersionComboBox.addItem("0.1-SNAPSHOT");
|
|
||||||
for (String newItem : newItems) {
|
for (String newItem : newItems) {
|
||||||
kotlinVersionComboBox.addItem(newItem);
|
kotlinVersionComboBox.addItem(newItem);
|
||||||
}
|
}
|
||||||
kotlinVersionComboBox.setSelectedIndex(1);
|
kotlinVersionComboBox.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
}, ModalityState.stateForComponent(kotlinVersionComboBox));
|
}, ModalityState.stateForComponent(kotlinVersionComboBox));
|
||||||
}
|
}
|
||||||
@@ -180,7 +179,10 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
|||||||
JsonArray docsElements = rootElement.getAsJsonObject().get("response").getAsJsonObject().get("docs").getAsJsonArray();
|
JsonArray docsElements = rootElement.getAsJsonObject().get("response").getAsJsonObject().get("docs").getAsJsonArray();
|
||||||
|
|
||||||
for (JsonElement element : docsElements) {
|
for (JsonElement element : docsElements) {
|
||||||
versions.add(element.getAsJsonObject().get("v").getAsString());
|
String versionNumber = element.getAsJsonObject().get("v").getAsString();
|
||||||
|
if (VersionComparatorUtil.compare("1.0.0", versionNumber) <= 0) {
|
||||||
|
versions.add(versionNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user