[Test] Reformat MockLibraryUtil according to code style
This commit is contained in:
committed by
TeamCityServer
parent
e287742842
commit
eadec08937
@@ -44,45 +44,53 @@ object MockLibraryUtil {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun compileJvmLibraryToJar(
|
||||
sourcesPath: String,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
allowKotlinSources: Boolean = true,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList(),
|
||||
useJava9: Boolean = false
|
||||
sourcesPath: String,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
allowKotlinSources: Boolean = true,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList(),
|
||||
useJava9: Boolean = false
|
||||
): File {
|
||||
return compileLibraryToJar(
|
||||
sourcesPath, KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName), jarName, addSources, allowKotlinSources, extraOptions, extraClasspath
|
||||
, useJava9)}
|
||||
sourcesPath,
|
||||
KtTestUtil.tmpDirForReusableFolder("testLibrary-" + jarName),
|
||||
jarName,
|
||||
addSources,
|
||||
allowKotlinSources,
|
||||
extraOptions,
|
||||
extraClasspath,
|
||||
useJava9
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun compileJavaFilesLibraryToJar(
|
||||
sourcesPath: String,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList()
|
||||
sourcesPath: String,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList()
|
||||
): File {
|
||||
return compileJvmLibraryToJar(
|
||||
sourcesPath, jarName, addSources,
|
||||
allowKotlinSources = false,
|
||||
extraClasspath = extraClasspath, extraOptions = extraOptions
|
||||
sourcesPath, jarName, addSources,
|
||||
allowKotlinSources = false,
|
||||
extraClasspath = extraClasspath, extraOptions = extraOptions
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun compileLibraryToJar(
|
||||
sourcesPath: String,
|
||||
contentDir: File,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
allowKotlinSources: Boolean = true,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList(),
|
||||
useJava9: Boolean = false
|
||||
sourcesPath: String,
|
||||
contentDir: File,
|
||||
jarName: String,
|
||||
addSources: Boolean = false,
|
||||
allowKotlinSources: Boolean = true,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
extraClasspath: List<String> = emptyList(),
|
||||
useJava9: Boolean = false
|
||||
): File {
|
||||
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
|
||||
if (classesDir.exists()) {
|
||||
classpath += classesDir.path
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
FileUtil.createDirectory(classesDir)
|
||||
}
|
||||
|
||||
val options = listOf(
|
||||
"-classpath", classpath.joinToString(File.pathSeparator),
|
||||
"-d", classesDir.path
|
||||
"-classpath", classpath.joinToString(File.pathSeparator),
|
||||
"-d", classesDir.path
|
||||
)
|
||||
|
||||
val compile =
|
||||
if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9
|
||||
else KotlinTestUtils::compileJavaFiles
|
||||
if (useJava9) KotlinTestUtils::compileJavaFilesExternallyWithJava9
|
||||
else KotlinTestUtils::compileJavaFiles
|
||||
|
||||
val success = compile(javaFiles, options)
|
||||
if (!success) {
|
||||
@@ -170,10 +177,10 @@ object MockLibraryUtil {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun compileKotlin(
|
||||
sourcesPath: String,
|
||||
outDir: File,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
vararg extraClasspath: String
|
||||
sourcesPath: String,
|
||||
outDir: File,
|
||||
extraOptions: List<String> = emptyList(),
|
||||
vararg extraClasspath: String
|
||||
) {
|
||||
val classpath = mutableListOf<String>()
|
||||
if (File(sourcesPath).isDirectory) {
|
||||
@@ -182,9 +189,9 @@ object MockLibraryUtil {
|
||||
classpath += extraClasspath
|
||||
|
||||
val args = mutableListOf(
|
||||
sourcesPath,
|
||||
"-d", outDir.absolutePath,
|
||||
"-classpath", classpath.joinToString(File.pathSeparator)
|
||||
sourcesPath,
|
||||
"-d", outDir.absolutePath,
|
||||
"-classpath", classpath.joinToString(File.pathSeparator)
|
||||
) + extraOptions
|
||||
|
||||
runJvmCompiler(args)
|
||||
@@ -215,8 +222,8 @@ object MockLibraryUtil {
|
||||
@Synchronized
|
||||
private fun createCompilerClassLoader(): ClassLoader {
|
||||
return ClassPreloadingUtils.preloadClasses(
|
||||
listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath),
|
||||
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
|
||||
listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath),
|
||||
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user