File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
sonar-kotlin-api/src/main/java/org/sonarsource/kotlin/api/frontend Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
43
43
import org.jetbrains.kotlin.resolve.BindingContext
44
44
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
45
45
import java.io.File
46
+ import java.net.URLClassLoader
46
47
47
48
class Environment (
48
49
val classpath : List <String >,
@@ -114,6 +115,9 @@ fun compilerConfiguration(
114
115
numberOfThreads : Int? ,
115
116
): CompilerConfiguration {
116
117
val classpathFiles = classpath.map(::File )
118
+
119
+ println (version(classpathFiles))
120
+
117
121
val versionSettings = LanguageVersionSettingsImpl (
118
122
languageVersion,
119
123
ApiVersion .createByLanguageVersion(languageVersion),
@@ -128,3 +132,8 @@ fun compilerConfiguration(
128
132
}
129
133
}
130
134
135
+ fun version (classpathFiles : List <File >): String {
136
+ val loader = URLClassLoader (classpathFiles.map { it.toURI().toURL() }.toTypedArray())
137
+ val kotlinVersion = loader.loadClass(" kotlin.KotlinVersion" ).getField(" CURRENT" ).get(null )
138
+ return kotlinVersion.javaClass.getMethod(" toString" ).invoke(kotlinVersion).toString()
139
+ }
You can’t perform that action at this time.
0 commit comments