Configuration: Support TeamCity repository for dev-versions
This commit is contained in:
+130
@@ -183,6 +183,136 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigureKotlinDevVersion() {
|
||||
createProjectSubFile("settings.gradle", "include ':app'")
|
||||
val file = createProjectSubFile(
|
||||
"app/build.gradle", """
|
||||
group 'testgroup'
|
||||
version '1.0-SNAPSHOT'
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
importProject()
|
||||
|
||||
runInEdtAndWait {
|
||||
runWriteAction {
|
||||
val module = ModuleManager.getInstance(myProject).findModuleByName("app")!!
|
||||
val configurator = findGradleModuleConfigurator()
|
||||
val collector = createConfigureKotlinNotificationCollector(myProject)
|
||||
configurator.configureWithVersion(myProject, listOf(module), "1.2.60-dev-286", collector)
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments()
|
||||
val content = LoadTextUtil.loadText(file).toString()
|
||||
assertEquals(
|
||||
"""
|
||||
group 'testgroup'
|
||||
version '1.0-SNAPSHOT'
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.60-dev-286'
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:1.2.60-dev-286,branch:default:any/artifacts/content/maven/'
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${"$"}kotlin_version"
|
||||
}
|
||||
}
|
||||
apply plugin: 'kotlin'
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:1.2.60-dev-286,branch:default:any/artifacts/content/maven/'
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${"$"}kotlin_version"
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
""".trimIndent(), content
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigureGradleKtsKotlinDevVersion() {
|
||||
createProjectSubFile("settings.gradle", "include ':app'")
|
||||
val file = createProjectSubFile(
|
||||
"app/build.gradle.kts", """
|
||||
group = "testgroup"
|
||||
version = "1.0-SNAPSHOT"
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
importProject()
|
||||
|
||||
runInEdtAndWait {
|
||||
runWriteAction {
|
||||
val module = ModuleManager.getInstance(myProject).findModuleByName("app")!!
|
||||
val configurator = findGradleModuleConfigurator()
|
||||
val collector = createConfigureKotlinNotificationCollector(myProject)
|
||||
configurator.configureWithVersion(myProject, listOf(module), "1.2.60-dev-286", collector)
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments()
|
||||
val content = LoadTextUtil.loadText(file).toString()
|
||||
assertEquals(
|
||||
"""
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
val kotlin_version: String by extra
|
||||
buildscript {
|
||||
var kotlin_version: String by extra
|
||||
kotlin_version = "1.2.60-dev-286"
|
||||
repositories {
|
||||
maven {
|
||||
setUrl("https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:1.2.60-dev-286,branch:default:any/artifacts/content/maven/")
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath(kotlinModule("gradle-plugin", kotlin_version))
|
||||
}
|
||||
}
|
||||
group = "testgroup"
|
||||
version = "1.0-SNAPSHOT"
|
||||
apply {
|
||||
plugin("kotlin")
|
||||
}
|
||||
dependencies {
|
||||
compile(kotlinModule("stdlib-jdk8", kotlin_version))
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
setUrl("https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:1.2.60-dev-286,branch:default:any/artifacts/content/maven/")
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
val compileKotlin: KotlinCompile by tasks
|
||||
compileKotlin.kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
val compileTestKotlin: KotlinCompile by tasks
|
||||
compileTestKotlin.kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
""".trimIndent(), content
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // Enable in Gradle 4.4+
|
||||
fun testConfigureJvmWithBuildGradle() {
|
||||
|
||||
+13
@@ -60,6 +60,14 @@ val EAP_REPOSITORY = RepositoryDescription(
|
||||
"https://bintray.com/kotlin/kotlin-eap/kotlin/",
|
||||
isSnapshot = false)
|
||||
|
||||
fun devRepository(version: String) = RepositoryDescription(
|
||||
"teamcity.kotlin.dev",
|
||||
"Teamcity Repository of Kotlin Development Builds",
|
||||
"https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:$version,branch:default:any/artifacts/content/maven/",
|
||||
null,
|
||||
isSnapshot = false
|
||||
)
|
||||
|
||||
val MAVEN_CENTRAL = "mavenCentral()"
|
||||
|
||||
val JCENTER = "jcenter()"
|
||||
@@ -85,6 +93,7 @@ fun RepositoryDescription.toKotlinRepositorySnippet() = "maven {\n setUrl(\"$
|
||||
fun getRepositoryForVersion(version: String): RepositoryDescription? = when {
|
||||
isSnapshot(version) -> SNAPSHOT_REPOSITORY
|
||||
isEap(version) -> EAP_REPOSITORY
|
||||
isDev(version) -> devRepository(version)
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -271,6 +280,10 @@ fun isEap(version: String): Boolean {
|
||||
return version.contains("rc") || version.contains("eap") || version.contains("-M")
|
||||
}
|
||||
|
||||
fun isDev(version: String): Boolean {
|
||||
return version.contains("dev")
|
||||
}
|
||||
|
||||
private class LibraryKindSearchScope(val module: Module,
|
||||
val baseScope: GlobalSearchScope,
|
||||
val libraryKind: PersistentLibraryKind<*>
|
||||
|
||||
Reference in New Issue
Block a user