[Test] Reformat MockLibraryUtil according to code style

This commit is contained in:
Dmitriy Novozhilov
2020-12-22 13:17:53 +03:00
committed by TeamCityServer
parent e287742842
commit eadec08937
@@ -44,45 +44,53 @@ object MockLibraryUtil {
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun compileJvmLibraryToJar( fun compileJvmLibraryToJar(
sourcesPath: String, sourcesPath: String,
jarName: String, jarName: String,
addSources: Boolean = false, addSources: Boolean = false,
allowKotlinSources: Boolean = true, allowKotlinSources: Boolean = true,
extraOptions: List<String> = emptyList(), extraOptions: List<String> = emptyList(),
extraClasspath: List<String> = emptyList(), extraClasspath: List<String> = emptyList(),
useJava9: Boolean = false useJava9: Boolean = false
): File { ): File {
return compileLibraryToJar( return compileLibraryToJar(
sourcesPath, KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName), jarName, addSources, allowKotlinSources, extraOptions, extraClasspath sourcesPath,
, useJava9)} KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName),
jarName,
addSources,
allowKotlinSources,
extraOptions,
extraClasspath,
useJava9
)
}
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun compileJavaFilesLibraryToJar( fun compileJavaFilesLibraryToJar(
sourcesPath: String, sourcesPath: String,
jarName: String, jarName: String,
addSources: Boolean = false, addSources: Boolean = false,
extraOptions: List<String> = emptyList(), extraOptions: List<String> = emptyList(),
extraClasspath: List<String> = emptyList() extraClasspath: List<String> = emptyList()
): File { ): File {
return compileJvmLibraryToJar( return compileJvmLibraryToJar(
sourcesPath, jarName, addSources, sourcesPath, jarName, addSources,
allowKotlinSources = false, allowKotlinSources = false,
extraClasspath = extraClasspath, extraOptions = extraOptions extraClasspath = extraClasspath, extraOptions = extraOptions
) )
} }
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun compileLibraryToJar( fun compileLibraryToJar(
sourcesPath: String, sourcesPath: String,
contentDir: File, contentDir: File,
jarName: String, jarName: String,
addSources: Boolean = false, addSources: Boolean = false,
allowKotlinSources: Boolean = true, allowKotlinSources: Boolean = true,
extraOptions: List<String> = emptyList(), extraOptions: List<String> = emptyList(),
extraClasspath: List<String> = emptyList(), extraClasspath: List<String> = emptyList(),
useJava9: Boolean = false useJava9: Boolean = false
): File { ): File {
val classesDir = File(contentDir, "classes") val classesDir = File(contentDir, "classes")
@@ -103,19 +111,18 @@ object MockLibraryUtil {
// Probably no kotlin files were present, so dir might not have been created after kotlin compiler // Probably no kotlin files were present, so dir might not have been created after kotlin compiler
if (classesDir.exists()) { if (classesDir.exists()) {
classpath += classesDir.path classpath += classesDir.path
} } else {
else {
FileUtil.createDirectory(classesDir) FileUtil.createDirectory(classesDir)
} }
val options = listOf( val options = listOf(
"-classpath", classpath.joinToString(File.pathSeparator), "-classpath", classpath.joinToString(File.pathSeparator),
"-d", classesDir.path "-d", classesDir.path
) )
val compile = val compile =
if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9 if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9
else KotlinTestUtils::compileJavaFiles else KotlinTestUtils::compileJavaFiles
val success = compile(javaFiles, options) val success = compile(javaFiles, options)
if (!success) { if (!success) {
@@ -170,10 +177,10 @@ object MockLibraryUtil {
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun compileKotlin( fun compileKotlin(
sourcesPath: String, sourcesPath: String,
outDir: File, outDir: File,
extraOptions: List<String> = emptyList(), extraOptions: List<String> = emptyList(),
vararg extraClasspath: String vararg extraClasspath: String
) { ) {
val classpath = mutableListOf<String>() val classpath = mutableListOf<String>()
if (File(sourcesPath).isDirectory) { if (File(sourcesPath).isDirectory) {
@@ -182,9 +189,9 @@ object MockLibraryUtil {
classpath += extraClasspath classpath += extraClasspath
val args = mutableListOf( val args = mutableListOf(
sourcesPath, sourcesPath,
"-d", outDir.absolutePath, "-d", outDir.absolutePath,
"-classpath", classpath.joinToString(File.pathSeparator) "-classpath", classpath.joinToString(File.pathSeparator)
) + extraOptions ) + extraOptions
runJvmCompiler(args) runJvmCompiler(args)
@@ -215,8 +222,8 @@ object MockLibraryUtil {
@Synchronized @Synchronized
private fun createCompilerClassLoader(): ClassLoader { private fun createCompilerClassLoader(): ClassLoader {
return ClassPreloadingUtils.preloadClasses( return ClassPreloadingUtils.preloadClasses(
listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath), listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath),
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
) )
} }
} }