Add 1.1 EAP repository when creating a new Gradle project with 1.1 EAP
#KT-15293 Fixed
This commit is contained in:
+5
-1
@@ -133,7 +133,11 @@ abstract class KotlinMavenConfigurator
|
||||
pom.addLibraryRepository(SNAPSHOT_REPOSITORY)
|
||||
pom.addPluginRepository(SNAPSHOT_REPOSITORY)
|
||||
}
|
||||
if (isEap(version)) {
|
||||
else if (is11Prerelease(version)) {
|
||||
pom.addLibraryRepository(EAP_11_REPOSITORY)
|
||||
pom.addPluginRepository(EAP_11_REPOSITORY)
|
||||
}
|
||||
else if (isEap(version)) {
|
||||
pom.addLibraryRepository(EAP_REPOSITORY)
|
||||
pom.addPluginRepository(EAP_REPOSITORY)
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ val EAP_REPOSITORY = RepositoryDescription(
|
||||
"http://dl.bintray.com/kotlin/kotlin-eap",
|
||||
isSnapshot = false)
|
||||
|
||||
@JvmField
|
||||
val EAP_11_REPOSITORY = RepositoryDescription(
|
||||
"bintray.kotlin.eap",
|
||||
"Bintray Kotlin 1.1 EAP Repository",
|
||||
"http://dl.bintray.com/kotlin/kotlin-eap-1.1",
|
||||
isSnapshot = false)
|
||||
|
||||
fun isModuleConfigured(module: Module): Boolean {
|
||||
return Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME).any {
|
||||
it.getStatus(module) == ConfigureKotlinStatus.CONFIGURED
|
||||
@@ -151,3 +158,6 @@ fun isEap(version: String): Boolean {
|
||||
return version.contains("rc") || version.contains("eap")
|
||||
}
|
||||
|
||||
fun is11Prerelease(version: String): Boolean {
|
||||
return Regex("1\\.1-[A-Za-z][A-Za-z0-9-]*").matches(version) && !version.startsWith("1.1-dev")
|
||||
}
|
||||
|
||||
+3
@@ -47,6 +47,9 @@ class GradleKotlinJavaFrameworkSupportProvider : GradleFrameworkSupportProvider(
|
||||
kotlinVersion = "1.1-SNAPSHOT"
|
||||
KotlinWithGradleConfigurator.SNAPSHOT_REPOSITORY_SNIPPET
|
||||
}
|
||||
is11Prerelease(kotlinVersion) -> {
|
||||
KotlinWithGradleConfigurator.EAP_11_REPOSITORY_SNIPPET
|
||||
}
|
||||
isEap(kotlinVersion) -> {
|
||||
KotlinWithGradleConfigurator.EAP_REPOSITORY_SNIPPET
|
||||
}
|
||||
|
||||
@@ -137,15 +137,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
}
|
||||
|
||||
val repositoriesBlock = getRepositoriesBlock(file)
|
||||
if (isSnapshot(version)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(SNAPSHOT_REPOSITORY_SNIPPET, repositoriesBlock)
|
||||
}
|
||||
else if (isEap(version)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(EAP_REPOSITORY_SNIPPET, repositoriesBlock)
|
||||
}
|
||||
else if (!isRepositoryConfigured(repositoriesBlock)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(MAVEN_CENTRAL, repositoriesBlock)
|
||||
}
|
||||
wasModified = wasModified or addRepository(repositoriesBlock, version)
|
||||
|
||||
val dependenciesBlock = getDependenciesBlock(file)
|
||||
wasModified = wasModified or addExpressionInBlockIfNeeded(LIBRARY, dependenciesBlock, false)
|
||||
@@ -195,6 +187,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
|
||||
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"
|
||||
@@ -279,15 +272,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
wasModified = addFirstExpressionInBlockIfNeeded(VERSION.replace(VERSION_TEMPLATE, version), buildScriptBlock)
|
||||
|
||||
val buildScriptRepositoriesBlock = getBuildScriptRepositoriesBlock(file)
|
||||
if (isSnapshot(version)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(SNAPSHOT_REPOSITORY_SNIPPET, buildScriptRepositoriesBlock)
|
||||
}
|
||||
else if (isEap(version)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(EAP_REPOSITORY_SNIPPET, buildScriptRepositoriesBlock)
|
||||
}
|
||||
else if (!isRepositoryConfigured(buildScriptRepositoriesBlock)) {
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(MAVEN_CENTRAL, buildScriptRepositoriesBlock)
|
||||
}
|
||||
wasModified = wasModified or addRepository(buildScriptRepositoriesBlock, version)
|
||||
|
||||
val buildScriptDependenciesBlock = getBuildScriptDependenciesBlock(file)
|
||||
wasModified = wasModified or addLastExpressionInBlockIfNeeded(CLASSPATH, buildScriptDependenciesBlock)
|
||||
@@ -410,5 +395,16 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
"<br/>See manual installation instructions <a href=\"https://kotlinlang.org/docs/reference/using-gradle.html\">here</a>.</html>",
|
||||
"Configure Kotlin-Gradle Plugin")
|
||||
}
|
||||
|
||||
private fun addRepository(repositoriesBlock: GrClosableBlock, version: String): Boolean {
|
||||
val snippet = when {
|
||||
isSnapshot(version) -> SNAPSHOT_REPOSITORY_SNIPPET
|
||||
is11Prerelease(version) -> EAP_11_REPOSITORY_SNIPPET
|
||||
isEap(version) -> EAP_REPOSITORY_SNIPPET
|
||||
!isRepositoryConfigured(repositoriesBlock) -> MAVEN_CENTRAL
|
||||
else -> return false
|
||||
}
|
||||
return addLastExpressionInBlockIfNeeded(snippet, repositoriesBlock)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
sourceCompatibility = 1.5
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'http://dl.bintray.com/kotlin/kotlin-eap-1.1'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
buildscript {
|
||||
ext.kotlin_version = '$VERSION$'
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://dl.bintray.com/kotlin/kotlin-eap-1.1'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
// VERSION: $VERSION$
|
||||
@@ -0,0 +1,14 @@
|
||||
apply plugin: 'java'
|
||||
|
||||
sourceCompatibility = 1.5
|
||||
version = '1.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||
}
|
||||
|
||||
// VERSION: 1.1-M04
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.junit.Assert
|
||||
|
||||
class ConfigureKotlinUtilTest : UsefulTestCase() {
|
||||
fun test11Prerelease() {
|
||||
Assert.assertTrue(is11Prerelease("1.1-M04"))
|
||||
Assert.assertTrue(is11Prerelease("1.1-beta"))
|
||||
Assert.assertTrue(is11Prerelease("1.1-beta-2"))
|
||||
Assert.assertTrue(is11Prerelease("1.1-rc2"))
|
||||
Assert.assertFalse(is11Prerelease("1.1"))
|
||||
Assert.assertFalse(is11Prerelease("1.1.2"))
|
||||
Assert.assertFalse(is11Prerelease("1.1.2-3"))
|
||||
Assert.assertFalse(is11Prerelease("1.1-dev-1234"))
|
||||
}
|
||||
}
|
||||
+6
@@ -48,6 +48,12 @@ public class GradleConfigureProjectByChangingFileTestGenerated extends AbstractG
|
||||
doTestGradle(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("m04Version_before.gradle")
|
||||
public void testM04Version() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/m04Version_before.gradle");
|
||||
doTestGradle(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("missedLibrary_before.gradle")
|
||||
public void testMissedLibrary() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/missedLibrary_before.gradle");
|
||||
|
||||
Reference in New Issue
Block a user