Detect version 1.1.0-beta as 1.1 prerelease

This commit is contained in:
Dmitry Jemerov
2017-01-25 18:48:24 +01:00
parent 56bbb8ec78
commit 85a74f4cca
5 changed files with 16 additions and 13 deletions
@@ -133,7 +133,7 @@ abstract class KotlinMavenConfigurator
pom.addLibraryRepository(SNAPSHOT_REPOSITORY) pom.addLibraryRepository(SNAPSHOT_REPOSITORY)
pom.addPluginRepository(SNAPSHOT_REPOSITORY) pom.addPluginRepository(SNAPSHOT_REPOSITORY)
} }
else if (is11Prerelease(version)) { else if (useEap11Repository(version)) {
pom.addLibraryRepository(EAP_11_REPOSITORY) pom.addLibraryRepository(EAP_11_REPOSITORY)
pom.addPluginRepository(EAP_11_REPOSITORY) pom.addPluginRepository(EAP_11_REPOSITORY)
} }
@@ -166,6 +166,6 @@ fun isEap(version: String): Boolean {
return version.contains("rc") || version.contains("eap") return version.contains("rc") || version.contains("eap")
} }
fun is11Prerelease(version: String): Boolean { fun useEap11Repository(version: String): Boolean {
return Regex("1\\.1-[A-Za-z][A-Za-z0-9-]*").matches(version) && !version.startsWith("1.1-dev") return Regex("1\\.1(\\.\\d)?-[A-Za-z][A-Za-z0-9-]*").matches(version) && !version.startsWith("1.1.0-dev")
} }
@@ -47,7 +47,7 @@ class GradleKotlinJavaFrameworkSupportProvider : GradleFrameworkSupportProvider(
kotlinVersion = "1.1-SNAPSHOT" kotlinVersion = "1.1-SNAPSHOT"
KotlinWithGradleConfigurator.SNAPSHOT_REPOSITORY_SNIPPET KotlinWithGradleConfigurator.SNAPSHOT_REPOSITORY_SNIPPET
} }
is11Prerelease(kotlinVersion) -> { useEap11Repository(kotlinVersion) -> {
KotlinWithGradleConfigurator.EAP_11_REPOSITORY_SNIPPET KotlinWithGradleConfigurator.EAP_11_REPOSITORY_SNIPPET
} }
isEap(kotlinVersion) -> { isEap(kotlinVersion) -> {
@@ -399,7 +399,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
private fun addRepository(repositoriesBlock: GrClosableBlock, version: String): Boolean { private fun addRepository(repositoriesBlock: GrClosableBlock, version: String): Boolean {
val snippet = when { val snippet = when {
isSnapshot(version) -> SNAPSHOT_REPOSITORY_SNIPPET isSnapshot(version) -> SNAPSHOT_REPOSITORY_SNIPPET
is11Prerelease(version) -> EAP_11_REPOSITORY_SNIPPET useEap11Repository(version) -> EAP_11_REPOSITORY_SNIPPET
isEap(version) -> EAP_REPOSITORY_SNIPPET isEap(version) -> EAP_REPOSITORY_SNIPPET
!isRepositoryConfigured(repositoriesBlock) -> MAVEN_CENTRAL !isRepositoryConfigured(repositoriesBlock) -> MAVEN_CENTRAL
else -> return false else -> return false
@@ -21,13 +21,16 @@ import org.junit.Assert
class ConfigureKotlinUtilTest : UsefulTestCase() { class ConfigureKotlinUtilTest : UsefulTestCase() {
fun test11Prerelease() { fun test11Prerelease() {
Assert.assertTrue(is11Prerelease("1.1-M04")) Assert.assertTrue(useEap11Repository("1.1-M04"))
Assert.assertTrue(is11Prerelease("1.1-beta")) Assert.assertTrue(useEap11Repository("1.1-beta"))
Assert.assertTrue(is11Prerelease("1.1-beta-2")) Assert.assertTrue(useEap11Repository("1.1.0-beta"))
Assert.assertTrue(is11Prerelease("1.1-rc2")) Assert.assertTrue(useEap11Repository("1.1-beta-2"))
Assert.assertFalse(is11Prerelease("1.1")) Assert.assertTrue(useEap11Repository("1.1-rc2"))
Assert.assertFalse(is11Prerelease("1.1.2")) Assert.assertTrue(useEap11Repository("1.1.0-RC"))
Assert.assertFalse(is11Prerelease("1.1.2-3")) Assert.assertTrue(useEap11Repository("1.1.1-eap-22"))
Assert.assertFalse(is11Prerelease("1.1-dev-1234")) Assert.assertFalse(useEap11Repository("1.1"))
Assert.assertFalse(useEap11Repository("1.1.2"))
Assert.assertFalse(useEap11Repository("1.1.2-3"))
Assert.assertFalse(useEap11Repository("1.1-dev-1234"))
} }
} }