Update different stdlib/gradle inspection to handle kotlin-stdlib-jre*
This commit is contained in:
+2
-2
@@ -114,11 +114,11 @@ class DifferentStdlibGradleVersionInspection : GradleBaseInspection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun DataNode<*>.getResolvedKotlinStdlibVersionByModuleData(libraryId: String): String? {
|
internal fun DataNode<*>.getResolvedKotlinStdlibVersionByModuleData(libraryId: String): String? {
|
||||||
val libraryNameMarker = "org.jetbrains.kotlin:$libraryId:"
|
val libraryNameMarker = "org.jetbrains.kotlin:$libraryId"
|
||||||
for (sourceSetData in findAll(GradleSourceSetData.KEY).filter { it.data.internalName.endsWith("main") }) {
|
for (sourceSetData in findAll(GradleSourceSetData.KEY).filter { it.data.internalName.endsWith("main") }) {
|
||||||
for (libraryDependencyData in sourceSetData.node.findAll(ProjectKeys.LIBRARY_DEPENDENCY)) {
|
for (libraryDependencyData in sourceSetData.node.findAll(ProjectKeys.LIBRARY_DEPENDENCY)) {
|
||||||
if (libraryDependencyData.data.externalName.startsWith(libraryNameMarker)) {
|
if (libraryDependencyData.data.externalName.startsWith(libraryNameMarker)) {
|
||||||
return libraryDependencyData.data.externalName.substringAfter(libraryNameMarker)
|
return libraryDependencyData.data.externalName.substringAfter(libraryNameMarker).substringAfter(':')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,40 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDifferentStdlibJre7GradleVersion() {
|
||||||
|
val localFile = createProjectSubFile("build.gradle", """
|
||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'http://dl.bintray.com/kotlin/kotlin-eap-1.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0-beta-17")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.0-beta-22"
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
val tool = DifferentStdlibGradleVersionInspection()
|
||||||
|
val problems = getInspectionResult(tool, localFile)
|
||||||
|
|
||||||
|
Assert.assertTrue(problems.size == 1)
|
||||||
|
Assert.assertEquals("Plugin version (1.1.0-beta-17) is not the same as library version (1.1.0-beta-22)", problems.single())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibGradleVersionWithVariables() {
|
fun testDifferentStdlibGradleVersionWithVariables() {
|
||||||
createProjectSubFile("gradle.properties", """
|
createProjectSubFile("gradle.properties", """
|
||||||
|
|||||||
Reference in New Issue
Block a user