Use correct repository for checking if current EAP version is published
Logic for determining the Maven repository corresponding to the current plugin version has been centralized and reused in the version chooser in "Configure Kotlin" dialog. #KT-17291 Fixed
This commit is contained in:
@@ -35,13 +35,14 @@ import org.jetbrains.kotlin.idea.versions.hasKotlinJsKjsmFile
|
||||
import org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinder
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
data class RepositoryDescription(val id: String, val name: String, val url: String, val isSnapshot: Boolean)
|
||||
data class RepositoryDescription(val id: String, val name: String, val url: String, val bintrayUrl: String?, val isSnapshot: Boolean)
|
||||
|
||||
@JvmField
|
||||
val SNAPSHOT_REPOSITORY = RepositoryDescription(
|
||||
"sonatype.oss.snapshots",
|
||||
"Sonatype OSS Snapshot Repository",
|
||||
"http://oss.sonatype.org/content/repositories/snapshots",
|
||||
null,
|
||||
isSnapshot = true)
|
||||
|
||||
@JvmField
|
||||
@@ -49,6 +50,7 @@ val EAP_REPOSITORY = RepositoryDescription(
|
||||
"bintray.kotlin.eap",
|
||||
"Bintray Kotlin EAP Repository",
|
||||
"http://dl.bintray.com/kotlin/kotlin-eap",
|
||||
"https://bintray.com/kotlin/kotlin-eap/kotlin/",
|
||||
isSnapshot = false)
|
||||
|
||||
@JvmField
|
||||
@@ -56,8 +58,18 @@ val EAP_11_REPOSITORY = RepositoryDescription(
|
||||
"bintray.kotlin.eap",
|
||||
"Bintray Kotlin 1.1 EAP Repository",
|
||||
"http://dl.bintray.com/kotlin/kotlin-eap-1.1",
|
||||
"https://bintray.com/kotlin/kotlin-eap-1.1/kotlin/",
|
||||
isSnapshot = false)
|
||||
|
||||
fun RepositoryDescription.toRepositorySnippet() = "maven {\nurl '$url'\n}"
|
||||
|
||||
fun getRepositoryForVersion(version: String): RepositoryDescription? = when {
|
||||
isSnapshot(version) -> SNAPSHOT_REPOSITORY
|
||||
useEap11Repository(version) -> EAP_11_REPOSITORY
|
||||
isEap(version) -> EAP_REPOSITORY
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun isModuleConfigured(module: Module): Boolean {
|
||||
return allConfigurators().any {
|
||||
it.getStatus(module) == ConfigureKotlinStatus.CONFIGURED
|
||||
|
||||
+4
-16
@@ -43,25 +43,13 @@ abstract class GradleKotlinFrameworkSupportProvider(val frameworkTypeId: String,
|
||||
modifiableModelsProvider: ModifiableModelsProvider,
|
||||
buildScriptData: BuildScriptDataBuilder) {
|
||||
var kotlinVersion = bundledRuntimeVersion()
|
||||
|
||||
val additionalRepository: String? = when {
|
||||
kotlinVersion == "@snapshot@" -> {
|
||||
kotlinVersion = "1.1-SNAPSHOT"
|
||||
KotlinWithGradleConfigurator.SNAPSHOT_REPOSITORY_SNIPPET
|
||||
}
|
||||
useEap11Repository(kotlinVersion) -> {
|
||||
KotlinWithGradleConfigurator.EAP_11_REPOSITORY_SNIPPET
|
||||
}
|
||||
isEap(kotlinVersion) -> {
|
||||
KotlinWithGradleConfigurator.EAP_REPOSITORY_SNIPPET
|
||||
}
|
||||
else -> {
|
||||
null
|
||||
}
|
||||
val additionalRepository = getRepositoryForVersion(kotlinVersion)
|
||||
if (isSnapshot(bundledRuntimeVersion())) {
|
||||
kotlinVersion = "1.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
if (additionalRepository != null) {
|
||||
val oneLineRepository = additionalRepository.replace('\n', ' ')
|
||||
val oneLineRepository = additionalRepository.toRepositorySnippet().replace('\n', ' ')
|
||||
buildScriptData.addBuildscriptRepositoriesDefinition(oneLineRepository)
|
||||
|
||||
buildScriptData.addRepositoriesDefinition("mavenCentral()")
|
||||
|
||||
@@ -218,10 +218,6 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
|
||||
val CLASSPATH = "classpath \"$GROUP_ID:$GRADLE_PLUGIN_ID:\$kotlin_version\""
|
||||
|
||||
val SNAPSHOT_REPOSITORY_SNIPPET = "maven {\nurl '" + SNAPSHOT_REPOSITORY.url + "'\n}"
|
||||
val EAP_REPOSITORY_SNIPPET = "maven {\nurl '" + EAP_REPOSITORY.url + "'\n}"
|
||||
val EAP_11_REPOSITORY_SNIPPET = "maven {\nurl '" + EAP_11_REPOSITORY.url + "'\n}"
|
||||
|
||||
private val MAVEN_CENTRAL = "mavenCentral()\n"
|
||||
private val JCENTER = "jcenter()\n"
|
||||
|
||||
@@ -515,10 +511,9 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
}
|
||||
|
||||
private fun addRepository(repositoriesBlock: GrClosableBlock, version: String): Boolean {
|
||||
val repository = getRepositoryForVersion(version)
|
||||
val snippet = when {
|
||||
isSnapshot(version) -> SNAPSHOT_REPOSITORY_SNIPPET
|
||||
useEap11Repository(version) -> EAP_11_REPOSITORY_SNIPPET
|
||||
isEap(version) -> EAP_REPOSITORY_SNIPPET
|
||||
repository != null -> repository.toRepositorySnippet()
|
||||
!isRepositoryConfigured(repositoriesBlock) -> MAVEN_CENTRAL
|
||||
else -> return false
|
||||
}
|
||||
|
||||
+4
-4
@@ -38,6 +38,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil;
|
||||
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt;
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator;
|
||||
import org.jetbrains.kotlin.idea.configuration.RepositoryDescription;
|
||||
import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtilKt;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -55,8 +56,6 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
private static final String VERSIONS_LIST_URL =
|
||||
"http://search.maven.org/solrsearch/select?q=g:%22org.jetbrains.kotlin%22+AND+a:%22kotlin-runtime%22&core=gav&rows=20&wt=json";
|
||||
|
||||
private static final String EAP_VERSIONS_URL =
|
||||
"https://bintray.com/kotlin/kotlin-eap/kotlin/";
|
||||
@NotNull private final String minimumVersion;
|
||||
|
||||
private final ChooseModulePanel chooseModulePanel;
|
||||
@@ -176,8 +175,9 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
List<String> versions = Lists.newArrayList();
|
||||
|
||||
String bundledRuntimeVersion = KotlinRuntimeLibraryUtilKt.bundledRuntimeVersion();
|
||||
if (ConfigureKotlinInProjectUtilsKt.isEap(bundledRuntimeVersion)) {
|
||||
HttpURLConnection eapConnection = HttpConfigurable.getInstance().openHttpConnection(EAP_VERSIONS_URL + bundledRuntimeVersion);
|
||||
RepositoryDescription repositoryDescription = ConfigureKotlinInProjectUtilsKt.getRepositoryForVersion(bundledRuntimeVersion);
|
||||
if (repositoryDescription != null && repositoryDescription.getBintrayUrl() != null) {
|
||||
HttpURLConnection eapConnection = HttpConfigurable.getInstance().openHttpConnection(repositoryDescription.getBintrayUrl() + bundledRuntimeVersion);
|
||||
try {
|
||||
int timeout = (int) TimeUnit.SECONDS.toMillis(30);
|
||||
eapConnection.setConnectTimeout(timeout);
|
||||
|
||||
Reference in New Issue
Block a user