mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-28 00:58:12 -07:00
Merge pull request #488 from pabl0rg/improve-kotlin-compiler-version-tests
Improve kotlin compiler version tests, upgrade to kotlin 1.2.70
This commit is contained in:
commit
7b902eb673
8 changed files with 80 additions and 10 deletions
|
@ -9,7 +9,7 @@ object Constants {
|
||||||
val BUILD_FILE_NAME = "Build.kt"
|
val BUILD_FILE_NAME = "Build.kt"
|
||||||
val BUILD_FILE_DIRECTORY = "kobalt/src"
|
val BUILD_FILE_DIRECTORY = "kobalt/src"
|
||||||
val BUILD_FILE_PATH = KFiles.joinDir(BUILD_FILE_DIRECTORY, BUILD_FILE_NAME)
|
val BUILD_FILE_PATH = KFiles.joinDir(BUILD_FILE_DIRECTORY, BUILD_FILE_NAME)
|
||||||
val KOTLIN_COMPILER_VERSION = "1.2.10"
|
val KOTLIN_COMPILER_VERSION = "1.2.70"
|
||||||
|
|
||||||
internal val DEFAULT_REPOS = listOf<HostConfig>(
|
internal val DEFAULT_REPOS = listOf<HostConfig>(
|
||||||
// "https://maven-central.storage.googleapis.com/",
|
// "https://maven-central.storage.googleapis.com/",
|
||||||
|
|
|
@ -60,6 +60,14 @@ object KobaltLogger {
|
||||||
} else {
|
} else {
|
||||||
Logger(false)
|
Logger(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLogLevel(args: Args) {
|
||||||
|
LOG_LEVEL = when {
|
||||||
|
args.log < Constants.LOG_QUIET_LEVEL -> Constants.LOG_DEFAULT_LEVEL
|
||||||
|
args.log > Constants.LOG_MAX_LEVEL -> Constants.LOG_MAX_LEVEL
|
||||||
|
else -> args.log
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Logger(val dev: Boolean) {
|
class Logger(val dev: Boolean) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ open class NewRunCommand(val info: RunCommandInfo) {
|
||||||
val process = pb.start()
|
val process = pb.start()
|
||||||
|
|
||||||
// Run the command and collect the return code and streams
|
// Run the command and collect the return code and streams
|
||||||
val returnCode = process.waitFor(30, TimeUnit.SECONDS)
|
val returnCode = process.waitFor(60, TimeUnit.SECONDS)
|
||||||
val input =
|
val input =
|
||||||
if (process.inputStream.available() > 0) fromStream(process.inputStream)
|
if (process.inputStream.available() > 0) fromStream(process.inputStream)
|
||||||
else listOf()
|
else listOf()
|
||||||
|
@ -87,12 +87,15 @@ open class NewRunCommand(val info: RunCommandInfo) {
|
||||||
if (process.errorStream.available() > 0) fromStream(process.errorStream)
|
if (process.errorStream.available() > 0) fromStream(process.errorStream)
|
||||||
else listOf()
|
else listOf()
|
||||||
|
|
||||||
|
kobaltLog(3, "info contains errors: " + (info.containsErrors != null))
|
||||||
|
|
||||||
// Check to see if the command succeeded
|
// Check to see if the command succeeded
|
||||||
val isSuccess =
|
val isSuccess =
|
||||||
if (info.containsErrors != null) ! info.containsErrors!!(error)
|
if (info.containsErrors != null) ! info.containsErrors!!(error)
|
||||||
else isSuccess(if (info.ignoreExitValue) true else returnCode, input, error)
|
else isSuccess(if (info.ignoreExitValue) true else returnCode, input, error)
|
||||||
|
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
kobaltLog(3, "success so far")
|
||||||
if (!info.useErrorStreamAsErrorIndicator) {
|
if (!info.useErrorStreamAsErrorIndicator) {
|
||||||
info.successCallback(error + input)
|
info.successCallback(error + input)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,11 +55,7 @@ class Main @Inject constructor(
|
||||||
val args = Args()
|
val args = Args()
|
||||||
val result = JCommander(args)
|
val result = JCommander(args)
|
||||||
result.parse(*argv)
|
result.parse(*argv)
|
||||||
KobaltLogger.LOG_LEVEL = if (args.log < Constants.LOG_QUIET_LEVEL) {
|
KobaltLogger.setLogLevel(args)
|
||||||
Constants.LOG_DEFAULT_LEVEL
|
|
||||||
} else if (args.log > Constants.LOG_MAX_LEVEL) {
|
|
||||||
Constants.LOG_MAX_LEVEL
|
|
||||||
} else args.log
|
|
||||||
return Main.RunInfo(result, args)
|
return Main.RunInfo(result, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
kobalt.version=1.0.114
|
kobalt.version=1.0.115
|
|
@ -9,6 +9,7 @@ import com.beust.kobalt.internal.KobaltPluginXml
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.build.SingleFileBuildSources
|
import com.beust.kobalt.internal.build.SingleFileBuildSources
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
import com.beust.kobalt.misc.KobaltLogger
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import org.testng.annotations.BeforeClass
|
import org.testng.annotations.BeforeClass
|
||||||
import org.testng.annotations.Guice
|
import org.testng.annotations.Guice
|
||||||
|
@ -121,6 +122,9 @@ open class BaseTest(val compilerFactory: BuildFileCompiler.IFactory? = null) {
|
||||||
val main = Kobalt.INJECTOR.getInstance(Main::class.java)
|
val main = Kobalt.INJECTOR.getInstance(Main::class.java)
|
||||||
val args = Args()
|
val args = Args()
|
||||||
val jc = JCommander(args).apply { parse(*commandLine) }
|
val jc = JCommander(args).apply { parse(*commandLine) }
|
||||||
|
|
||||||
|
KobaltLogger.setLogLevel(args)
|
||||||
|
|
||||||
args.buildFile = KFiles.fixSlashes(project.file.absolutePath) + "/kobalt/src/Build.kt"
|
args.buildFile = KFiles.fixSlashes(project.file.absolutePath) + "/kobalt/src/Build.kt"
|
||||||
val result = Main.launchMain(main, jc, args, arrayOf("assemble"))
|
val result = Main.launchMain(main, jc, args, arrayOf("assemble"))
|
||||||
return LaunchProjectResult(project, result)
|
return LaunchProjectResult(project, result)
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.beust.kobalt.internal
|
||||||
|
|
||||||
|
import com.beust.kobalt.BaseTest
|
||||||
|
import com.beust.kobalt.BuildFile
|
||||||
|
import com.beust.kobalt.ProjectFile
|
||||||
|
import com.beust.kobalt.ProjectInfo
|
||||||
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class KotlinCompilerVersionTest : BaseTest() {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldCompileWithExternalKotlin() {
|
||||||
|
val projectInfo = ProjectInfo(
|
||||||
|
BuildFile(
|
||||||
|
listOf("com.beust.kobalt.plugin.packaging.*", "com.beust.kobalt.plugin.kotlin.kotlinCompiler"),
|
||||||
|
"""
|
||||||
|
kotlinCompiler {
|
||||||
|
version = "1.2.60"
|
||||||
|
}
|
||||||
|
assemble{ jar{} }
|
||||||
|
"""
|
||||||
|
),
|
||||||
|
listOf(
|
||||||
|
ProjectFile("src/main/kotlin/A.kt", "val a = Bob()"),
|
||||||
|
ProjectFile("src/main/kotlin/Bob.java", "class Bob { }")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val result = launchProject(projectInfo, arrayOf("assemble", "--log", "2"))
|
||||||
|
|
||||||
|
val project = result.projectDescription
|
||||||
|
val jarFile = File(KFiles.joinDir(project.file.absolutePath, "kobaltBuild/libs", project.name + "-"
|
||||||
|
+ project.version + ".jar"))
|
||||||
|
|
||||||
|
assertThat(jarFile).exists()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldFailWhenKotlinVersionDoesNotExist() {
|
||||||
|
val projectInfo = ProjectInfo(
|
||||||
|
BuildFile(
|
||||||
|
listOf("com.beust.kobalt.plugin.packaging.*", "com.beust.kobalt.plugin.kotlin.kotlinCompiler"),
|
||||||
|
"""
|
||||||
|
kotlinCompiler { version = "1.1.20" }
|
||||||
|
assemble{ jar{} }
|
||||||
|
"""
|
||||||
|
),
|
||||||
|
listOf(ProjectFile("src/main/kotlin/A.kt", "val a = \"foo\""))
|
||||||
|
)
|
||||||
|
|
||||||
|
val result = launchProject(projectInfo, arrayOf("assemble", "--log", "2"))
|
||||||
|
|
||||||
|
assertThat(result.result).isEqualTo(1)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beust.kobalt.misc
|
package com.beust.kobalt.misc
|
||||||
|
|
||||||
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.BaseTest
|
import com.beust.kobalt.BaseTest
|
||||||
import com.beust.kobalt.internal.KobaltSettings
|
import com.beust.kobalt.internal.KobaltSettings
|
||||||
import com.beust.kobalt.internal.KobaltSettingsXml
|
import com.beust.kobalt.internal.KobaltSettingsXml
|
||||||
|
@ -95,7 +96,7 @@ class MavenResolverTest : BaseTest() {
|
||||||
private fun resolve(id: String): List<ArtifactResult> {
|
private fun resolve(id: String): List<ArtifactResult> {
|
||||||
val system = Booter.newRepositorySystem()
|
val system = Booter.newRepositorySystem()
|
||||||
val session = Booter.newRepositorySystemSession(system,
|
val session = Booter.newRepositorySystemSession(system,
|
||||||
localRepo.localRepo, KobaltSettings(KobaltSettingsXml()), EventBus())
|
localRepo.localRepo, KobaltSettings(KobaltSettingsXml()), Args(), EventBus())
|
||||||
val artifact = DefaultArtifact(id)
|
val artifact = DefaultArtifact(id)
|
||||||
|
|
||||||
val collectRequest = CollectRequest().apply {
|
val collectRequest = CollectRequest().apply {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue