1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Fixed various syntax.

This commit is contained in:
Erik C. Thauvin 2017-10-31 23:17:42 -07:00
parent c99a9eb6cd
commit 05d0ff04fb
2 changed files with 32 additions and 39 deletions

View file

@ -89,12 +89,12 @@ class KotlinCompiler @Inject constructor(
// the K2JVMCompiler class directly
val actualVersion = kotlinVersion(project)
if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION
return if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION
|| info.compilerSeparateProcess) {
return invokeCompilerInSeparateProcess(classpath, info, actualVersion, project)
invokeCompilerInSeparateProcess(classpath, info, actualVersion, project)
} else {
return invokeCompilerDirectly(project, projectName ?: "kobalt-" + Random().nextInt(), outputDir,
invokeCompilerDirectly(project, projectName ?: "kobalt-" + Random().nextInt(), outputDir,
info, classpath, filesToCompile)
}
}
@ -111,7 +111,7 @@ class KotlinCompiler @Inject constructor(
.filterNotNull()
.joinToString(" ")
val xFlagsArray = xFlagsString.split(" ").toTypedArray() ?: emptyArray()
val xFlagsArray = xFlagsString.split(" ").toTypedArray()
val newArgs = listOf(
"-classpath", compilerClasspath,
K2JVMCompiler::class.java.name,
@ -145,7 +145,7 @@ class KotlinCompiler @Inject constructor(
// Collect the compiler args from kotlinCompiler{} and from settings.xml and parse them
val args2 =
info.compilerArgs +
(settings.kobaltCompilerFlags?.split(" ") ?: listOf<String>())
(settings.kobaltCompilerFlags?.split(" ") ?: listOf())
val args = K2JVMCompilerArguments()
val compiler = K2JVMCompiler()
compiler.parseArguments(args2.toTypedArray(), args)
@ -225,7 +225,7 @@ class KotlinCompiler @Inject constructor(
}
fun dump(location: CompilerMessageLocation?, s: String) =
if (location != null && location.lineContent != null) {
if (location?.lineContent != null) {
with(location) {
"$lineContent\n$path:$line:$column $s"
}
@ -250,24 +250,22 @@ class KotlinCompiler @Inject constructor(
// // TODO: experimental should be removed as soon as it becomes standard
// System.setProperty("kotlin.incremental.compilation.experimental", "true")
val result =
if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) {
log(2, " Kotlin incremental compilation is disabled")
val duration = benchmarkMillis {
compiler.exec(collector, Services.Builder().build(), args)
}
log(1, " Regular compilation time: ${duration.first} ms")
TaskResult(duration.second == ExitCode.OK)
} else {
log(1, " Kotlin incremental compilation is enabled")
val start = System.currentTimeMillis()
val duration = benchmarkMillis {
compileIncrementally(filesToCompile, sourceFiles, outputDir, info, args, collector)
}
log(1, " Incremental compilation time: ${duration.first} ms")
TaskResult()
}
return result
return if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) {
log(2, " Kotlin incremental compilation is disabled")
val duration = benchmarkMillis {
compiler.exec(collector, Services.Builder().build(), args)
}
log(1, " Regular compilation time: ${duration.first} ms")
TaskResult(duration.second == ExitCode.OK)
} else {
log(1, " Kotlin incremental compilation is enabled")
//val start = System.currentTimeMillis()
val duration = benchmarkMillis {
compileIncrementally(filesToCompile, sourceFiles, outputDir, info, args, collector)
}
log(1, " Incremental compilation time: ${duration.first} ms")
TaskResult()
}
}
private fun compileIncrementally(filesToCompile: Int, sourceFiles: List<String>, outputDir: String?,
@ -381,8 +379,7 @@ class KotlinCompiler @Inject constructor(
= dependencyManager.create("org.jetbrains" + ".kotlin:kotlin-compiler-embeddable:$version")
fun compilerEmbeddableDependencies(project: Project?, version: String): List<IClasspathDependency> {
val deps = dependencyManager.transitiveClosure(listOf(compilerDep(version)), requiredBy = project?.name ?: "")
return deps
return dependencyManager.transitiveClosure(listOf(compilerDep(version)), requiredBy = project?.name ?: "")
}
/**
@ -415,7 +412,7 @@ class KotlinCompiler @Inject constructor(
if (project != null) {
listOf(KFiles.joinDir(project.directory, project.buildDirectory, KFiles.CLASSES_DIR))
} else {
emptyList<String>()
emptyList()
}
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args,
friendPaths, context?.internalContext?.forceRecompile ?: false, compilerSeparateProcess)

View file

@ -80,12 +80,12 @@ class BintrayApi @Inject constructor(val http: Http,
// level = HttpLoggingInterceptor.Level.BASIC
// })
builder.interceptors().add(Interceptor { chain ->
val original = chain.request();
val original = chain.request()
chain.proceed(original.newBuilder()
.header("Authorization", Credentials.basic(username, password))
.method(original.method(), original.body())
.build());
.build())
})
val okHttpClient = builder.build()
@ -163,7 +163,7 @@ class BintrayApi @Inject constructor(val http: Http,
fun dots(total: Int, list: List<Boolean>, file: File? = null): String {
val spaces: String = Array(total - list.size, { " " }).joinToString("")
return "|" + list.map { if (it) "." else "X" }.joinToString("") + spaces +
return "|" + list.joinToString("") { if (it) "." else "X" } + spaces +
(if (file != null) "| [ $file ]" else "|")
}
@ -208,7 +208,7 @@ class BintrayApi @Inject constructor(val http: Http,
return TaskResult()
} else {
error(" Errors while uploading:\n" + errorMessages.map { " $it" }.joinToString("\n"))
error(" Errors while uploading:\n" + errorMessages.joinToString("\n") { " $it" })
return TaskResult(false, errorMessage = errorMessages.joinToString("\n"))
}
} else {
@ -221,7 +221,7 @@ class BintrayApi @Inject constructor(val http: Http,
fun JsonObject.addNonNull(name: String, value: String?) {
if (value != null) {
addProperty(name, value);
addProperty(name, value)
}
}
@ -236,20 +236,16 @@ class ConverterFactory : Converter.Factory() {
override fun requestBodyConverter(type: Type, parameterAnnotations: Array<out Annotation>,
methodAnnotations: Array<out Annotation>,
retrofit: Retrofit?): Converter<*, RequestBody>? {
val result =
if (type.typeName == File::class.java.name) FileBodyConverter()
else GsonBodyConverter()
return result
return if (type.typeName == File::class.java.name) FileBodyConverter()
else GsonBodyConverter()
}
}
class GsonResponseBodyConverter(private val gson: Gson, private val adapter: TypeAdapter<out Any>) : Converter<ResponseBody, Any> {
override fun convert(value: ResponseBody): Any {
val jsonReader = gson.newJsonReader(value.charStream())
try {
value.use {
return adapter.read(jsonReader)
} finally {
value.close()
}
}
}